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.userobjects;
16:
17: import javax.swing.JComboBox;
18:
19: import com.metaboss.applications.designstudio.Application;
20: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
21: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
22:
23: /* AssociationRole combobox item class */
24:
25: public class AssociationRoleItem {
26: // load Association Roles combobox
27: public static void loadBoxWithAssociationRoles(JComboBox pBox,
28: Entity pEntity, boolean pAddNull) {
29: pBox.removeAllItems();
30:
31: if (pAddNull)
32: pBox.addItem(new AssociationRoleItem(null));
33:
34: if (pEntity != null) {
35: try {
36: Object[] pList = pEntity.getCombinedReferences()
37: .toArray();
38: for (int i = 0; i < pList.length; i++)
39: pBox.addItem(new AssociationRoleItem(
40: (AssociationRole) pList[i]));
41: } catch (Exception e) {
42: e.printStackTrace();
43: }
44: }
45: }
46:
47: // find entity index
48: public static int findAssociationRoleItemIndex(JComboBox pBox,
49: AssociationRole lRole) throws Exception {
50: for (int i = 0; i < pBox.getItemCount(); i++) {
51: AssociationRoleItem lItem = (AssociationRoleItem) pBox
52: .getItemAt(i);
53: if (lRole == null && lItem.mRole == null)
54: return i;
55: else if (lRole != null && lItem.mRole != null
56: && lItem.toString().equals(lRole.getName()))
57: return i;
58: }
59: return -1;
60: }
61:
62: public AssociationRole mRole = null;
63:
64: public AssociationRoleItem(AssociationRole pRole) {
65: mRole = pRole;
66: }
67:
68: public String toString() {
69: String lRedult = "";
70: try {
71: if (mRole != null)
72: lRedult = mRole.getName();
73: else
74: lRedult = Application.getString("unspecified");
75: } catch (Exception e) {
76: e.printStackTrace();
77: }
78: return lRedult;
79: }
80: }
|