01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.applications.designstudio.propertiesdialogs;
16:
17: import java.awt.Dimension;
18:
19: import javax.swing.JComboBox;
20:
21: import com.metaboss.applications.designstudio.BasePropertiesDialog;
22: import com.metaboss.applications.designstudio.userobjects.AssociationRoleItem;
23: import com.metaboss.applications.designstudio.userobjects.AttributeItem;
24: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
25: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.PrimaryKeyElement;
26:
27: /* Primary Key Element properties tuning Dialog class */
28:
29: public class PrimaryKeyPropertiesDialog extends BasePropertiesDialog {
30: private JComboBox mTypeField = new JComboBox();
31: private JComboBox mAssociationField = new JComboBox();
32: private JComboBox mAttributeField = new JComboBox();
33:
34: public PrimaryKeyPropertiesDialog() {
35: super ("Primary Key Element", true, new Dimension(400, 200));
36:
37: addComboBox("Association Role: ", mAssociationField, 1, false);
38: addComboBox("Attribute: ", mAttributeField, 2, false);
39: }
40:
41: // load entity properties
42: public void loadProperties(Entity pEntity) throws Exception {
43: loadComboBoxes(pEntity);
44: }
45:
46: // get primary key element
47: public PrimaryKeyElement getPrimaryKeyElement() {
48: Object lItem = mAssociationField.getSelectedItem();
49: if (lItem != null && lItem instanceof AssociationRoleItem
50: && ((AssociationRoleItem) lItem).mRole != null)
51: return ((AssociationRoleItem) lItem).mRole;
52:
53: lItem = mAttributeField.getSelectedItem();
54: if (lItem != null && lItem instanceof AttributeItem
55: && ((AttributeItem) lItem).mAttribute != null)
56: return ((AttributeItem) lItem).mAttribute;
57:
58: return null;
59: }
60:
61: private void loadComboBoxes(Entity pEntity) {
62: AssociationRoleItem.loadBoxWithAssociationRoles(
63: mAssociationField, pEntity, true);
64: AttributeItem.loadBoxWithAttributes(mAttributeField, pEntity,
65: true);
66: }
67: }
|