1 | @Override | | 1 | @Override |
2 | protected void updateListeners(Object oldOwner, Object newOwner) { | | 2 | protected void updateListeners(Object oldOwner, Object newOwner) { |
3 | Set<Object[]> l = new HashSet<Object[]>(); | | 3 | Set<Object[]> lst = new HashSet<Object[]>(); |
4 | | | 4 | if (newOwner != null) { |
5 | if (newOwner != null) { | | 5 | // add the listeners to the newOwner |
6 | /* Don't listen to all property names | | 6 | lst.add(new Object[] {newOwner, null}); |
7 | * We only need to listen to its "type", and "remove". */ | | 7 | // and its stereotypes |
8 | l.add(new Object[] {newOwner, new String[] {"type", "remove"}}); | | 8 | for (Object stereo : Model.getFacade().getStereotypes(newOwner)) { |
9 | // register for events from the type | | 9 | lst.add(new Object[] {stereo, null}); |
10 | Object type = Model.getFacade().getType(newOwner); | | 10 | } |
11 | if (Model.getFacade().isAClassifier(type)) { | | 11 | // and its features |
12 | if (Model.getFacade().isAClassifierInState(type)) { | | 12 | for (Object feat : Model.getFacade().getFeatures(newOwner)) { |
13 | Object classifier = Model.getFacade().getType(type); | | 13 | lst.add(new Object[] {feat, null}); |
14 | l.add(new Object[] {classifier, "name"}); | | 14 | // and the stereotypes of its features |
15 | l.add(new Object[] {type, "inState"}); | | 15 | for (Object stereo : Model.getFacade().getStereotypes(feat)) { |
16 | Collection states = Model.getFacade().getInStates(type); | | 16 | lst.add(new Object[] {stereo, null}); |
17 | Iterator i = states.iterator(); | | 17 | } |
18 | while (i.hasNext()) { | | 18 | } |
19 | l.add(new Object[] {i.next(), "name"}); | | 19 | // and its enumerationLiterals |
20 | } | | 20 | for (Object literal : Model.getFacade().getEnumerationLiterals( |
21 | } else { | | 21 | newOwner)) { |
22 | l.add(new Object[] {type, "name"}); | | 22 | lst.add(new Object[] {literal, null}); |
23 | } | | 23 | } |
24 | } | | 24 | } |
25 | } | | 25 | // And now add listeners to them all: |
26 | | | 26 | updateElementListeners(lst); |
27 | updateElementListeners(l); | | 27 | |
28 | } | | 28 | } |