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.RelationalEntityTablePropertiesDialog;
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.domainimplementationmodel.DomainRelationalStorageDefinition;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTable;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTableClass;
031:
032: /* RelationalEntityTable user object class */
033:
034: public class RelationalEntityTableUserObject extends BaseUserObject {
035: public static final int ADD_REFERENCECOLUMN = 1;
036: public static final int ADD_ATTRIBUTECOLUMN = 2;
037:
038: private RelationalEntityTable mRelationalEntityTable = null;
039: private AttributeColumnAction mAttributeColumnAction = new AttributeColumnAction();
040: private ReferenceColumnAction mReferenceColumnAction = new ReferenceColumnAction();
041:
042: public RelationalEntityTableUserObject(
043: RelationalEntityTable pRelationalEntityTable) {
044: super (pRelationalEntityTable, Application.ENTITYTABLE_ICON);
045: mRelationalEntityTable = pRelationalEntityTable;
046: }
047:
048: public RelationalEntityTableUserObject(
049: RelationalEntityTable pRelationalEntityTable,
050: String pCaption, int pMode) {
051: super (pRelationalEntityTable, pCaption, pMode);
052: mRelationalEntityTable = pRelationalEntityTable;
053: }
054:
055: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
056: RelationalEntityTableClass lClass = pPackage
057: .getEnterpriseModel().getSystemImplementationModel()
058: .getDomainImplementationModel()
059: .getRelationalEntityTable();
060: return new RelationalEntityTableUserObject(lClass
061: .createRelationalEntityTable());
062: }
063:
064: public static void addNewEntityTable(
065: DomainRelationalStorageDefinition pStorageDefinition)
066: throws Exception {
067: new RelationalEntityTableUserObject(null).addNewObject(
068: getObjectPackage(pStorageDefinition),
069: pStorageDefinition.getEntityTables());
070: }
071:
072: // return object root node captions
073: public String getRootNodeName() {
074: return Application.getString("entitytables_node");
075: }
076:
077: // load object properties into grid control
078: public void loadObjectProperties(PropertiesTableModel pModel)
079: throws Exception {
080: super .loadObjectProperties(pModel);
081: if (pModel == null || mRelationalEntityTable == null)
082: return;
083:
084: addModelElement(pModel, "Entity", mRelationalEntityTable
085: .getEntity());
086: pModel.AddProperty("Instance Id Column Name Override",
087: mRelationalEntityTable
088: .getInstanceIdColumnNameOverride());
089: pModel.AddProperty("Instance Id Column Name Suggestion",
090: mRelationalEntityTable
091: .getInstanceIdColumnNameSuggestion());
092: pModel.AddProperty("Name Override", mRelationalEntityTable
093: .getNameOverride());
094: pModel.AddProperty("Name Suggestion", mRelationalEntityTable
095: .getNameSuggestion());
096: pModel.AddProperty(
097: "Natural Primary Key Constraint Name Override",
098: mRelationalEntityTable
099: .getNaturalPrimaryKeyConstraintNameOverride());
100: pModel
101: .AddProperty(
102: "Natural Primary Key Constraint Name Suggestion",
103: mRelationalEntityTable
104: .getNaturalPrimaryKeyConstraintNameSuggestion());
105: pModel.AddProperty("Primary Key Constraint Name Override",
106: mRelationalEntityTable
107: .getPrimaryKeyConstraintNameOverride());
108: pModel.AddProperty("Primary Key Constraint Name Suggestion",
109: mRelationalEntityTable
110: .getPrimaryKeyConstraintNameSuggestion());
111: pModel.AddProperty("State Column Name Override",
112: mRelationalEntityTable.getStateColumnNameOverride());
113: pModel.AddProperty("State Column Name Suggestion",
114: mRelationalEntityTable.getStateColumnNameSuggestion());
115: pModel.AddProperty(
116: "State Referential Constraint Name Override",
117: mRelationalEntityTable
118: .getStateReferentialConstraintNameOverride());
119: pModel.AddProperty(
120: "State Referential Constraint Name Suggestion",
121: mRelationalEntityTable
122: .getStateReferentialConstraintNameSuggestion());
123: pModel.AddProperty("Table Alias", mRelationalEntityTable
124: .getTableAlias());
125: pModel
126: .AddProperty("Version Id Column Name Override",
127: mRelationalEntityTable
128: .getVersionIdColumnNameOverride());
129: pModel.AddProperty("Version Id Column Name Suggestion",
130: mRelationalEntityTable
131: .getVersionIdColumnNameSuggestion());
132: pModel.AddProperty("Has Natural Primary Key",
133: boolToString(mRelationalEntityTable
134: .isHasNaturalPrimaryKey()));
135: pModel
136: .AddProperty("Has State Column",
137: boolToString(mRelationalEntityTable
138: .isHasStateColumn()));
139: pModel.AddProperty("Has Version Id Column",
140: boolToString(mRelationalEntityTable
141: .isHasVersionIdColumn()));
142: }
143:
144: public BasePropertiesDialog getObjectEditor() {
145: return new RelationalEntityTablePropertiesDialog();
146: }
147:
148: public void fillActionsList(ArrayList pList) {
149: switch (mMode) {
150: case ALL_ACTIONS:
151: super .fillActionsList(pList);
152: pList.add(new SeparatorAction());
153: pList.add(mAttributeColumnAction);
154: pList.add(mReferenceColumnAction);
155: break;
156: case ADD_ATTRIBUTECOLUMN:
157: pList.add(mAttributeColumnAction);
158: break;
159: case ADD_REFERENCECOLUMN:
160: pList.add(mReferenceColumnAction);
161: break;
162: }
163: }
164:
165: private void addAttributeColumn() {
166: try {
167: RelationalEntityTableAttributeColumnUserObject
168: .addNewAttributeColumn(mRelationalEntityTable);
169: } catch (Exception e) {
170: Application.processError(e);
171: }
172: }
173:
174: private void addReferenceColumn() {
175: try {
176: RelationalEntityTableReferenceColumnUserObject
177: .addNewReferenceColumn(mRelationalEntityTable);
178: } catch (Exception e) {
179: Application.processError(e);
180: }
181: }
182:
183: /* Actions */
184:
185: public class ReferenceColumnAction extends BaseAction {
186: public ReferenceColumnAction() {
187: super ("Add New Reference Column", Application
188: .getAddIcon(Application.FIELDS_ICON));
189: }
190:
191: public void actionPerformed(ActionEvent arg0) {
192: addReferenceColumn();
193: }
194: }
195:
196: public class AttributeColumnAction extends BaseAction {
197: public AttributeColumnAction() {
198: super ("Add New Attribute Column", Application
199: .getAddIcon(Application.ATTRIBUTECOLUMN_ICON));
200: }
201:
202: public void actionPerformed(ActionEvent arg0) {
203: addAttributeColumn();
204: }
205: }
206: }
|