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