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.AttributeItem;
025: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTableAttributeColumn;
027:
028: /* RelationalEntityTableAttributeColumn properties dialog */
029:
030: public class RelationalEntityTableAttributeColumnPropertiesDialog
031: extends ModelElementPropertiesDialog {
032: private JPanel mOverridePanel = new JPanel();
033: //properties
034: private JComboBox mAttributeField = 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 RelationalEntityTableAttributeColumnPropertiesDialog() {
041: super ("Relational Entity Table Attribute Column",
042: new Dimension(400, 280));
043:
044: mOverridePanel.setLayout(mClientGridBagLayout);
045:
046: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
047: addComboBox(mPropertiesPanel, "Attribute: ", mAttributeField,
048: 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: mAttributeField
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 RelationalEntityTableAttributeColumn) {
067: RelationalEntityTableAttributeColumn lColumn = (RelationalEntityTableAttributeColumn) pObject;
068:
069: AttributeItem.loadBoxWithAttributes(mAttributeField,
070: lColumn.getTable().getEntity(), false);
071:
072: mNameField.setText(lColumn.getName());
073: mAttributeField.setSelectedIndex(AttributeItem
074: .findAttributeItemIndex(mAttributeField, lColumn
075: .getAttribute()));
076: mColumnNameOverrideField.setText(lColumn
077: .getColumnNameOverride());
078: mReferentialConstraintNameOverrideField.setText(lColumn
079: .getReferentialConstraintNameOverride());
080: mDescriptionField.setText(lColumn.getDescription());
081: }
082: super .loadProperties(pObject);
083: }
084:
085: // save entity table proeprties
086: public void saveProperties(ModelElement pObject) throws Exception {
087: super .saveProperties(pObject);
088: if (pObject != null
089: && pObject instanceof RelationalEntityTableAttributeColumn) {
090: RelationalEntityTableAttributeColumn lColumn = (RelationalEntityTableAttributeColumn) pObject;
091:
092: lColumn.setName(mNameField.getText());
093: lColumn.setColumnNameOverride(mColumnNameOverrideField
094: .getText());
095: lColumn
096: .setReferentialConstraintNameOverride(mReferentialConstraintNameOverrideField
097: .getText());
098: lColumn.setDescription(mDescriptionField.getText());
099:
100: AttributeItem lItem = (AttributeItem) mAttributeField
101: .getSelectedItem();
102: if (lItem != null)
103: lColumn.setAttribute(lItem.mAttribute);
104: else
105: lColumn.setAttribute(null);
106: }
107: }
108:
109: protected ModelElement getNameElement() {
110: ModelElement lResult = null;
111: try {
112: lResult = ((AttributeItem) mAttributeField
113: .getSelectedItem()).mAttribute;
114: } catch (Exception e) {
115: lResult = null;
116: }
117: return lResult;
118: }
119: }
|