1 | public void actionPerformed(ActionEvent e) { | | 1 | /** |
2 | super.actionPerformed(e); | | 2 | * Search the attribute named <code>attributeName</code> in the given |
3 | Object t = TargetManager.getInstance().getModelTarget(); | | 3 | * relation. If there exist more than one attribute the first one is |
4 | Object owner = null; | | 4 | * returned. |
5 | Object namespace = null; | | 5 | * |
6 | if (Model.getFacade().isAStereotype(t)) { | | 6 | * @param relation |
7 | owner = t; | | 7 | * The relation in which to search the attribute. |
8 | } else if (Model.getFacade().isAPackage(t)) { | | 8 | * @param attributeName |
9 | namespace = t; | | 9 | * The name of the attribute to search. |
10 | } else { | | 10 | * @return The attribute if found, <code>null</code> else. |
11 | namespace = Model.getFacade().getInnerContainingModel(t); | | 11 | */ |
12 | } | | 12 | public static Object getAttributeForName(Object relation, |
13 | Object newTagDefinition = null; | | 13 | String attributeName) { |
14 | if (Model.getFacade().getUmlVersion().charAt(0) == '1') { | | 14 | Object attribute = null; |
15 | newTagDefinition = Model.getExtensionMechanismsFactory() | | 15 | |
16 | .buildTagDefinition((String) null, owner, namespace); | | 16 | Collection attributes = Model.getFacade().getAttributes(relation); |
17 | } else { | | 17 | for (Iterator it = attributes.iterator(); it.hasNext();) { |
18 | Object type = null; | | 18 | Object attr = it.next(); |
19 | for (Object aType : Model.getExtensionMechanismsHelper() | | 19 | if (Model.getFacade().getName(attr).equals(attributeName)) { |
20 | .getCommonTaggedValueTypes()) { | | 20 | attribute = attr; |
21 | if ("String".equals(Model.getFacade().getName(aType))) { | | 21 | break; |
22 | type = aType; | | 22 | } |
23 | break; | | 23 | } |
24 | } | | 24 | |
25 | } | | 25 | return attribute; |
26 | newTagDefinition = Model.getCoreFactory().buildAttribute2(t, type); | | 26 | } |
27 | } | | | |
28 | TargetManager.getInstance().setTarget(newTagDefinition); | | | |
29 | super.actionPerformed(e); | | | |
30 | } | | | |