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.AssociationItem;
025: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Association;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalAssociationTable;
028:
029: /* RelationalAssociationTable user object */
030:
031: public class RelationalAssociationTablePropertiesDialog extends
032: ModelElementPropertiesDialog {
033: private JPanel mOverridePanel = new JPanel();
034: //properties
035: private JComboBox mAssociationField = new JComboBox();
036: private JTextField mTableAliasField = new JTextField();
037: private JTextArea mDescriptionField = new JTextArea(8, 40);
038: //override
039: private JTextField mFirstRoleColumnNameOverrideField = new JTextField();
040: private JTextField mFirstRoleReferentialConstraintNameOverrideField = new JTextField();
041: private JTextField mNameOverrideField = new JTextField();
042: private JTextField mPrimaryKeyConstraintNameOverrideField = new JTextField();
043: private JTextField mSecondRoleColumnNameOverrideField = new JTextField();
044: private JTextField mSecondRoleReferentialConstraintNameOverrideField = new JTextField();
045:
046: public RelationalAssociationTablePropertiesDialog() {
047: super ("Relational Association Table", new Dimension(400, 310));
048:
049: mOverridePanel.setLayout(mClientGridBagLayout);
050:
051: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
052: addComboBox(mPropertiesPanel, "Association: ",
053: mAssociationField, 2, true);
054: addTextField(mPropertiesPanel, "Table Alias: ",
055: mTableAliasField, 3, false);
056: addTextArea(mPropertiesPanel, "Description: ",
057: mDescriptionField, 4, false);
058:
059: addTextField(mOverridePanel, "First Role Column Name: ",
060: mFirstRoleColumnNameOverrideField, 3, false);
061: addTextField(mOverridePanel,
062: "First Role Referential Constraint Name: ",
063: mFirstRoleReferentialConstraintNameOverrideField, 4,
064: false);
065: addTextField(mOverridePanel, "Name: ", mNameOverrideField, 5,
066: false);
067: addTextField(mOverridePanel, "Primary Key Constraint Name: ",
068: mPrimaryKeyConstraintNameOverrideField, 6, false);
069: addTextField(mOverridePanel, "Second Role Column Name: ",
070: mSecondRoleColumnNameOverrideField, 7, false);
071: addTextField(mOverridePanel,
072: "Second Role Referential Constraint Name: ",
073: mSecondRoleReferentialConstraintNameOverrideField, 8,
074: false);
075:
076: mTabControl
077: .insertTab("Override", null, mOverridePanel, null, 1);
078: mAssociationField
079: .addItemListener(new NameElementChangeListener());
080: }
081:
082: // load association table properties
083: public void loadProperties(ModelElement pObject) throws Exception {
084: if (pObject != null
085: && pObject instanceof RelationalAssociationTable) {
086: RelationalAssociationTable lAssociationTable = (RelationalAssociationTable) pObject;
087:
088: AssociationItem.loadBoxWithAssociations(mAssociationField,
089: lAssociationTable.getDomainStorage().getDomain(),
090: false);
091:
092: mNameField.setText(lAssociationTable.getName());
093: mAssociationField.setSelectedIndex(AssociationItem
094: .findAssociationItemIndex(mAssociationField,
095: lAssociationTable.getAssociation()));
096: mTableAliasField.setText(lAssociationTable.getTableAlias());
097: mFirstRoleColumnNameOverrideField.setText(lAssociationTable
098: .getFirstRoleColumnNameOverride());
099: mFirstRoleReferentialConstraintNameOverrideField
100: .setText(lAssociationTable
101: .getFirstRoleReferentialConstraintNameOverride());
102: mNameOverrideField.setText(lAssociationTable
103: .getNameOverride());
104: mPrimaryKeyConstraintNameOverrideField
105: .setText(lAssociationTable
106: .getPrimaryKeyConstraintNameOverride());
107: mSecondRoleColumnNameOverrideField
108: .setText(lAssociationTable
109: .getSecondRoleColumnNameOverride());
110: mSecondRoleReferentialConstraintNameOverrideField
111: .setText(lAssociationTable
112: .getSecondRoleReferentialConstraintNameOverride());
113: mDescriptionField.setText(lAssociationTable
114: .getDescription());
115: }
116: super .loadProperties(pObject);
117: }
118:
119: // save association table proeprties
120: public void saveProperties(ModelElement pObject) throws Exception {
121: super .saveProperties(pObject);
122: if (pObject != null
123: && pObject instanceof RelationalAssociationTable) {
124: RelationalAssociationTable lAssociationTable = (RelationalAssociationTable) pObject;
125:
126: lAssociationTable.setName(mNameField.getText());
127: lAssociationTable.setTableAlias(mTableAliasField.getText());
128: lAssociationTable
129: .setFirstRoleColumnNameOverride(mFirstRoleColumnNameOverrideField
130: .getText());
131: lAssociationTable
132: .setFirstRoleReferentialConstraintNameOverride(mFirstRoleReferentialConstraintNameOverrideField
133: .getText());
134: lAssociationTable.setNameOverride(mNameOverrideField
135: .getText());
136: lAssociationTable
137: .setPrimaryKeyConstraintNameOverride(mPrimaryKeyConstraintNameOverrideField
138: .getText());
139: lAssociationTable
140: .setSecondRoleColumnNameOverride(mSecondRoleColumnNameOverrideField
141: .getText());
142: lAssociationTable
143: .setSecondRoleReferentialConstraintNameOverride(mSecondRoleReferentialConstraintNameOverrideField
144: .getText());
145: lAssociationTable.setDescription(mDescriptionField
146: .getText());
147:
148: AssociationItem lItem = (AssociationItem) mAssociationField
149: .getSelectedItem();
150: if (lItem != null)
151: lAssociationTable.setAssociation(lItem.mAssociation);
152: else
153: lAssociationTable.setAssociation(null);
154: }
155: }
156:
157: protected ModelElement getNameElement() {
158: Association lResult = null;
159: try {
160: lResult = ((AssociationItem) mAssociationField
161: .getSelectedItem()).mAssociation;
162: } catch (Exception e) {
163: lResult = null;
164: }
165: return lResult;
166: }
167: }
|