1 | private Object buildImport(Object element, Object srcFile) { | | 1 | /** |
2 | // TODO: add <<javaImport>> stereotype to Java profile - thn | | 2 | * Helper method that gets a stereotype for the given model |
3 | Collection dependencies = Model.getCoreHelper().getDependencies( | | 3 | * element with the given name. |
4 | element, srcFile); | | 4 | * |
5 | for (Object dep : dependencies) { | | 5 | * TODO: this might be a performance bottleneck. If so, caching of |
6 | for (Object stereotype : Model.getFacade().getStereotypes(dep)) { | | 6 | * stereotypes for model elements by their stereotypes names could fix it. |
7 | if ("javaImport".equals( | | 7 | * |
8 | Model.getFacade().getName(stereotype))) { | | 8 | * @param modelElement The model element for which to look for the |
9 | return dep; | | 9 | * stereotype with the given name |
10 | } | | 10 | * @param stereotypeName The name of the stereotype. |
11 | } | | 11 | * @return the stereotype model element or null if not found. |
12 | } | | 12 | */ |
13 | | | 13 | private Object getStereotype(Object modelElement, String stereotypeName) { |
14 | // Didn't find it. Let's create one. | | 14 | Object stereotype = null; |
15 | Object pkgImport = Model.getCoreFactory().buildDependency(srcFile, | | 15 | Collection stereotypes = StereotypeUtility.getAvailableStereotypes( |
16 | element); | | 16 | modelElement); |
17 | if (Model.getFacade().getUmlVersion().charAt(0) == '1') { | | 17 | for (Iterator it = stereotypes.iterator(); it.hasNext();) { |
18 | // TODO: support for stereotypes in eUML | | 18 | Object candidateStereotype = it.next(); |
19 | Model.getCoreHelper().addStereotype(pkgImport, | | 19 | if (getFacade().getName(candidateStereotype).equals( |
20 | getUML1Stereotype("javaImport")); | | 20 | stereotypeName)) { |
21 | ProjectManager.getManager().updateRoots(); | | 21 | stereotype = candidateStereotype; |
22 | } | | 22 | break; |
23 | String newName = makeDependencyName(srcFile, element); | | 23 | } |
24 | Model.getCoreHelper().setName(pkgImport, newName); | | 24 | } |
25 | newElements.add(pkgImport); | | 25 | return stereotype; |
26 | return pkgImport; | | 26 | } |
27 | } | | | |