001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.applications.designstudio.userobjects;
016:
017: import java.awt.event.ActionEvent;
018: import java.util.ArrayList;
019:
020: import com.metaboss.applications.designstudio.Application;
021: import com.metaboss.applications.designstudio.BaseAction;
022: import com.metaboss.applications.designstudio.BasePropertiesDialog;
023: import com.metaboss.applications.designstudio.BaseUserObject;
024: import com.metaboss.applications.designstudio.components.SeparatorAction;
025: import com.metaboss.applications.designstudio.propertiesdialogs.RelationalStorageDefinitionPropertiesDialog;
026: import com.metaboss.applications.designstudio.propertiesview.PropertiesTableModel;
027: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.DomainRelationalStorageDefinition;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.DomainRelationalStorageDefinitionClass;
031:
032: /* DomainRelationalStorageDefinition user object */
033:
034: public class RelationalStorageDefinitionUserObject extends
035: BaseUserObject {
036: public static final int ADD_ENTITYTABLES = 1;
037: public static final int ADD_ASSOCIATIONTABLES = 2;
038: public static final int ADD_RELATIONALTABLES = 3;
039:
040: private DomainRelationalStorageDefinition mStorageDefinition = null;
041: private AssociationTableAction mAssociationTableAction = new AssociationTableAction();
042: private EntityTableAction mEntityTableAction = new EntityTableAction();
043: private RelationalTableAction mRelationalTableAction = new RelationalTableAction();
044:
045: public RelationalStorageDefinitionUserObject(
046: DomainRelationalStorageDefinition pStorageDefinition) {
047: super (pStorageDefinition, Application.DOMAINIMPL_ICON);
048: mStorageDefinition = pStorageDefinition;
049: }
050:
051: public RelationalStorageDefinitionUserObject(
052: DomainRelationalStorageDefinition pStorageDefinition,
053: String pCaption, int pMode) {
054: super (pStorageDefinition, pCaption, pMode);
055: mStorageDefinition = pStorageDefinition;
056: }
057:
058: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
059: DomainRelationalStorageDefinitionClass lClass = pPackage
060: .getEnterpriseModel().getSystemImplementationModel()
061: .getDomainImplementationModel()
062: .getDomainRelationalStorageDefinition();
063: return new RelationalStorageDefinitionUserObject(lClass
064: .createDomainRelationalStorageDefinition());
065: }
066:
067: public static void addNewStorageDefinition(Domain pDomain)
068: throws Exception {
069: new RelationalStorageDefinitionUserObject(null).addNewObject(
070: getObjectPackage(pDomain), pDomain
071: .getRelationalImplementations());
072: }
073:
074: // return object root node captions
075: public String getRootNodeName() {
076: return Application.getString("domainimplementations_node");
077: }
078:
079: // load object properties into grid control
080: public void loadObjectProperties(PropertiesTableModel pModel)
081: throws Exception {
082: super .loadObjectProperties(pModel);
083: if (pModel == null || mStorageDefinition == null)
084: return;
085:
086: //addModelElement(pModel, "Domain", mStorageDefinition.getDomain());
087: addModelElement(pModel, "Technology", mStorageDefinition
088: .getTechnology());
089: }
090:
091: public void fillActionsList(ArrayList pList) {
092: switch (mMode) {
093: case ALL_ACTIONS:
094: super .fillActionsList(pList);
095: pList.add(new SeparatorAction());
096: pList.add(mAssociationTableAction);
097: pList.add(mEntityTableAction);
098: pList.add(mRelationalTableAction);
099: break;
100: case ADD_ASSOCIATIONTABLES:
101: pList.add(mAssociationTableAction);
102: break;
103: case ADD_ENTITYTABLES:
104: pList.add(mEntityTableAction);
105: break;
106: case ADD_RELATIONALTABLES:
107: pList.add(mRelationalTableAction);
108: break;
109: }
110: }
111:
112: public BasePropertiesDialog getObjectEditor() {
113: return new RelationalStorageDefinitionPropertiesDialog();
114: }
115:
116: // add new AssociationTable
117: private void addAssociationTable() {
118: try {
119: RelationalAssociationTableUserObject
120: .addNewAssociationTable(mStorageDefinition);
121: } catch (Exception e) {
122: Application.processError(e);
123: }
124: }
125:
126: // add new EntityTable
127: private void addEntityTable() {
128: try {
129: RelationalEntityTableUserObject
130: .addNewEntityTable(mStorageDefinition);
131: } catch (Exception e) {
132: Application.processError(e);
133: }
134: }
135:
136: // add new RelationalTable
137: private void addRelationalTable() {
138: try {
139: RelationalReferenceTableUserObject
140: .addNewReferenceTable(mStorageDefinition);
141: } catch (Exception e) {
142: Application.processError(e);
143: }
144: }
145:
146: /* Actions */
147:
148: public class AssociationTableAction extends BaseAction {
149: public AssociationTableAction() {
150: super ("Add New Association Table", Application
151: .getAddIcon(Application.ASSOCIATIONTABLE_ICON));
152: }
153:
154: public void actionPerformed(ActionEvent arg0) {
155: addAssociationTable();
156: }
157: }
158:
159: public class EntityTableAction extends BaseAction {
160: public EntityTableAction() {
161: super ("Add New Entity Table", Application
162: .getAddIcon(Application.ENTITYTABLE_ICON));
163: }
164:
165: public void actionPerformed(ActionEvent arg0) {
166: addEntityTable();
167: }
168: }
169:
170: public class RelationalTableAction extends BaseAction {
171: public RelationalTableAction() {
172: super ("Add New Relational Table", Application
173: .getAddIcon(Application.TABLE_ICON));
174: }
175:
176: public void actionPerformed(ActionEvent arg0) {
177: addRelationalTable();
178: }
179: }
180: }
|