/*
   * @see org.argouml.uml.ui.UMLComboBoxModel2#buildModelList()
   */
  protected void buildModelList() {
    Set<Object> elements = new TreeSet<Object>(new PathComparator());

    Object model = ProjectManager.getManager().getCurrentProject().getRoot();
    Object target = getTarget();
    elements.addAll(Model.getCoreHelper().getAllPossibleNamespaces(target, model));

    /* These next lines for the case that the current namespace
     * is not a valid one... Which of course should not happen,
     * but it does - see the project attached to issue 3772.
     */
    /* TODO: Enhance the isValidNamespace function so
     * that this never happens.
     */
    if (target != null) {
      Object namespace = Model.getFacade().getNamespace(target);
      if (namespace != null && !elements.contains(namespace)) {
        elements.add(namespace);
        LOG.warn("The current namespace is not a valid one!");
      }
    }

    // Our comparator will throw an InvalidElementException if the old
    // list contains deleted elements (eg after a new project is loaded)
    // so remove all the old contents first
    removeAllElements();
    addAll(elements);
  }
Ejemplo n.º 2
0
  protected void removeFromDiagramImpl() {
    Object o = getOwner();
    if (o != null) {
      removeElementListener(o);
    }
    ArgoEventPump.removeListener(this);

    Iterator it = getPathItemFigs().iterator();
    while (it.hasNext()) {
      Fig fig = (Fig) it.next();
      fig.removeFromDiagram();
    }

    /* TODO: MVW: Why the next action?
     * Deleting a fig from 1 diagram should not influence others!
     * */
    // GEF does not take into account the multiple diagrams we have
    // therefore we loop through our diagrams and delete each and every
    // occurence on our own
    it = ProjectManager.getManager().getCurrentProject().getDiagrams().iterator();
    while (it.hasNext()) {
      ArgoDiagram diagram = (ArgoDiagram) it.next();
      diagram.damage();
    }

    /* TODO: MVW: Should we not call damage()
     * for diagrams AFTER the next step? */
    super.removeFromDiagram();
  }
 /** @see javax.swing.Action#isEnabled() */
 public boolean isEnabled() {
   Object target = TargetManager.getInstance().getTarget();
   ArgoDiagram dia = ProjectManager.getManager().getCurrentProject().getActiveDiagram();
   if (dia == null) return false;
   MutableGraphModel gm = (MutableGraphModel) dia.getGraphModel();
   return gm.canAddNode(target);
 }
  private Collection getApplicableTagDefinitions(Object t) {
    Set<List<String>> paths = new HashSet<List<String>>();
    Set<Object> availableTagDefs = new TreeSet<Object>(new PathComparator());
    Collection stereotypes = Model.getFacade().getStereotypes(t);
    Project project = ProjectManager.getManager().getCurrentProject();
    for (Object model : project.getModels()) {
      addAllUniqueModelElementsFrom(
          availableTagDefs,
          paths,
          Model.getModelManagementHelper()
              .getAllModelElementsOfKind(model, Model.getMetaTypes().getTagDefinition()));
    }
    addAllUniqueModelElementsFrom(
        availableTagDefs,
        paths,
        project.getProfileConfiguration().findByMetaType(Model.getMetaTypes().getTagDefinition()));

    List notValids = new ArrayList();
    for (Object tagDef : availableTagDefs) {
      Object owner = Model.getFacade().getOwner(tagDef);
      if (owner != null && !stereotypes.contains(owner)) {
        notValids.add(tagDef);
      }
    }
    int size = availableTagDefs.size();
    availableTagDefs.removeAll(notValids);
    int delta = size - availableTagDefs.size();
    return availableTagDefs;
  }
Ejemplo n.º 5
0
  private static void update_method_signature(
      Operation operation,
      String method_name,
      String method_return_type,
      String[] s_param_names,
      String[] s_return_types) {
    Project project = ProjectManager.getManager().getCurrentProject();
    List<Parameter> param_list = operation.getParameter();

    operation.setName(method_name);
    Object data_type = project.findType(method_return_type, false);
    if (data_type == null) {
      data_type = project.findType(method_return_type, true);
    }

    Parameter return_param = param_list.get(0);
    return_param.setType((Classifier) data_type);

    for (int i = 1; i < param_list.size(); i++) {
      Parameter param = param_list.get(i);
      param.setName(s_param_names[i - 1]);

      data_type = project.findType(s_return_types[i - 1], false);
      if (data_type == null) {
        data_type = project.findType(s_return_types[i - 1], true);
      }

      param.setType((Classifier) data_type);
    }
  }
  /*
   * @see java.awt.event.ActionListener#actionPerformed(
   *      java.awt.event.ActionEvent)
   */
  @Override
  public void actionPerformed(ActionEvent e) {

    // TODO: Get Project or other necessary context from source??
    // e.getSource();

    // TODO: Since there may be multiple top level elements in
    // a project, this should be using the default Namespace (currently
    // undefined) or something similar
    Project p = ProjectManager.getManager().getCurrentProject();
    Object ns = findNamespace();

    if (ns != null && isValidNamespace(ns)) {
      super.actionPerformed(e);
      DiagramSettings settings = p.getProjectSettings().getDefaultDiagramSettings();
      ArgoDiagram diagram = createDiagram(ns, settings);
      assert (diagram != null) : "No diagram was returned by the concrete class";

      p.addMember(diagram);
      // TODO: make the explorer listen to project member property
      // changes...  to eliminate coupling on gui.
      ExplorerEventAdaptor.getInstance().modelElementAdded(diagram.getNamespace());
      TargetManager.getInstance().setTarget(diagram);
    } else {
      LOG.error("No valid namespace found");
      throw new IllegalStateException("No valid namespace found");
    }
  }
Ejemplo n.º 7
0
 /** @see java.lang.Runnable#run() */
 public void run() {
   Designer dsgr = Designer.theDesigner();
   org.argouml.uml.cognitive.critics.Init.init();
   org.argouml.uml.cognitive.checklist.Init.init();
   Project p = ProjectManager.getManager().getCurrentProject();
   // set the icon for this poster
   dsgr.setClarifier(ResourceLoaderWrapper.lookupIconResource("PostItD0"));
   dsgr.setDesignerName(Configuration.getString(Argo.KEY_USER_FULLNAME));
   Configuration.addListener(Argo.KEY_USER_FULLNAME, dsgr); // MVW
   dsgr.spawnCritiquer(p);
   dsgr.setChildGenerator(new ChildGenUML());
   java.util.Enumeration models = (p.getUserDefinedModels()).elements();
   while (models.hasMoreElements()) {
     Object o = models.nextElement();
     Model.getPump().addModelEventListener(dsgr, o);
   }
   LOG.info("spawned critiquing thread");
   dsgr.getDecisionModel().startConsidering(UMLDecision.CLASS_SELECTION);
   dsgr.getDecisionModel().startConsidering(UMLDecision.BEHAVIOR);
   dsgr.getDecisionModel().startConsidering(UMLDecision.NAMING);
   dsgr.getDecisionModel().startConsidering(UMLDecision.STORAGE);
   dsgr.getDecisionModel().startConsidering(UMLDecision.INHERITANCE);
   dsgr.getDecisionModel().startConsidering(UMLDecision.CONTAINMENT);
   dsgr.getDecisionModel().startConsidering(UMLDecision.PLANNED_EXTENSIONS);
   dsgr.getDecisionModel().startConsidering(UMLDecision.STATE_MACHINES);
   dsgr.getDecisionModel().startConsidering(UMLDecision.PATTERNS);
   dsgr.getDecisionModel().startConsidering(UMLDecision.RELATIONSHIPS);
   dsgr.getDecisionModel().startConsidering(UMLDecision.INSTANCIATION);
   dsgr.getDecisionModel().startConsidering(UMLDecision.MODULARITY);
   dsgr.getDecisionModel().startConsidering(UMLDecision.EXPECTED_USAGE);
   dsgr.getDecisionModel().startConsidering(UMLDecision.METHODS);
   dsgr.getDecisionModel().startConsidering(UMLDecision.CODE_GEN);
   dsgr.getDecisionModel().startConsidering(UMLDecision.STEREOTYPES);
   Designer.setUserWorking(true);
 }
  // TODO: Move to different class?
  public static void jumpToDiagramShowing(List targets) {

    if (targets == null || targets.size() == 0) {
      return;
    }
    Object first = targets.get(0);
    if (first instanceof ArgoDiagram && targets.size() > 1) {
      setTarget(first);
      setTarget(targets.get(1));
      return;
    }
    if (first instanceof ArgoDiagram && targets.size() == 1) {
      setTarget(first);
      return;
    }

    // TODO: This should get the containing project from the list of
    // targets, not from some global
    Project project = ProjectManager.getManager().getCurrentProject();
    if (project == null) {
      return;
    }

    List<ArgoDiagram> diagrams = project.getDiagramList();
    Object target = TargetManager.getInstance().getTarget();
    if ((target instanceof ArgoDiagram)
        && ((ArgoDiagram) target).countContained(targets) == targets.size()) {
      setTarget(first);
      return;
    }

    ArgoDiagram bestDiagram = null;
    int bestNumContained = 0;
    for (ArgoDiagram d : diagrams) {
      int nc = d.countContained(targets);
      if (nc > bestNumContained) {
        bestNumContained = nc;
        bestDiagram = d;
      }
      if (nc == targets.size()) {
        break;
      }
    }
    if (bestDiagram != null) {
      if (!DiagramUtils.getActiveDiagram().equals(bestDiagram)) {
        setTarget(bestDiagram);
      }
      setTarget(first);
    }
    // making it possible to jump to the modelroots
    if (project.getRoots().contains(first)) {
      setTarget(first);
    }

    // and finally, adjust the scrollbars to show the Fig
    Object f = TargetManager.getInstance().getFigTarget();
    if (f instanceof Fig) {
      Globals.curEditor().scrollToShow((Fig) f);
    }
  }
 @Override
 public boolean isGenerateMementos() {
   // TODO: This shouldn't depend on the current project, but for now
   // just make sure it's defined and that we have an undo manager
   Project p = ProjectManager.getManager().getCurrentProject();
   return super.isGenerateMementos() && p != null && p.getUndoManager() != null;
 }
Ejemplo n.º 10
0
  /** The constructor. */
  public FigGeneralization() {
    // UML spec for Generalizations doesn't call for name or stereotype
    //        middleGroup.addFig(getNameFig());
    //        middleGroup.addFig(getStereotypeFig());
    //        middleGroup.calcBounds();
    //        addPathItem(middleGroup,
    //                new PathConvPercent2(this, middleGroup, 50, 25));
    endArrow = new ArrowHeadTriangle();

    discriminator.setFont(getLabelFont());
    discriminator.setTextColor(Color.black);
    discriminator.setTextFilled(false);
    discriminator.setFilled(false);
    discriminator.setLineWidth(0);
    discriminator.setExpandOnly(false);
    discriminator.setReturnAction(FigText.END_EDITING);
    discriminator.setTabAction(FigText.END_EDITING);
    addPathItem(discriminator, new PathConvPercent(this, 40, -10));
    endArrow.setFillColor(Color.white);
    setDestArrowHead(endArrow);
    setBetweenNearestPoints(true);

    if (getLayer() == null) {
      setLayer(ProjectManager.getManager().getCurrentProject().getActiveDiagram().getLayer());
    }
  }
  /**
   * Parse a string representing one or more ";" separated enumeration literals.
   *
   * @param enumeration the enumeration that the literal belongs to
   * @param literal the literal on which the editing will happen
   * @param text the string to parse
   * @throws ParseException for invalid input - so that the right message may be shown to the user
   */
  protected void parseEnumerationLiteralFig(Object enumeration, Object literal, String text)
      throws ParseException {

    if (enumeration == null || literal == null) {
      return;
    }
    Project project = ProjectManager.getManager().getCurrentProject();

    ParseException pex = null;
    int start = 0;
    int end = NotationUtilityUml.indexOfNextCheckedSemicolon(text, start);

    if (end == -1) {
      /* No text. We may remove the literal. */
      project.moveToTrash(literal);
      return;
    }
    String s = text.substring(start, end).trim();
    if (s.length() == 0) {
      /* No non-white chars in text? remove literal! */
      project.moveToTrash(literal);
      return;
    }
    parseEnumerationLiteral(s, literal);

    int i = Model.getFacade().getEnumerationLiterals(enumeration).indexOf(literal);
    // check for more literals (';' separated):
    start = end + 1;
    end = NotationUtilityUml.indexOfNextCheckedSemicolon(text, start);
    while (end > start && end <= text.length()) {
      s = text.substring(start, end).trim();
      if (s.length() > 0) {
        // yes, there are more:
        Object newLiteral = Model.getCoreFactory().createEnumerationLiteral();
        if (newLiteral != null) {
          try {
            if (i != -1) {
              Model.getCoreHelper().addLiteral(enumeration, ++i, newLiteral);
            } else {
              Model.getCoreHelper().addLiteral(enumeration, 0, newLiteral);
            }
            parseEnumerationLiteral(s, newLiteral);
          } catch (ParseException ex) {
            if (pex == null) {
              pex = ex;
            }
          }
        }
      }
      start = end + 1;
      end = NotationUtilityUml.indexOfNextCheckedSemicolon(text, start);
    }
    if (pex != null) {
      throw pex;
    }
  }
Ejemplo n.º 12
0
 protected List getChoices() {
   List ret = new ArrayList();
   Object model = ProjectManager.getManager().getCurrentProject().getModel();
   if (getTarget() != null) {
     ret.addAll(
         Model.getModelManagementHelper()
             .getAllModelElementsOfKind(model, Model.getMetaTypes().getReception()));
   }
   return ret;
 }
Ejemplo n.º 13
0
 /*
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public void actionPerformed(ActionEvent ae) {
   super.actionPerformed(ae);
   Project p = ProjectManager.getManager().getCurrentProject();
   int numPacks = p.getUserDefinedModelList().size();
   String nameStr = "package_" + (numPacks + 1);
   Object model = Model.getModelManagementFactory().createModel();
   Model.getCoreHelper().setName(model, nameStr);
   p.addMember(model);
   super.actionPerformed(ae);
   new ActionClassDiagram().actionPerformed(ae);
 }
 protected List getChoices() {
   List ret = new ArrayList();
   if (getTarget() != null) {
     Project p = ProjectManager.getManager().getCurrentProject();
     Object model = p.getRoot();
     ret.addAll(
         Model.getModelManagementHelper()
             .getAllModelElementsOfKindWithModel(model, Model.getMetaTypes().getClassifier()));
   }
   return ret;
 }
Ejemplo n.º 15
0
  /**
   * @param namespace the namespace in which to create the diagram
   * @return the new diagram
   * @deprecated for 0.29.1 by tfmorris. Use {@link #createDiagram(Object, DiagramSettings)}/
   */
  @SuppressWarnings("deprecation")
  @Deprecated
  protected ArgoDiagram createDiagram(Object namespace) {
    DiagramSettings settings =
        ProjectManager.getManager()
            .getCurrentProject()
            .getProjectSettings()
            .getDefaultDiagramSettings();

    return createDiagram(namespace, settings);
  }
Ejemplo n.º 16
0
 /** @see org.tigris.gef.presentation.Fig#deleteFromModel() */
 public void deleteFromModel() {
   Object own = getOwner();
   if (own != null) {
     ProjectManager.getManager().getCurrentProject().moveToTrash(own);
   }
   Iterator it = getPathItemFigs().iterator();
   while (it.hasNext()) {
     ((Fig) it.next()).deleteFromModel();
   }
   super.deleteFromModel();
 }
  /*
   * @see junit.framework.TestCase#setUp()
   */
  protected void setUp() {
    InitializeModel.initializeDefault();
    new InitProfileSubsystem().init();

    project = ProjectManager.getManager().makeEmptyProject();

    action = getAction();
    ns = getNamespace();
    validNamespaces = getValidNamespaceClasses();

    TargetManager.getInstance().setTarget(ns);
  }
  /*
   * @see org.argouml.uml.ui.UMLComboBoxModel2#buildModelList()
   */
  protected void buildModelList() {
    Set<Object> elements = new TreeSet<Object>(new PathComparator());
    Project p = ProjectManager.getManager().getCurrentProject();
    for (Object model : p.getUserDefinedModelList()) {
      elements.addAll(
          Model.getModelManagementHelper()
              .getAllModelElementsOfKind(model, Model.getMetaTypes().getClassifier()));
    }

    elements.addAll(
        p.getProfileConfiguration().findByMetaType(Model.getMetaTypes().getClassifier()));
    removeAllElements();
    addAll(elements);
  }
Ejemplo n.º 19
0
 /**
  * Creates the event, sets its role and namespace, and navigates towards it.
  *
  * <p>{@inheritDoc}
  */
 public void actionPerformed(ActionEvent e) {
   super.actionPerformed(e);
   Object target = getTarget();
   Object model = ProjectManager.getManager().getCurrentProject().getModel();
   Object ns = Model.getStateMachinesHelper().findNamespaceForEvent(target, model);
   Object event = createEvent(ns);
   if (getValue(ROLE).equals(Roles.TRIGGER)) {
     Model.getStateMachinesHelper().setEventAsTrigger(target, event);
   }
   if (getValue(ROLE).equals(Roles.DEFERRABLE_EVENT)) {
     Model.getStateMachinesHelper().addDeferrableEvent(target, event);
   }
   TargetManager.getInstance().setTarget(event);
 }
  /** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */
  public void actionPerformed(ActionEvent ae) {
    super.actionPerformed(ae);
    try {
      /*Here the actions to delete a region.
      We assume the only figs enclosed in a concurrent composite state
      are concurrent region figs*/
      Fig f = (Fig) TargetManager.getInstance().getFigTarget();
      Fig encloser = null;

      int height = 0;
      Rectangle encBound;
      Project p = ProjectManager.getManager().getCurrentProject();

      if (Model.getFacade().isAConcurrentRegion(f.getOwner())) encloser = f.getEnclosingFig();

      Vector nodesInside;
      nodesInside = ((Vector) encloser.getEnclosedFigs().clone());
      int index = nodesInside.indexOf(f);
      Rectangle r = f.getBounds();
      encBound = encloser.getBounds();
      if (Model.getFacade().isAConcurrentRegion(f.getOwner())) p.moveToTrash(f.getOwner());
      // It wasnt the last region
      if (index < nodesInside.size() - 1) {
        Rectangle rFig = ((Fig) nodesInside.elementAt(index + 1)).getBounds();
        height = rFig.y - r.y;
        for (int i = ++index; i < nodesInside.size(); i++)
          ((FigNodeModelElement) nodesInside.elementAt(i)).displace(0, -height);
      }
      // It was the last region
      else height = r.height + 4;

      /*When only one concurrent region remains it must be erased and the
      composite state sets non concurent*/
      if (((Vector) encloser.getEnclosedFigs()).size() == 1) {
        f = ((Fig) encloser.getEnclosedFigs().elementAt(0));
        nodesInside = ((Vector) f.getEnclosedFigs());
        Model.getStateMachinesHelper().setConcurrent(encloser.getOwner(), false);
        if (!nodesInside.isEmpty()) {
          for (int i = 0; i < nodesInside.size(); i++) {
            FigStateVertex curFig = (FigStateVertex) nodesInside.elementAt(i);
            curFig.setEnclosingFig(encloser);
          }
        }
        p.moveToTrash(f.getOwner());
      }

    } catch (Exception ex) {
      LOG.error(ex);
    }
  }
Ejemplo n.º 21
0
  /**
   * Add a new class diagram for a package to the project.
   *
   * @param ns The namespace to contain the diagram. If null, the root model will be used.
   * @param name The fully qualified name of the package, which is used to generate the diagram name
   *     from.
   */
  public void addClassDiagram(Object ns, String name) {
    Project p = ProjectManager.getManager().getCurrentProject();

    ArgoDiagram d =
        DiagramFactory.getInstance()
            .createDiagram(UMLClassDiagram.class, ns == null ? p.getRoot() : ns, null);

    try {
      d.setName(getDiagramName(name));
    } catch (PropertyVetoException pve) {
      LOG.error("Failed to set diagram name.", pve);
    }
    p.addMember(d);
    setCurrentDiagram(d);
  }
 /*
  * @see org.argouml.ui.explorer.rules.PerspectiveRule#getChildren(java.lang.Object)
  */
 public Collection getChildren(Object parent) {
   if (Model.getFacade().isAOperation(parent)) {
     Object operation = parent;
     Collection col = Model.getFacade().getCollaborations(operation);
     Set<ArgoDiagram> ret = new HashSet<ArgoDiagram>();
     Project p = ProjectManager.getManager().getCurrentProject();
     for (ArgoDiagram diagram : p.getDiagramList()) {
       if (diagram instanceof UMLCollaborationDiagram
           && col.contains(((UMLCollaborationDiagram) diagram).getNamespace())) {
         ret.add(diagram);
       }
     }
     return ret;
   }
   return Collections.EMPTY_SET;
 }
Ejemplo n.º 23
0
  /*
   * @see tudresden.ocl.check.types.ModelFacade#getClassifier(java.lang.String)
   */
  public Any getClassifier(String name) {
    Project p = ProjectManager.getManager().getCurrentProject();

    if (target != null && Model.getFacade().getName(target).equals(name)) {
      return new ArgoAny(target);
    }
    Object classifier = p.findTypeInModel(name, p.getModel());
    if (classifier == null) {
      /** Added search in defined types 2001-10-18 STEFFEN ZSCHALER. */
      classifier = p.findType(name, false);
      if (classifier == null) {
        throw new OclTypeException("cannot find classifier: " + name);
      }
    }
    return new ArgoAny(classifier);
  }
  private ProjectActions() {
    super();

    undoAction =
        new ActionUndo(
            Translator.localize("action.undo"), ResourceLoaderWrapper.lookupIcon("Undo"));
    undoAction.setEnabled(false);

    redoAction =
        new ActionRedo(
            Translator.localize("action.redo"), ResourceLoaderWrapper.lookupIcon("Redo"));
    redoAction.setEnabled(false);

    TargetManager.getInstance().addTargetListener(this);
    Project p = ProjectManager.getManager().getCurrentProject();
    if (p != null) {
      p.getUndoManager().addPropertyChangeListener(this);
    }
  }
Ejemplo n.º 25
0
  /**
   * Select a class diagram as the current diagram, creating it if necessary.
   *
   * @param p The package.
   * @param name The fully qualified name of this package.
   */
  public void selectClassDiagram(Object p, String name) {

    // Check if this diagram already exists in the project
    ProjectMember m;
    if (isDiagramInProject(name)) {
      Project project = ProjectManager.getManager().getCurrentProject();
      m = findDiagramMemberByUniqueName(project, getDiagramName(name));

      // The diagram already exists in this project. Select it
      // as the current target.
      if (m instanceof ProjectMemberDiagram) {
        setCurrentDiagram(((ProjectMemberDiagram) m).getDiagram());
      }

    } else {
      // Otherwise create a new classdiagram for the package.
      addClassDiagram(p, name);
    }
  }
 /*
  * @see junit.framework.TestCase#setUp()
  */
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   InitializeModel.initializeDefault();
   new InitProfileSubsystem().init();
   Project p = ProjectManager.getManager().getCurrentProject();
   elem = Model.getCommonBehaviorFactory().createReception();
   signals = new Object[NO_OF_ELEMENTS];
   Object m = Model.getModelManagementFactory().createModel();
   Collection roots = new ArrayList();
   roots.add(m);
   p.setRoots(roots);
   Model.getCoreHelper().setNamespace(elem, m);
   for (int i = 0; i < NO_OF_ELEMENTS; i++) {
     signals[i] = Model.getCommonBehaviorFactory().createSignal();
     Model.getCoreHelper().addOwnedElement(m, signals[i]);
   }
   model = new UMLReceptionSignalComboBoxModel();
   model.targetSet(new TargetEvent(this, "set", new Object[0], new Object[] {elem}));
   ThreadHelper.synchronize();
 }
 /** @see junit.framework.TestCase#setUp() */
 protected void setUp() throws Exception {
   super.setUp();
   Object mmodel = Model.getModelManagementFactory().createModel();
   Model.getCoreHelper().setName(mmodel, "untitledModel");
   Model.getModelManagementFactory().setRootModel(mmodel);
   namespace = Model.getModelManagementFactory().createPackage();
   child = Model.getCoreFactory().buildClass("child", namespace);
   parent = Model.getCoreFactory().buildClass("parent", namespace);
   elem = Model.getCoreFactory().buildGeneralization(child, parent);
   model = new UMLGeneralizationPowertypeComboBoxModel();
   model.targetSet(new TargetEvent(this, "set", new Object[0], new Object[] {elem}));
   types = new Object[10];
   Object m = Model.getModelManagementFactory().createModel();
   ProjectManager.getManager().getCurrentProject().setRoot(m);
   Model.getCoreHelper().setNamespace(elem, m);
   for (int i = 0; i < 10; i++) {
     types[i] = Model.getCoreFactory().createClass();
     Model.getCoreHelper().addOwnedElement(m, types[i]);
   }
   Model.getPump().flushModelEvents();
 }
Ejemplo n.º 28
0
  /*
   * the model structure has changed significantly, eg a new project.
   * @see org.argouml.ui.explorer.TreeModelUMLEventListener#structureChanged()
   */
  public void structureChanged() {
    // remove references for gc
    if (getRoot() instanceof ExplorerTreeNode) {
      ((ExplorerTreeNode) getRoot()).remove();
    }

    // This should only be helpful for old garbage collectors.
    for (Collection nodes : modelElementMap.values()) {
      nodes.clear();
    }
    modelElementMap.clear();

    // This is somewhat inconsistent with the design of the constructor
    // that receives the root object by argument. If this is okay
    // then there may be no need for a constructor with that argument.
    modelElementMap = new HashMap<Object, Set<ExplorerTreeNode>>();
    Project proj = ProjectManager.getManager().getCurrentProject();
    ExplorerTreeNode rootNode = new ExplorerTreeNode(proj, this);

    addToMap(proj, rootNode);
    setRoot(rootNode);
  }
Ejemplo n.º 29
0
  public void testListener() {
    Object model = Model.getModelManagementFactory().createModel();
    Project p = ProjectManager.getManager().getCurrentProject();
    p.addModel(model);
    aClass = Model.getCoreFactory().buildClass(model);

    NotationProvider np = new NPImpl();
    np.initialiseListener(this, aClass);

    propChanged = false;
    Model.getCoreHelper().setName(aClass, "ClassA1");
    Model.getPump().flushModelEvents();
    assertTrue("No event received", propChanged);

    np.cleanListener(this, aClass);
    propChanged = false;
    Model.getCoreHelper().setName(aClass, "ClassA2");
    Model.getPump().flushModelEvents();
    assertTrue("Event received, despite not listening", !propChanged);

    np.updateListener(this, aClass, null);
  }
  /**
   * @param memento the GEF memento
   * @see org.tigris.gef.undo.UndoManager#addMemento(org.tigris.gef.undo.Memento)
   */
  @Override
  public void addMemento(final Memento memento) {
    // TODO: This shouldn't be referencing the current project.  Instead
    // the appropriate UndoManager should have already been retrieved from
    // the correct project.
    Project p = ProjectManager.getManager().getCurrentProject();
    if (p != null) {
      org.argouml.kernel.UndoManager undo = p.getUndoManager();
      if (undo != null) {
        if (startChain) {
          // TODO i18n: GEF needs to pass us back the description
          // of what is being done.
          undo.startInteraction("Diagram Interaction");
        }
        // TODO: I presume this would fix issue 5250 - but
        // GEF would need to be adapted:
        //                if (!(memento instanceof SelectionMemento))
        undo.addCommand(new DiagramCommand(memento));

        startChain = false;
      }
    }
  }