コード例 #1
0
  // 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);
    }
  }
コード例 #2
0
ファイル: FigClass.java プロジェクト: carvalhomb/tsmells
  /**
   * Build a collection of menu items relevant for a right-click popup menu on a Class.
   *
   * @param me a mouse event
   * @return a collection of menu items
   * @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(java.awt.event.MouseEvent)
   */
  public Vector getPopUpActions(MouseEvent me) {
    Vector popUpActions = super.getPopUpActions(me);

    // Add...
    ArgoJMenu addMenu = new ArgoJMenu("menu.popup.add");
    addMenu.add(TargetManager.getInstance().getAddAttributeAction());
    addMenu.add(TargetManager.getInstance().getAddOperationAction());
    addMenu.add(new ActionAddNote());
    addMenu.add(ActionEdgesDisplay.getShowEdges());
    addMenu.add(ActionEdgesDisplay.getHideEdges());
    popUpActions.insertElementAt(addMenu, popUpActions.size() - getPopupAddOffset());

    // Show ...
    ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show");
    Iterator i = ActionCompartmentDisplay.getActions().iterator();
    while (i.hasNext()) {
      showMenu.add((Action) i.next());
    }
    popUpActions.insertElementAt(showMenu, popUpActions.size() - getPopupAddOffset());

    // Modifiers ...
    popUpActions.insertElementAt(
        buildModifierPopUp(ABSTRACT | LEAF | ROOT | ACTIVE),
        popUpActions.size() - getPopupAddOffset());

    // Visibility ...
    popUpActions.insertElementAt(buildVisibilityPopUp(), popUpActions.size() - getPopupAddOffset());

    return popUpActions;
  }
コード例 #3
0
 /** @see javax.swing.Action#isEnabled() */
 public boolean isEnabled() {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getStateMachinesHelper().isTopState(target)) return false;
   if (Model.getFacade().isAConcurrentRegion(target)) {
     return TargetManager.getInstance().getModelTargets().size() < 2;
   }
   return false;
 }
コード例 #4
0
ファイル: PropPanelDiagram.java プロジェクト: ckaestne/LEADT
 /*
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 @Override
 public void actionPerformed(ActionEvent e) {
   Object target = TargetManager.getInstance().getTarget();
   Object destination = navigateTo(target);
   if (destination != null) {
     TargetManager.getInstance().setTarget(destination);
   }
 }
コード例 #5
0
  /** The constructor. */
  public TargetManagerPanel() {
    setLayout(new BorderLayout());

    lst = new JList(lm);
    setTarget(TargetManager.getInstance().getTargets());
    add(new JScrollPane(lst), BorderLayout.CENTER);
    lst.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    TargetManager.getInstance().addTargetListener(this);
    add(new JButton(new ClearAction("Clear")), BorderLayout.SOUTH);
  }
コード例 #6
0
 /*
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public void actionPerformed(ActionEvent e) {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getFacade().isAExtensionPoint(target)) {
     TargetManager.getInstance()
         .setTarget(
             Model.getUseCasesFactory()
                 .buildExtensionPoint(Model.getFacade().getUseCase(target)));
     super.actionPerformed(e);
   }
 }
コード例 #7
0
 /*
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public void actionPerformed(ActionEvent e) {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getFacade().isAEnumerationLiteral(target)) {
     target = Model.getFacade().getEnumeration(target);
   }
   if (Model.getFacade().isAClassifier(target)) {
     Object el = Model.getCoreFactory().buildEnumerationLiteral("", target);
     TargetManager.getInstance().setTarget(el);
     super.actionPerformed(e);
   }
 }
コード例 #8
0
 /*
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public void actionPerformed(ActionEvent e) {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getFacade().isAClassifier(target)) {
     Object classifier = target;
     Object ns = Model.getFacade().getNamespace(classifier);
     if (ns != null) {
       Object peer = Model.getCoreFactory().buildClass(ns);
       TargetManager.getInstance().setTarget(peer);
       super.actionPerformed(e);
     }
   }
 }
コード例 #9
0
 public void actionPerformed(ActionEvent e) {
   if (!isEnabled()) {
     return;
   }
   super.actionPerformed(e);
   Object target = TargetManager.getInstance().getModelTarget();
   Object model = Model.getFacade().getInnerContainingModel(target);
   Object ns = Model.getStateMachinesHelper().findNamespaceForEvent(target, model);
   Object event = createEvent(ns);
   Model.getStateMachinesHelper().setEventAsTrigger(target, event);
   TargetManager.getInstance().setTarget(event);
 }
コード例 #10
0
ファイル: PropPanelExtend.java プロジェクト: Jewest/argouml
 /*
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 @Override
 public void actionPerformed(ActionEvent e) {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getFacade().isAExtend(target)
       && Model.getFacade().getNamespace(target) != null
       && Model.getFacade().getBase(target) != null) {
     Object extensionPoint =
         Model.getUseCasesFactory().buildExtensionPoint(Model.getFacade().getBase(target));
     Model.getUseCasesHelper().addExtensionPoint(target, extensionPoint);
     TargetManager.getInstance().setTarget(extensionPoint);
     super.actionPerformed(e);
   }
 }
コード例 #11
0
 /** @see org.argouml.uml.ui.UMLComboBoxModel2#isValidElement(java.lang.Object) */
 protected boolean isValidElement(Object element) {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getFacade().isACallEvent(target)) {
     return element == Model.getFacade().getOperation(target);
   }
   return false;
 }
コード例 #12
0
 /** @see org.argouml.uml.ui.UMLComboBoxModel2#getSelectedModelElement() */
 protected Object getSelectedModelElement() {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getFacade().isACallEvent(target)) {
     return Model.getFacade().getOperation(target);
   }
   return null;
 }
コード例 #13
0
  /*
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent ae) {
    super.actionPerformed(ae);
    Object target = TargetManager.getInstance().getModelTarget();

    Object enumeration;
    if (Model.getFacade().isAEnumeration(target)) {
      enumeration = target;
    } else if (Model.getFacade().isAEnumerationLiteral(target)) {
      enumeration = Model.getFacade().getEnumeration(target);
    } else {
      return;
    }

    Object oper = Model.getCoreFactory().buildEnumerationLiteral("anon", enumeration);
    TargetManager.getInstance().setTarget(oper);
  }
コード例 #14
0
 /** @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);
 }
コード例 #15
0
  /*
   * @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");
    }
  }
コード例 #16
0
ファイル: ActionNewDiagram.java プロジェクト: brunodiniz/KSE
 /**
  * Utility function to create a collaboration.
  *
  * @return a new collaboration
  * @param namespace the back-up namespace to put the collaboration in
  */
 protected static Object createCollaboration(Object namespace) {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getFacade().isAUMLElement(target)
       && Model.getModelManagementHelper().isReadOnly(target)) {
     target = namespace;
   }
   Object collaboration = null;
   if (Model.getFacade().isAOperation(target)) {
     Object ns = Model.getFacade().getNamespace(Model.getFacade().getOwner(target));
     collaboration = Model.getCollaborationsFactory().buildCollaboration(ns, target);
   } else if (Model.getFacade().isAClassifier(target)) {
     Object ns = Model.getFacade().getNamespace(target);
     collaboration = Model.getCollaborationsFactory().buildCollaboration(ns, target);
   } else {
     collaboration = Model.getCollaborationsFactory().createCollaboration();
     if (Model.getFacade().isANamespace(target)) {
       /* TODO: Not all namespaces are useful here - any WFRs? */
       namespace = target;
     } else {
       if (Model.getFacade().isAModelElement(target)) {
         Object ns = Model.getFacade().getNamespace(target);
         if (Model.getFacade().isANamespace(ns)) {
           namespace = ns;
         }
       }
     }
     Model.getCoreHelper().setNamespace(collaboration, namespace);
     Model.getCoreHelper().setName(collaboration, "unattachedCollaboration");
   }
   return collaboration;
 }
コード例 #17
0
ファイル: TestProject.java プロジェクト: ckaestne/LEADT
  /** Test the moveToTrash function for package and content. */
  public void testTrashcanPackageContent() {
    Project p = ProjectManager.getManager().getOpenProjects().get(0);
    // test with a class in a package
    Object package1 = Model.getModelManagementFactory().buildPackage("test1");
    Model.getCoreHelper().setNamespace(package1, p.getRoot());
    Object cls1 = Model.getCoreFactory().buildClass(package1);
    Object cls2 = Model.getCoreFactory().buildClass(package1);
    Object cls3 = Model.getCoreFactory().buildClass(package1);
    Object cls4 = Model.getCoreFactory().buildClass(p.getRoot());
    Object c1 = Model.getFacade().getOwnedElements(p.getRoot());
    assertTrue(c1 instanceof Collection);
    // Let's make it a bit more difficult by setting the target:
    TargetManager.getInstance().setTarget(cls2);

    p.moveToTrash(package1);
    Model.getPump().flushModelEvents();

    // TODO: We should also test that the object
    // have been removed from their namespace.
    // Collection c = Model.getFacade().getOwnedElements(p.getRoot());
    assertTrue("Package not in trash", p.isInTrash(package1));
    assertTrue("Package not deleted", Model.getUmlFactory().isRemoved(package1));
    assertTrue("Class 1 not deleted", Model.getUmlFactory().isRemoved(cls1));
    assertTrue("Class 2 not deleted", Model.getUmlFactory().isRemoved(cls2));
    assertTrue("Class 3 not deleted", Model.getUmlFactory().isRemoved(cls3));
    assertTrue("Class 4 has been deleted", !Model.getUmlFactory().isRemoved(cls4));
  }
コード例 #18
0
ファイル: ActionRename.java プロジェクト: prat0318/fop
  /*
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent ae) {
    ArgoDiagram diagram = DiagramUtils.getActiveDiagram();
    List nodes = diagram.getNodes();

    if (!nodes.isEmpty()) {
      Object target = TargetManager.getInstance().getTarget();
      if (target != null) {
        RenameBox box = new RenameBox(Translator.localize("action.rename"), target);

        // LOG.info(target.getClass().getName());

        //    		if (target != null && target instanceof UmlClass) {
        //    			UmlClass ele = (UmlClass) target;
        //    			String name = ele.getName();
        //
        //    			box.setRenameNode();
        //    		} else {
        //    			// This is what we are not doing currently.
        //    			box.addNodes(nodes);
        //    		}
        box.setVisible(true);
      }
    } else {
      // OptionPane.showMessageDialog(diagram, "here comes the text.");
    }
  }
コード例 #19
0
  /*
   * @see junit.framework.TestCase#setUp()
   */
  protected void setUp() {
    action = getAction();
    ns = getNamespace();
    validNamespaces = getValidNamespaceClasses();

    TargetManager.getInstance().setTarget(ns);
  }
コード例 #20
0
  /**
   * Tests if the list with namespaces defined in getValidNamespaceClasses contains only valid
   * namespaces.
   *
   * <p>TODO: This test does not test anything, really!
   */
  public void testValidNamespaces() {
    Iterator it = validNamespaces.iterator();
    while (it.hasNext()) {
      Object type = it.next();

      Object o = Model.getUmlFactory().buildNode(type);
      String objDesc = "" + o;
      if (o != null) {
        objDesc += " (" + o.getClass() + ")";
      }
      TargetManager.getInstance().setTarget(o);
      Model.getPump().flushModelEvents();
      action.actionPerformed(null);
      Object d = TargetManager.getInstance().getTarget();
      assertTrue(objDesc + " is not valid namespace for the diagram", d instanceof ArgoDiagram);
    }
  }
コード例 #21
0
  /*
   * @see org.argouml.uml.ui.UMLExpressionModel2#setExpression(java.lang.Object)
   */
  public void setExpression(Object expression) {
    Object target = TargetManager.getInstance().getTarget();

    if (target == null) {
      throw new IllegalStateException("There is no target for " + getContainer());
    }
    Model.getCommonBehaviorHelper().setRecurrence(target, expression);
  }
コード例 #22
0
 /**
  * This action is performed on ALL targets.
  *
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 public final void actionPerformed(ActionEvent e) {
   super.actionPerformed(e);
   Iterator i = TargetManager.getInstance().getTargets().iterator();
   while (i.hasNext()) {
     Object t = i.next();
     toggleValueOfTarget(t);
   }
 }
コード例 #23
0
 /** @see java.awt.event.ActionListener#actionPerformed( java.awt.event.ActionEvent) */
 public void actionPerformed(ActionEvent e) {
   super.actionPerformed(e);
   Object t = TargetManager.getInstance().getModelTarget();
   Object owner = null;
   Object namespace = null;
   if (Model.getFacade().isAStereotype(t)) {
     owner = t;
   } else if (Model.getFacade().isAPackage(t)) {
     namespace = t;
   } else {
     namespace = Model.getFacade().getModel(t);
   }
   Object newTagDefinition =
       Model.getExtensionMechanismsFactory().buildTagDefinition((String) null, owner, namespace);
   TargetManager.getInstance().setTarget(newTagDefinition);
   super.actionPerformed(e);
 }
コード例 #24
0
  /** @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(java.awt.event.MouseEvent) */
  public Vector getPopUpActions(MouseEvent me) {
    Vector popUpActions = super.getPopUpActions(me);

    // TODO: Remove this line after 0.20.
    // This is a hack that removes the ordering menu according to issue 3645
    popUpActions.remove(0);

    // popupAddOffset should be equal to the number of items added here:
    popUpActions.addElement(new JSeparator());
    popupAddOffset = 1;
    if (removeFromDiagram) {
      popUpActions.addElement(ProjectBrowser.getInstance().getRemoveFromDiagramAction());
      popupAddOffset++;
    }
    popUpActions.addElement(new ActionDeleteModelElements());
    popupAddOffset++;

    /* Check if multiple items are selected: */
    boolean ms = TargetManager.getInstance().getTargets().size() > 1;
    if (!ms) {
      // #if defined(COGNITIVE)
      // @#$LPS-COGNITIVE:GranularityType:Statement
      // @#$LPS-COGNITIVE:Localization:NestedStatement
      ToDoList list = Designer.theDesigner().getToDoList();
      Vector items = (Vector) list.elementsForOffender(getOwner()).clone();
      if (items != null && items.size() > 0) {
        ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques");
        ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY());
        if (itemUnderMouse != null) {
          critiques.add(new ActionGoToCritique(itemUnderMouse));
          critiques.addSeparator();
        }
        int size = items.size();
        for (int i = 0; i < size; i++) {
          ToDoItem item = (ToDoItem) items.elementAt(i);
          if (item == itemUnderMouse) continue;
          critiques.add(new ActionGoToCritique(item));
        }
        popUpActions.insertElementAt(new JSeparator(), 0);
        popUpActions.insertElementAt(critiques, 0);
      }
    }
    // #endif

    // Add stereotypes submenu
    Action[] stereoActions = getApplyStereotypeActions();
    if (stereoActions != null) {
      popUpActions.insertElementAt(new JSeparator(), 0);
      ArgoJMenu stereotypes = new ArgoJMenu("menu.popup.apply-stereotypes");
      for (int i = 0; i < stereoActions.length; ++i) {
        stereotypes.addCheckItem(stereoActions[i]);
      }
      popUpActions.insertElementAt(stereotypes, 0);
    }
    return popUpActions;
  }
コード例 #25
0
  /**
   * Create a new AddToDoItemDialog
   *
   * @param renderer the ListCellRenderer to use in order to display the offenders
   */
  public AddToDoItemDialog(ListCellRenderer renderer) {
    super(Translator.localize("dialog.title.add-todo-item"), Dialog.OK_CANCEL_OPTION, true);

    headLineTextField = new JTextField(TEXT_COLUMNS);
    priorityComboBox = new JComboBox(PRIORITIES);
    moreinfoTextField = new JTextField(TEXT_COLUMNS);
    descriptionTextArea = new JTextArea(TEXT_ROWS, TEXT_COLUMNS);

    DefaultListModel dlm = new DefaultListModel();
    Object[] offObj = TargetManager.getInstance().getModelTargets().toArray();
    for (int i = 0; i < offObj.length; i++) {
      if (offObj[i] != null) {
        dlm.addElement(offObj[i]);
      }
    }

    offenderList = new JList(dlm);
    offenderList.setCellRenderer(renderer);
    JScrollPane offenderScroll = new JScrollPane(offenderList);
    offenderScroll.setOpaque(true);

    JLabel headlineLabel = new JLabel(Translator.localize("label.headline"));
    JLabel priorityLabel = new JLabel(Translator.localize("label.priority"));
    JLabel moreInfoLabel = new JLabel(Translator.localize("label.more-info-url"));
    JLabel offenderLabel = new JLabel(Translator.localize("label.offenders"));
    priorityComboBox.setSelectedItem(PRIORITIES[0]);

    JPanel panel = new JPanel(new LabelledLayout(getLabelGap(), getComponentGap()));

    headlineLabel.setLabelFor(headLineTextField);
    panel.add(headlineLabel);
    panel.add(headLineTextField);

    priorityLabel.setLabelFor(priorityComboBox);
    panel.add(priorityLabel);
    panel.add(priorityComboBox);

    moreInfoLabel.setLabelFor(moreinfoTextField);
    panel.add(moreInfoLabel);
    panel.add(moreinfoTextField);

    offenderLabel.setLabelFor(offenderScroll);
    panel.add(offenderLabel);
    panel.add(offenderScroll);

    descriptionTextArea.setLineWrap(true); // MVW - Issue 2422
    descriptionTextArea.setWrapStyleWord(true); // MVW - Issue 2422
    descriptionTextArea.setText(Translator.localize("label.enter-todo-item") + "\n");
    descriptionTextArea.setMargin(new Insets(INSET_PX, INSET_PX, INSET_PX, INSET_PX));
    JScrollPane descriptionScroller = new JScrollPane(descriptionTextArea);
    descriptionScroller.setPreferredSize(descriptionTextArea.getPreferredSize());
    panel.add(descriptionScroller);

    setContent(panel);
  }
コード例 #26
0
  /*
   * @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);
  }
コード例 #27
0
 /** Test to create a diagram. */
 public void testCreateDiagram() {
   Model.getPump().flushModelEvents();
   action.actionPerformed(null);
   Object d = TargetManager.getInstance().getTarget();
   assertTrue("No diagram generated", d instanceof ArgoDiagram);
   Model.getPump().flushModelEvents();
   ArgoDiagram diagram = (ArgoDiagram) d;
   assertNotNull("The diagram has no namespace", diagram.getNamespace());
   assertNotNull("The diagram has no graphmodel", diagram.getGraphModel());
   assertTrue(
       "The graphmodel of the diagram is not a " + "UMLMutableGraphSupport",
       diagram.getGraphModel() instanceof UMLMutableGraphSupport);
   assertNotNull("The diagram has no name", diagram.getName());
 }
コード例 #28
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);
 }
コード例 #29
0
  /** @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);
    }
  }
コード例 #30
0
  /** Tests if two diagrams created have different names. */
  public void testDifferentNames() {
    action.actionPerformed(null);
    Object d = TargetManager.getInstance().getTarget();
    assertTrue("No diagram generated", d instanceof ArgoDiagram);
    Model.getPump().flushModelEvents();
    ArgoDiagram diagram1 = (ArgoDiagram) d;
    // This next line is needed to register the diagram in the project,
    // since creating a next diagram will need the new name to be compared
    // with existing diagrams in the project, to validate
    // there are no duplicates.
    ProjectManager.getManager().getCurrentProject().addMember(diagram1);

    TargetManager.getInstance().setTarget(ns);
    action.actionPerformed(null);
    d = TargetManager.getInstance().getTarget();
    assertTrue("No diagram generated", d instanceof ArgoDiagram);
    Model.getPump().flushModelEvents();
    ArgoDiagram diagram2 = (ArgoDiagram) d;

    Model.getPump().flushModelEvents();
    assertTrue(
        "The created diagrams have the same name",
        !(diagram1.getName().equals(diagram2.getName())));
  }