@SuppressWarnings("unchecked")
 public Collection getAllContents(Object element) {
   if (!(element instanceof Element)) {
     throw new IllegalArgumentException("The argument must be instance of Element"); // $NON-NLS-1$
   }
   Collection result = new HashSet();
   if (element instanceof Collaboration) {
     // TODO: implement
   }
   if (element instanceof Classifier) {
     result.addAll(((Classifier) element).allFeatures());
   }
   if (element instanceof Namespace) {
     result.addAll(((Namespace) element).getMembers());
   }
   if (element instanceof org.eclipse.uml2.uml.Package) {
     result.addAll(((org.eclipse.uml2.uml.Package) element).getPackagedElements());
     org.eclipse.uml2.uml.Package p = ((org.eclipse.uml2.uml.Package) element).getNestingPackage();
     while (p != null) {
       for (PackageableElement e : p.getPackagedElements()) {
         if (e.getVisibility() == VisibilityKind.PUBLIC_LITERAL) {
           result.add(e);
         }
       }
       p = p.getNestingPackage();
     }
   }
   return result;
 }
Beispiel #2
0
  protected String getViewName(Property property) {
    if (!(generator instanceof ProfileGenerator)) {
      return "";
    }

    org.eclipse.uml2.uml.Property attribute = ((ProfileGenerator) generator).getAttribute(property);

    Package nearestPackage = attribute.getType().getNearestPackage();
    Package rootPackage = nearestPackage;
    while (rootPackage.getNestingPackage() != null) {
      rootPackage = rootPackage.getNestingPackage();
    }

    // TODO : We're assuming the rootPackage has the same name as the context...
    // This layout generator is really only compatible with ProfileGenerator
    return rootPackage.getName() + ":Single " + attribute.getType().getName();
  }