protected void modelChanged() {
    super.modelChanged();
    MComponentInstance coi = (MComponentInstance) getOwner();
    if (coi == null) return;
    String nameStr = "";
    if (coi.getName() != null) {
      nameStr = coi.getName().trim();
    }

    // construct bases string (comma separated)
    String baseStr = "";
    Collection col = coi.getClassifiers();
    if (col != null && col.size() > 0) {
      Iterator it = col.iterator();
      baseStr = ((MClassifier) it.next()).getName();
      while (it.hasNext()) {
        baseStr += ", " + ((MClassifier) it.next()).getName();
      }
    }
    if (_readyToEdit) {
      if (nameStr == "" && baseStr == "") _name.setText("");
      else _name.setText(nameStr.trim() + " : " + baseStr);
    }
    Dimension nameMin = _name.getMinimumSize();
    Rectangle r = getBounds();
    setBounds(r.x, r.y, r.width, r.height);

    updateStereotypeText();
  }
Esempio n. 2
0
 public boolean predicate2(Object dm, Designer dsgr) {
   if (!(dm instanceof MClassifier)) return NO_PROBLEM;
   MClassifier cls = (MClassifier) dm;
   String myName = cls.getName();
   //@ if (myName.equals(Name.UNSPEC)) return NO_PROBLEM;
   String myNameString = myName;
   if (myNameString.length() == 0) return NO_PROBLEM;
   Collection pkgs = cls.getElementImports2();
   if (pkgs == null) return NO_PROBLEM;
   for (Iterator iter = pkgs.iterator(); iter.hasNext();) {
     MElementImport imp = (MElementImport)iter.next();
     MNamespace ns = imp.getPackage();
     Collection siblings = ns.getOwnedElements();
     if (siblings == null) return NO_PROBLEM;
     Iterator enum = siblings.iterator();
     while (enum.hasNext()) {
       MElementImport eo = (MElementImport) enum.next();
       MModelElement me = (MModelElement) eo.getModelElement();
       if (!(me instanceof MClassifier)) continue;
       if (me == cls) continue;
       String meName = me.getName();
       if (meName == null || meName.equals("")) continue;
       if (meName.equals(myNameString)) return PROBLEM_FOUND;
     }
   };
   return NO_PROBLEM;
 }
  public synchronized void createModelUUIDS(MNamespace model) {

    cat.info("NOTE: The temporary method 'createModelUUIDs' has been called.");

    Collection ownedElements = model.getOwnedElements();
    Iterator oeIterator = ownedElements.iterator();

    String uuid = model.getUUID();
    if (uuid == null) model.setUUID(getNewUUID());

    while (oeIterator.hasNext()) {
      MModelElement me = (MModelElement) oeIterator.next();
      if (me instanceof MModel
          ||
          // me instanceof MNamespace ||
          me instanceof MClassifier
          || me instanceof MFeature
          || me instanceof MStateVertex
          || me instanceof MStateMachine
          || me instanceof MTransition
          || me instanceof MCollaboration
          || me instanceof MMessage
          || me instanceof MAssociation
          || me instanceof MAssociationEnd
          || me instanceof MGeneralization
          || me instanceof MDependency
          || me instanceof MStereotype
          || me instanceof MUseCase) {
        uuid = me.getUUID();
        if (uuid == null) {
          me.setUUID(getNewUUID());
        }
      }
      // recursive handling of namespaces, needed for Collaborations
      if (me instanceof MNamespace) {
        cat.debug("Found another namespace: " + me);
        createModelUUIDS((MNamespace) me);
      }
    }
  }