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.JPanel;
020: import javax.swing.JTextArea;
021: import javax.swing.JTextField;
022:
023: import com.metaboss.applications.designstudio.datatypefield.DataTypeBox;
024: import com.metaboss.applications.designstudio.userobjects.DatatypeItem;
025: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalReferenceTable;
027:
028: /* RelationalReferenceTable properties dialog */
029:
030: public class RelationalReferenceTablePropertiesDialog extends
031: ModelElementPropertiesDialog {
032: private JPanel mOverridePanel = new JPanel();
033: //properties
034: private DataTypeBox mDataTypeField = new DataTypeBox("DataType");
035: private JTextField mTableAliasField = new JTextField();
036: private JTextArea mDescriptionField = new JTextArea(8, 40);
037: //override
038: private JTextField mDescriptionColumnNameOverrideField = new JTextField();
039: private JTextField mNameOverrideField = new JTextField();
040: private JTextField mPrimaryKeyConstraintNameOverrideField = new JTextField();
041: private JTextField mValueColumnNameOverrideField = new JTextField();
042: private JTextField mWeightColumnNameOverrideField = new JTextField();
043: private JTextField mWeightConstraintNameOverrideField = new JTextField();
044:
045: public RelationalReferenceTablePropertiesDialog() {
046: super ("Relational Reference Table", new Dimension(400, 310));
047:
048: mOverridePanel.setLayout(mClientGridBagLayout);
049:
050: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
051: addComplexFieldWithEdit(mPropertiesPanel, mDataTypeField, 2,
052: true);
053: addTextField(mPropertiesPanel, "Table Alias: ",
054: mTableAliasField, 3, false);
055: addTextArea(mPropertiesPanel, "Description: ",
056: mDescriptionField, 4, false);
057:
058: addTextField(mOverridePanel, "Description Column Name: ",
059: mDescriptionColumnNameOverrideField, 1, false);
060: addTextField(mOverridePanel, "Name: ", mNameOverrideField, 2,
061: false);
062: addTextField(mOverridePanel, "Primary Key Constraint Name: ",
063: mPrimaryKeyConstraintNameOverrideField, 3, false);
064: addTextField(mOverridePanel, "Value Column Name: ",
065: mValueColumnNameOverrideField, 4, false);
066: addTextField(mOverridePanel, "Weight Column Name: ",
067: mWeightColumnNameOverrideField, 5, false);
068: addTextField(mOverridePanel, "Weight Constraint Name: ",
069: mWeightConstraintNameOverrideField, 6, false);
070:
071: mTabControl
072: .insertTab("Override", null, mOverridePanel, null, 1);
073: mDataTypeField.addItemListener(new NameElementChangeListener());
074: }
075:
076: // load reference table properties
077: public void loadProperties(ModelElement pObject) throws Exception {
078: if (pObject != null
079: && pObject instanceof RelationalReferenceTable) {
080: RelationalReferenceTable lTable = (RelationalReferenceTable) pObject;
081:
082: mDataTypeField.setSystem(lTable.getDomainStorage()
083: .getDomain().getSystem());
084:
085: mNameField.setText(lTable.getName());
086: mDataTypeField.setSelectedDataType(lTable.getDataType());
087: mTableAliasField.setText(lTable.getTableAlias());
088: mDescriptionColumnNameOverrideField.setText(lTable
089: .getDescriptionColumnNameOverride());
090: mNameOverrideField.setText(lTable.getNameOverride());
091: mPrimaryKeyConstraintNameOverrideField.setText(lTable
092: .getPrimaryKeyConstraintNameOverride());
093: mValueColumnNameOverrideField.setText(lTable
094: .getValueColumnNameOverride());
095: mWeightColumnNameOverrideField.setText(lTable
096: .getWeightColumnNameOverride());
097: mWeightConstraintNameOverrideField.setText(lTable
098: .getWeightConstraintNameOverride());
099: mDescriptionField.setText(lTable.getDescription());
100: }
101: super .loadProperties(pObject);
102: }
103:
104: // save entity table proeprties
105: public void saveProperties(ModelElement pObject) throws Exception {
106: super .saveProperties(pObject);
107: if (pObject != null
108: && pObject instanceof RelationalReferenceTable) {
109: RelationalReferenceTable lTable = (RelationalReferenceTable) pObject;
110:
111: lTable.setName(mNameField.getText());
112: lTable.setTableAlias(mTableAliasField.getText());
113: lTable
114: .setDescriptionColumnNameOverride(mDescriptionColumnNameOverrideField
115: .getText());
116: lTable.setNameOverride(mNameOverrideField.getText());
117: lTable
118: .setPrimaryKeyConstraintNameOverride(mPrimaryKeyConstraintNameOverrideField
119: .getText());
120: lTable
121: .setValueColumnNameOverride(mValueColumnNameOverrideField
122: .getText());
123: lTable
124: .setWeightColumnNameOverride(mWeightColumnNameOverrideField
125: .getText());
126: lTable
127: .setWeightConstraintNameOverride(mWeightConstraintNameOverrideField
128: .getText());
129: lTable.setDescription(mDescriptionField.getText());
130: lTable.setDataType(mDataTypeField.getSelectedDataType());
131: }
132: }
133:
134: protected ModelElement getNameElement() {
135: ModelElement lResult = null;
136: try {
137: lResult = ((DatatypeItem) mDataTypeField.getSelectedItem()).mDataType;
138: } catch (Exception e) {
139: lResult = null;
140: }
141: return lResult;
142: }
143: }
|