/** * Returns the name of the type with its qualified name * * @param type a type * @return the name of the type with its qualified name */ public static String getTypeLabel(Type type, Namespace model) { String label = ""; // $NON-NLS-1$ List<Package> importedPackages = new ArrayList<Package>(model.getImportedPackages()); List<Package> visitedPackages = new ArrayList<Package>(); Package currentPackage = type.getNearestPackage(); boolean rootFound = false; while (currentPackage != null && !rootFound) { visitedPackages.add(currentPackage); if (importedPackages.contains(currentPackage) || currentPackage == model) { rootFound = true; } Element owner = currentPackage.getOwner(); while (owner != null && !(owner instanceof Package)) owner = owner.getOwner(); currentPackage = owner != null ? (Package) owner : null; } for (int i = visitedPackages.size() - 1; i >= 0; i--) { label += visitedPackages.get(i).getName() + "::"; // $NON-NLS-1$ } return label + type.getName(); }
protected List<Type> getChoiceOfValues(org.eclipse.uml2.uml.Package package_) { List<Type> choiceOfValues = new ArrayList<Type>(); Resource eResource = package_.eResource(); ResourceSet resourceSet = eResource == null ? null : eResource.getResourceSet(); if (resourceSet != null) { try { resourceSet.getResource(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI), true); } catch (Exception e) { // ignore } try { resourceSet.getResource(URI.createURI(UMLResource.JAVA_PRIMITIVE_TYPES_LIBRARY_URI), true); } catch (Exception e) { // ignore } try { resourceSet.getResource(URI.createURI(UMLResource.ECORE_PRIMITIVE_TYPES_LIBRARY_URI), true); } catch (Exception e) { // ignore } try { resourceSet.getResource(URI.createURI(UMLResource.XML_PRIMITIVE_TYPES_LIBRARY_URI), true); } catch (Exception e) { // ignore } } if (eResource != null) { EList<NamedElement> members = package_.getMembers(); TreeIterator<?> allContents = resourceSet == null ? eResource.getAllContents() : resourceSet.getAllContents(); while (allContents.hasNext()) { Object object = allContents.next(); if (object instanceof Type && !members.contains(object)) { Type type = (Type) object; if (type.getNearestPackage().makesVisible(type)) { choiceOfValues.add(type); } } } } Collections.<Type>sort(choiceOfValues, new TextComparator<Type>()); return choiceOfValues; }