1 | public List getInEdges(Object port) { | | 1 | /** |
2 | List res = new ArrayList(); | | 2 | * To simplify implementation, we list all associations |
3 | if (Model.getFacade().isANode(port)) { | | 3 | * found with any of the Classifiers |
4 | Collection ends = Model.getFacade().getAssociationEnds(port); | | 4 | * represented by the linked Instances. <p> |
5 | if (ends == null) { | | 5 | * |
6 | return Collections.EMPTY_LIST; | | 6 | * TODO: Make a foolproof algorithm that only allows selecting associations |
7 | } | | 7 | * that create a correct model. Also take into account n-ary associations |
8 | for (Object end : ends) { | | 8 | * and associationclasses. This algo best goes in the model subsystem, e.g. |
9 | res.add(Model.getFacade().getAssociation(end)); | | 9 | * in a method getAllPossibleAssociationsForALink(). |
10 | } | | 10 | * |
11 | } | | 11 | * @see org.argouml.uml.ui.UMLComboBoxModel#buildModelList() |
12 | if (Model.getFacade().isANodeInstance(port)) { | | 12 | */ |
13 | Object noi = port; | | 13 | protected void buildModelList() { |
14 | Collection ends = Model.getFacade().getLinkEnds(noi); | | 14 | Collection linkEnds; |
15 | res.addAll(ends); | | 15 | Collection associations = new HashSet(); |
16 | } | | 16 | Object t = getTarget(); |
17 | if (Model.getFacade().isAComponent(port)) { | | 17 | if (Model.getFacade().isALink(t)) { |
18 | Collection ends = Model.getFacade().getAssociationEnds(port); | | 18 | linkEnds = Model.getFacade().getConnections(t); |
19 | if (ends == null) { | | 19 | Iterator ile = linkEnds.iterator(); |
20 | return Collections.EMPTY_LIST; | | 20 | while (ile.hasNext()) { |
21 | } | | 21 | Object instance = Model.getFacade().getInstance(ile.next()); |
22 | for (Object end : ends) { | | 22 | Collection c = Model.getFacade().getClassifiers(instance); |
23 | res.add(Model.getFacade().getAssociation(end)); | | 23 | Iterator ic = c.iterator(); |
24 | } | | 24 | while (ic.hasNext()) { |
25 | } | | 25 | Object classifier = ic.next(); |
26 | if (Model.getFacade().isAComponentInstance(port)) { | | 26 | Collection ae = |
27 | Object coi = port; | | 27 | Model.getFacade().getAssociationEnds(classifier); |
28 | Collection ends = Model.getFacade().getLinkEnds(coi); | | 28 | Iterator iae = ae.iterator(); |
29 | res.addAll(ends); | | 29 | while (iae.hasNext()) { |
30 | } | | 30 | Object associationEnd = iae.next(); |
31 | if (Model.getFacade().isAClass(port)) { | | 31 | Object association = |
32 | Collection ends = Model.getFacade().getAssociationEnds(port); | | 32 | Model.getFacade().getAssociation(associationEnd); |
33 | if (ends == null) { | | 33 | associations.add(association); |
34 | return Collections.EMPTY_LIST; | | 34 | } |
35 | } | | 35 | } |
36 | for (Object end : ends) { | | 36 | } |
37 | res.add(Model.getFacade().getAssociation(end)); | | 37 | } |
38 | } | | 38 | setElements(associations); |
39 | } | | 39 | } |
40 | if (Model.getFacade().isAInterface(port)) { | | | |
41 | Collection ends = Model.getFacade().getAssociationEnds(port); | | | |
42 | if (ends == null) { | | | |
43 | return Collections.EMPTY_LIST; | | | |
44 | } | | | |
45 | for (Object end : ends) { | | | |
46 | res.add(Model.getFacade().getAssociation(end)); | | | |
47 | } | | | |
48 | } | | | |
49 | if (Model.getFacade().isAObject(port)) { | | | |
50 | Object clo = port; | | | |
51 | Collection ends = Model.getFacade().getLinkEnds(clo); | | | |
52 | res.addAll(ends); | | | |
53 | } | | | |
54 | | | | |
55 | | | | |
56 | return res; | | | |
57 | } | | | |