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.propertiesdialogs;
016:
017: import java.awt.Dimension;
018:
019: import javax.swing.JComboBox;
020: import javax.swing.JPanel;
021: import javax.swing.JTextArea;
022: import javax.swing.JTextField;
023:
024: import com.metaboss.applications.designstudio.userobjects.EntityItem;
025: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTable;
028:
029: /* RelationalEntityTable user object class */
030:
031: public class RelationalEntityTablePropertiesDialog extends
032: ModelElementPropertiesDialog {
033: private JPanel mOverridePanel = new JPanel();
034: //properties
035: private JComboBox mEntityField = new JComboBox();
036: private JTextField mTableAliasField = new JTextField();
037: private JTextArea mDescriptionField = new JTextArea(8, 40);
038: //override
039: private JTextField mInstanceIdColumnNameOverrideField = new JTextField();
040: private JTextField mNameOverrideField = new JTextField();
041: private JTextField mNaturalPrimaryKeyConstraintNameOverrideField = new JTextField();
042: private JTextField mPrimaryKeyConstraintNameOverrideField = new JTextField();
043: private JTextField mStateColumnNameOverrideField = new JTextField();
044: private JTextField mStateReferentialConstraintNameOverrideField = new JTextField();
045: private JTextField mVersionIdColumnNameOverrideField = new JTextField();
046:
047: public RelationalEntityTablePropertiesDialog() {
048: super ("Relational Entity Table", new Dimension(400, 310));
049:
050: mOverridePanel.setLayout(mClientGridBagLayout);
051:
052: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
053: addComboBox(mPropertiesPanel, "Entity: ", mEntityField, 2, true);
054: addTextField(mPropertiesPanel, "Table Alias: ",
055: mTableAliasField, 3, false);
056: addTextArea(mPropertiesPanel, "Description: ",
057: mDescriptionField, 4, false);
058:
059: addTextField(mOverridePanel, "Instance Id Column Name: ",
060: mInstanceIdColumnNameOverrideField, 1, false);
061: addTextField(mOverridePanel, "Name: ", mNameOverrideField, 2,
062: false);
063: addTextField(mOverridePanel,
064: "Natural Primary Key Constraint Name: ",
065: mNaturalPrimaryKeyConstraintNameOverrideField, 3, false);
066: addTextField(mOverridePanel, "Primary Key Constraint Name: ",
067: mPrimaryKeyConstraintNameOverrideField, 4, false);
068: addTextField(mOverridePanel, "State Column Name: ",
069: mStateColumnNameOverrideField, 5, false);
070: addTextField(mOverridePanel,
071: "State Referential Constraint Name: ",
072: mStateReferentialConstraintNameOverrideField, 6, false);
073: addTextField(mOverridePanel, "Version Id Column Name: ",
074: mVersionIdColumnNameOverrideField, 7, false);
075:
076: mTabControl
077: .insertTab("Override", null, mOverridePanel, null, 1);
078: mEntityField.addItemListener(new NameElementChangeListener());
079: }
080:
081: // load entity table properties
082: public void loadProperties(ModelElement pObject) throws Exception {
083: if (pObject != null && pObject instanceof RelationalEntityTable) {
084: RelationalEntityTable lEntityTable = (RelationalEntityTable) pObject;
085:
086: EntityItem.loadBoxWithEntities(mEntityField, lEntityTable
087: .getDomainStorage().getDomain(), false);
088:
089: mNameField.setText(lEntityTable.getName());
090: mEntityField.setSelectedIndex(EntityItem
091: .findEntityItemIndex(mEntityField, lEntityTable
092: .getEntity()));
093: mTableAliasField.setText(lEntityTable.getTableAlias());
094: mInstanceIdColumnNameOverrideField.setText(lEntityTable
095: .getInstanceIdColumnNameOverride());
096: mNameOverrideField.setText(lEntityTable.getNameOverride());
097: mNaturalPrimaryKeyConstraintNameOverrideField
098: .setText(lEntityTable
099: .getNaturalPrimaryKeyConstraintNameOverride());
100: mPrimaryKeyConstraintNameOverrideField.setText(lEntityTable
101: .getPrimaryKeyConstraintNameOverride());
102: mStateColumnNameOverrideField.setText(lEntityTable
103: .getStateColumnNameOverride());
104: mStateReferentialConstraintNameOverrideField
105: .setText(lEntityTable
106: .getStateReferentialConstraintNameOverride());
107: mVersionIdColumnNameOverrideField.setText(lEntityTable
108: .getVersionIdColumnNameOverride());
109: mDescriptionField.setText(lEntityTable.getDescription());
110: }
111: super .loadProperties(pObject);
112: }
113:
114: // save entity table proeprties
115: public void saveProperties(ModelElement pObject) throws Exception {
116: super .saveProperties(pObject);
117: if (pObject != null && pObject instanceof RelationalEntityTable) {
118: RelationalEntityTable lEntityTable = (RelationalEntityTable) pObject;
119:
120: lEntityTable.setName(mNameField.getText());
121: lEntityTable.setTableAlias(mTableAliasField.getText());
122: lEntityTable
123: .setInstanceIdColumnNameOverride(mInstanceIdColumnNameOverrideField
124: .getText());
125: lEntityTable.setNameOverride(mNameOverrideField.getText());
126: lEntityTable
127: .setNaturalPrimaryKeyConstraintNameOverride(mNaturalPrimaryKeyConstraintNameOverrideField
128: .getText());
129: lEntityTable
130: .setPrimaryKeyConstraintNameOverride(mPrimaryKeyConstraintNameOverrideField
131: .getText());
132: lEntityTable
133: .setStateColumnNameOverride(mStateColumnNameOverrideField
134: .getText());
135: lEntityTable
136: .setStateReferentialConstraintNameOverride(mStateReferentialConstraintNameOverrideField
137: .getText());
138: lEntityTable
139: .setVersionIdColumnNameOverride(mVersionIdColumnNameOverrideField
140: .getText());
141: lEntityTable.setDescription(mDescriptionField.getText());
142:
143: EntityItem lItem = (EntityItem) mEntityField
144: .getSelectedItem();
145: if (lItem != null)
146: lEntityTable.setEntity(lItem.mEntity);
147: else
148: lEntityTable.setEntity(null);
149: }
150: }
151:
152: protected ModelElement getNameElement() {
153: Entity lResult = null;
154: try {
155: lResult = ((EntityItem) mEntityField.getSelectedItem()).mEntity;
156: } catch (Exception e) {
157: lResult = null;
158: }
159: return lResult;
160: }
161: }
|