1 | private Object buildImport(Object element, Object srcFile) { | | 1 | /** |
2 | // TODO: add <<javaImport>> stereotype to Java profile - thn | | 2 | * Search the attribute named <code>attributeName</code> in the given |
3 | Collection dependencies = Model.getCoreHelper().getDependencies( | | 3 | * relation. If there exist more than one attribute the first one is |
4 | element, srcFile); | | 4 | * returned. |
5 | for (Object dep : dependencies) { | | 5 | * |
6 | for (Object stereotype : Model.getFacade().getStereotypes(dep)) { | | 6 | * @param relation |
7 | if ("javaImport".equals( | | 7 | * The relation in which to search the attribute. |
8 | Model.getFacade().getName(stereotype))) { | | 8 | * @param attributeName |
9 | return dep; | | 9 | * The name of the attribute to search. |
10 | } | | 10 | * @return The attribute if found, <code>null</code> else. |
11 | } | | 11 | */ |
12 | } | | 12 | public static Object getAttributeForName(Object relation, |
13 | | | 13 | String attributeName) { |
14 | // Didn't find it. Let's create one. | | 14 | Object attribute = null; |
15 | Object pkgImport = Model.getCoreFactory().buildDependency(srcFile, | | 15 | |
16 | element); | | 16 | Collection attributes = Model.getFacade().getAttributes(relation); |
17 | if (Model.getFacade().getUmlVersion().charAt(0) == '1') { | | 17 | for (Iterator it = attributes.iterator(); it.hasNext();) { |
18 | // TODO: support for stereotypes in eUML | | 18 | Object attr = it.next(); |
19 | Model.getCoreHelper().addStereotype(pkgImport, | | 19 | if (Model.getFacade().getName(attr).equals(attributeName)) { |
20 | getUML1Stereotype("javaImport")); | | 20 | attribute = attr; |
21 | ProjectManager.getManager().updateRoots(); | | 21 | break; |
22 | } | | 22 | } |
23 | String newName = makeDependencyName(srcFile, element); | | 23 | } |
24 | Model.getCoreHelper().setName(pkgImport, newName); | | 24 | |
25 | newElements.add(pkgImport); | | 25 | return attribute; |
26 | return pkgImport; | | 26 | } |
27 | } | | | |