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.AssociationRoleItem;
025: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTableReferenceColumn;
027:
028: /* RelationalEntityTableReferenceColumn properties dialog */
029:
030: public class RelationalEntityTableReferenceColumnPropertiesDialog
031: extends ModelElementPropertiesDialog {
032: private JPanel mOverridePanel = new JPanel();
033: //properties
034: private JComboBox mAssociationRoleField = new JComboBox();
035: private JTextArea mDescriptionField = new JTextArea(8, 40);
036: //override
037: private JTextField mColumnNameOverrideField = new JTextField();
038: private JTextField mReferentialConstraintNameOverrideField = new JTextField();
039:
040: public RelationalEntityTableReferenceColumnPropertiesDialog() {
041: super ("Relational Entity Table Reference Column",
042: new Dimension(400, 280));
043:
044: mOverridePanel.setLayout(mClientGridBagLayout);
045:
046: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
047: addComboBox(mPropertiesPanel, "Association Role: ",
048: mAssociationRoleField, 2, true);
049: addTextArea(mPropertiesPanel, "Description: ",
050: mDescriptionField, 3, false);
051:
052: addTextField(mOverridePanel, "Column Name: ",
053: mColumnNameOverrideField, 1, false);
054: addTextField(mOverridePanel, "Referential Constraint Name: ",
055: mReferentialConstraintNameOverrideField, 2, false);
056:
057: mTabControl
058: .insertTab("Override", null, mOverridePanel, null, 1);
059: mAssociationRoleField
060: .addItemListener(new NameElementChangeListener());
061: }
062:
063: // load entity table properties
064: public void loadProperties(ModelElement pObject) throws Exception {
065: if (pObject != null
066: && pObject instanceof RelationalEntityTableReferenceColumn) {
067: RelationalEntityTableReferenceColumn lColumn = (RelationalEntityTableReferenceColumn) pObject;
068:
069: AssociationRoleItem.loadBoxWithAssociationRoles(
070: mAssociationRoleField, lColumn.getTable()
071: .getEntity(), false);
072:
073: mNameField.setText(lColumn.getName());
074: mAssociationRoleField.setSelectedIndex(AssociationRoleItem
075: .findAssociationRoleItemIndex(
076: mAssociationRoleField, lColumn
077: .getAssociationRole()));
078: mColumnNameOverrideField.setText(lColumn
079: .getColumnNameOverride());
080: mReferentialConstraintNameOverrideField.setText(lColumn
081: .getReferentialConstraintNameOverride());
082: mDescriptionField.setText(lColumn.getDescription());
083: }
084: super .loadProperties(pObject);
085: }
086:
087: // save entity table proeprties
088: public void saveProperties(ModelElement pObject) throws Exception {
089: super .saveProperties(pObject);
090: if (pObject != null
091: && pObject instanceof RelationalEntityTableReferenceColumn) {
092: RelationalEntityTableReferenceColumn lColumn = (RelationalEntityTableReferenceColumn) pObject;
093:
094: lColumn.setName(mNameField.getText());
095: lColumn.setColumnNameOverride(mColumnNameOverrideField
096: .getText());
097: lColumn
098: .setReferentialConstraintNameOverride(mReferentialConstraintNameOverrideField
099: .getText());
100: lColumn.setDescription(mDescriptionField.getText());
101:
102: AssociationRoleItem lItem = (AssociationRoleItem) mAssociationRoleField
103: .getSelectedItem();
104: if (lItem != null)
105: lColumn.setAssociationRole(lItem.mRole);
106: else
107: lColumn.setAssociationRole(null);
108: }
109: }
110:
111: protected ModelElement getNameElement() {
112: ModelElement lResult = null;
113: try {
114: lResult = ((AssociationRoleItem) mAssociationRoleField
115: .getSelectedItem()).mRole;
116: } catch (Exception e) {
117: lResult = null;
118: }
119: return lResult;
120: }
121: }
|