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.JTextArea;
021: import javax.swing.JTextField;
022:
023: import com.metaboss.applications.designstudio.userobjects.AggregationTypeItem;
024: import com.metaboss.applications.designstudio.userobjects.AssociationRoleCardinalityItem;
025: import com.metaboss.applications.designstudio.userobjects.EntityItem;
026: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AggregationType;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRoleCardinality;
030:
031: /* AssociationRole properties tuning dialog class */
032:
033: public class AssociationRolePropertiesDialog extends
034: ModelElementPropertiesDialog {
035: private JTextField mNameField = new JTextField();
036: private JTextField mPluralNameField = new JTextField();
037: private JComboBox mEntityField = new JComboBox();
038: private JComboBox mStereotypeField = new JComboBox();
039: private JComboBox mCardinalityField = new JComboBox();
040: private JTextArea mDescriptionField = new JTextArea(8, 40);
041:
042: public AssociationRolePropertiesDialog() {
043: super ("Association Role", new Dimension(400, 370));
044:
045: AggregationTypeItem
046: .loadBoxWithAggregationTypes(mStereotypeField);
047: AssociationRoleCardinalityItem
048: .loadBoxWithCardinalities(mCardinalityField);
049:
050: addTextField(mPropertiesPanel, "Name: ", mNameField, 1, true);
051: addTextField(mPropertiesPanel, "Plural Name: ",
052: mPluralNameField, 2, true);
053: addComboBox(mPropertiesPanel, "Entity: ", mEntityField, 3,
054: false);
055: addComboBox(mPropertiesPanel, "Aggregation Type: ",
056: mStereotypeField, 4, false);
057: addComboBox(mPropertiesPanel, "Cardinality: ",
058: mCardinalityField, 5, false);
059: addTextArea(mPropertiesPanel, "Description: ",
060: mDescriptionField, 6, false);
061:
062: mEntityField.setEnabled(false);
063: }
064:
065: // load AssociationRole properties
066: public void loadProperties(ModelElement pObject) throws Exception {
067: if (pObject != null && pObject instanceof AssociationRole) {
068: AssociationRole lRole = (AssociationRole) pObject;
069: if (lRole.getEntity() != null)
070: EntityItem.loadBoxWithEntities(mEntityField, lRole
071: .getEntity().getDomain(), true);
072:
073: mNameField.setText(lRole.getName());
074: mPluralNameField.setText(lRole.getPluralName());
075: mEntityField.setSelectedIndex(EntityItem
076: .findEntityItemIndex(mEntityField, lRole
077: .getEntity()));
078: mStereotypeField.setSelectedIndex(AggregationTypeItem
079: .findAggregationTypeItemIndex(mStereotypeField,
080: lRole.getAggregationType()));
081: mCardinalityField
082: .setSelectedIndex(AssociationRoleCardinalityItem
083: .findCardinalityItemIndex(
084: mCardinalityField, lRole
085: .getCardinality()));
086: mDescriptionField.setText(lRole.getDescription());
087: }
088: super .loadProperties(pObject);
089: }
090:
091: // save Properties
092: public void saveProperties(ModelElement pObject) throws Exception {
093: super .saveProperties(pObject);
094: if (pObject != null && pObject instanceof AssociationRole) {
095: AssociationRole lRole = (AssociationRole) pObject;
096:
097: lRole.setName(mNameField.getText());
098: lRole.setPluralName(mPluralNameField.getText());
099: lRole.setAggregationType((AggregationType) mStereotypeField
100: .getSelectedItem());
101: lRole
102: .setCardinality((AssociationRoleCardinality) mCardinalityField
103: .getSelectedItem());
104: lRole.setDescription(mDescriptionField.getText());
105: EntityItem lItem = (EntityItem) mEntityField
106: .getSelectedItem();
107: if (lItem != null)
108: lRole.setEntity(lItem.mEntity);
109: else
110: lRole.setEntity(null);
111: }
112: }
113: }
|