Ejemplo n.º 1
0
 /*
  * @see org.argouml.kernel.DelayedVChangeListener#delayedVetoableChange(java.beans.PropertyChangeEvent)
  */
 public void delayedVetoableChange(PropertyChangeEvent pce) {
   if (stylePanel != null) {
     stylePanel.refresh(pce);
   }
 }
Ejemplo n.º 2
0
  /**
   * Sets the target of the style tab.
   *
   * @param t is the new target
   */
  public void setTarget(Object t) {
    if (target != null) {
      target.removePropertyChangeListener(this);
      if (target instanceof FigEdge) {
        // In this case, the bounds are determined by the FigEdge
        ((FigEdge) target).getFig().removePropertyChangeListener(this);
      }
      if (target instanceof FigAssociationClass) {
        // In this case, the bounds (of the box) are determined
        // by the FigClassAssociationClass
        FigClassAssociationClass ac = ((FigAssociationClass) target).getAssociationClass();
        // A newly created AssociationClass may not have all its parts
        // created by the time we are called
        if (ac != null) {
          ac.removePropertyChangeListener(this);
        }
      }
    }

    // TODO: Defer most of this work if the panel isn't visible - tfm

    // the responsibility of determining if the given target is a
    // correct one for this tab has been moved from the
    // DetailsPane to the member tabs of the details pane. Reason for
    // this is that the details pane is configurable and cannot
    // know what's the correct target for some tab.
    if (!(t instanceof Fig)) {
      if (Model.getFacade().isAModelElement(t)) {
        ArgoDiagram diagram = DiagramUtils.getActiveDiagram();
        if (diagram != null) {
          t = diagram.presentationFor(t);
        }
        if (!(t instanceof Fig)) {
          Project p = ProjectManager.getManager().getCurrentProject();
          Collection col = p.findFigsForMember(t);
          if (col == null || col.isEmpty()) {
            return;
          }
          t = col.iterator().next();
        }
        if (!(t instanceof Fig)) {
          return;
        }
      } else {
        return;
      }
    }

    target = (Fig) t;
    if (target != null) {
      target.addPropertyChangeListener(this);
      // TODO: This shouldn't know about the specific type of Fig that
      // is being displayed.  That couples it too strongly to things it
      // shouldn't need to know about - tfm - 20070924
      if (target instanceof FigEdge) {
        // In this case, the bounds are determined by the FigEdge
        ((FigEdge) target).getFig().addPropertyChangeListener(this);
      }
      if (target instanceof FigAssociationClass) {
        // In this case, the bounds (of the box) are determined
        // by the FigClassAssociationClass
        FigClassAssociationClass ac = ((FigAssociationClass) target).getAssociationClass();
        // A newly created AssociationClass may not have all its parts
        // created by the time we are called
        if (ac != null) {
          ac.addPropertyChangeListener(this);
        }
      }
    }
    if (lastPanel != null) {
      remove(lastPanel);
      if (lastPanel instanceof TargetListener) {
        removeTargetListener((TargetListener) lastPanel);
      }
    }
    if (t == null) {
      add(blankPanel, BorderLayout.NORTH);
      shouldBeEnabled = false;
      lastPanel = blankPanel;
      return;
    }
    shouldBeEnabled = true;
    stylePanel = null;
    Class targetClass = t.getClass();

    stylePanel = findPanelFor(targetClass);

    if (stylePanel != null) {
      removeTargetListener(stylePanel);
      addTargetListener(stylePanel);
      stylePanel.setTarget(target);
      add(stylePanel, BorderLayout.NORTH);
      shouldBeEnabled = true;
      lastPanel = stylePanel;
    } else {
      add(blankPanel, BorderLayout.NORTH);
      shouldBeEnabled = false;
      lastPanel = blankPanel;
    }
    validate();
    repaint();
  }