/**
   * Action method invoked when an event triggers this action.
   *
   * <p>The {@link #_compartment} instance variable defines the action to take, and the {@link
   * #_display} instance variable whether it should set visibility or note.
   *
   * <p><em>Note</em>. The {@link #_display} instance variable is really redundant. Its value is
   * implied by the operation.
   *
   * @param ae The event that triggered us.
   */
  public void actionPerformed(ActionEvent ae) {

    // Only do anything if we have a single item selected (surely this
    // should work for multiple selections as well?).

    Vector sels = Globals.curEditor().getSelectionManager().selections();

    if (sels.size() == 1) {
      Selection sel = (Selection) sels.firstElement();
      Fig f = sel.getContent();

      // Perform the action

      if (_compartment.equals("Show Attribute Compartment")) {
        ((FigClass) f).setAttributeVisible(_display);
      } else if (_compartment.equals("Hide Attribute Compartment")) {
        ((FigClass) f).setAttributeVisible(_display);
      } else if (_compartment.equals("Show Operation Compartment")
          || _compartment.equals("Hide Operation Compartment")) {
        if (f instanceof FigClass) ((FigClass) f).setOperationVisible(_display);
        if (f instanceof FigInterface) ((FigInterface) f).setOperationVisible(_display);
      } else if (_compartment.equals("Show Extension Point Compartment")) {
        ((FigUseCase) f).setExtensionPointVisible(_display);
      } else if (_compartment.equals("Hide Extension Point Compartment")) {
        ((FigUseCase) f).setExtensionPointVisible(_display);
      } else if (_compartment.equals("Show All Compartments")) {
        ((FigClass) f).setAttributeVisible(_display);
        ((FigClass) f).setOperationVisible(_display);
      } else {
        ((FigClass) f).setAttributeVisible(_display);
        ((FigClass) f).setOperationVisible(_display);
      }
    }
  }
예제 #2
0
 @Override
 public Object clone() {
   FigClass figClone = (FigClass) super.clone();
   Iterator thisIter = this.getFigs().iterator();
   Iterator cloneIter = figClone.getFigs().iterator();
   while (thisIter.hasNext()) {
     Fig thisFig = (Fig) thisIter.next();
     Fig cloneFig = (Fig) cloneIter.next();
   }
   return figClone;
 }
예제 #3
0
 /** @see java.lang.Object#clone() */
 public Object clone() {
   FigClass figClone = (FigClass) super.clone();
   Iterator thisIter = this.getFigs().iterator();
   Iterator cloneIter = figClone.getFigs().iterator();
   while (thisIter.hasNext()) {
     Fig thisFig = (Fig) thisIter.next();
     Fig cloneFig = (Fig) cloneIter.next();
     if (thisFig == borderFig) {
       figClone.borderFig = (FigRect) thisFig;
     }
   }
   return figClone;
 }
예제 #4
0
  /**
   * Add a classier to the current diagram.
   *
   * @param classifier The new class or interface to add to the editor.
   * @param minimise minimise the class fig by hiding compartments (of attributes and operations)
   */
  private void addClassifier(Object classifier, boolean minimise) {

    String name = Model.getFacade().getName(classifier);

    // if the classifier is not in the current diagram, add it:
    if (currentGM.canAddNode(classifier)) {
      FigClassifierBox newFig;
      if (Model.getFacade().isAClass(classifier)) {
        newFig = new FigClass(currentGM, classifier);
      } else if (Model.getFacade().isAInterface(classifier)) {
        newFig = new FigInterface(currentGM, classifier);
      } else {
        return;
      }

      /*
       * The following calls are ORDER DEPENDENT. Not sure why, but the
       * layer add must come before the model add or we'll end up with
       * duplicate figures in the diagram. - tfm
       */
      currentLayer.add(newFig);
      currentGM.addNode(classifier);
      currentLayer.putInPosition(newFig);

      newFig.setOperationsVisible(!minimise);
      if (Model.getFacade().isAClass(classifier)) {
        ((FigClass) newFig).setAttributesVisible(!minimise);
      }

      newFig.setSize(newFig.getMinimumSize());
    } else {
      // the class is in the diagram
      // so we are on a second pass,
      // find the fig for this class can update its visible state.
      FigClassifierBox existingFig = null;
      List figs = currentLayer.getContentsNoEdges();
      for (int i = 0; i < figs.size(); i++) {
        Fig fig = (Fig) figs.get(i);
        if (classifier == fig.getOwner()) {
          existingFig = (FigClassifierBox) fig;
        }
      }
      existingFig.renderingChanged();
    }

    // add edges
    // for a 2-pass r.e. process we might have already added the
    // class but not its edges
    currentGM.addNodeRelatedEdges(classifier);
  }