/**
   * Removes the passed profile from the configuration.
   *
   * @param p the profile to be removed
   */
  public void removeProfile(Profile p) {
    profiles.remove(p);
    try {
      profileModels.removeAll(p.getProfilePackages());
    } catch (ProfileException e) {
      LOG.error("Exception", e);
    }

    FigNodeStrategy fns = p.getFigureStrategy();
    if (fns != null) {
      figNodeStrategies.remove(fns);
    }

    if (formatingStrategy == p.getFormatingStrategy()) {
      formatingStrategy = null;
    }

    List<Profile> markForRemoval = new ArrayList<Profile>();
    for (Profile profile : profiles) {
      if (profile.getDependencies().contains(p)) {
        markForRemoval.add(profile);
      }
    }

    for (Profile profile : markForRemoval) {
      removeProfile(profile);
    }

    updateStrategies();
    ArgoEventPump.fireEvent(
        new ArgoProfileEvent(
            ArgoEventTypes.PROFILE_REMOVED, new PropertyChangeEvent(this, "profile", p, null)));
  }
  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();
  }
  /**
   * Applies a new profile to this configuration
   *
   * @param p the profile to be applied
   */
  @SuppressWarnings("unchecked")
  public void addProfile(Profile p) {
    if (!profiles.contains(p)) {
      profiles.add(p);
      try {
        profileModels.addAll(p.getProfilePackages());
      } catch (ProfileException e) {
        LOG.warn("Error retrieving profile's " + p + " packages.", e);
      }

      FigNodeStrategy fns = p.getFigureStrategy();
      if (fns != null) {
        figNodeStrategies.add(fns);
      }

      for (Profile dependency : p.getDependencies()) {
        addProfile(dependency);
      }

      updateStrategies();
      ArgoEventPump.fireEvent(
          new ArgoProfileEvent(
              ArgoEventTypes.PROFILE_ADDED, new PropertyChangeEvent(this, "profile", null, p)));
    }
  }
  /**
   * Partially construct a new FigNode. This method creates the _name element that holds the name of
   * the model element and adds itself as a listener.
   */
  public FigEdgeModelElement() {

    nameFig = new FigSingleLineText(10, 30, 90, 20, false);
    nameFig.setTextFilled(false);

    stereotypeFig = new FigStereotypesCompartment(10, 10, 90, 15);

    setBetweenNearestPoints(true);

    ArgoEventPump.addListener(ArgoEventTypes.ANY_NOTATION_EVENT, this);
  }
 /*
  * @see org.argouml.uml.notation.NotationProvider#parse(java.lang.Object, java.lang.String)
  */
 public void parse(Object modelElement, String text) {
   try {
     parseStateBody(modelElement, text);
   } catch (ParseException pe) {
     String msg = "statusmsg.bar.error.parsing.statebody";
     Object[] args = {
       pe.getLocalizedMessage(), Integer.valueOf(pe.getErrorOffset()),
     };
     ArgoEventPump.fireEvent(
         new ArgoHelpEvent(
             ArgoEventTypes.HELP_CHANGED, this, Translator.messageFormat(msg, args)));
   }
 }
 /**
  * Send all events when the settings are changed to refresh anything rendered with these settings.
  */
 public void notifyOfChangedSettings() {
   /*
    * Since body ever looks
    * at the type of the diagram appearance event, we can simplify from
    * sending every existing event to one event only. But since there is no
    * catch-all event defined, we just use one. Rationale: reduce the
    * number of total refreshes of the drawing.
    */
   ConfigurationKey key = Configuration.makeKey("diagramappearance", "all");
   ArgoEventPump.fireEvent(
       new ArgoDiagramAppearanceEvent(
           ArgoEventTypes.DIAGRAM_FONT_CHANGED,
           new PropertyChangeEvent(this, key.getKey(), "0", "0")));
 }
 @Override
 public void parse(Object modelElement, String text) {
   try {
     parseEnumerationLiteralFig(
         Model.getFacade().getEnumeration(modelElement), modelElement, text);
   } catch (ParseException pe) {
     String msg = "statusmsg.bar.error.parsing.enumeration-literal";
     Object[] args = {
       pe.getLocalizedMessage(), Integer.valueOf(pe.getErrorOffset()),
     };
     ArgoEventPump.fireEvent(
         new ArgoHelpEvent(
             ArgoEventTypes.HELP_CHANGED, this, Translator.messageFormat(msg, args)));
   }
 }
 /**
  * Utility function to localize the given string with help text, and show it in the status bar of
  * the ArgoUML window. This function is used in favour of the inline call to enable later
  * improvements; e.g. it would be possible to show a help-balloon.
  *
  * <p>TODO: This code is also present in other root Figs...
  *
  * @param s the given string to be localized and shown
  */
 protected void showHelp(String s) {
   ArgoEventPump.fireEvent(
       new ArgoHelpEvent(ArgoEventTypes.HELP_CHANGED, this, Translator.localize(s)));
 }
 @Override
 public void removeFromDiagram() {
   ArgoEventPump.removeListener(ArgoEventTypes.ANY_NOTATION_EVENT, this);
   notationProvider.cleanListener(this, getOwner());
   super.removeFromDiagram();
 }
 /** @see org.tigris.gef.presentation.Fig#postLoad() */
 public void postLoad() {
   ArgoEventPump.removeListener(this);
   ArgoEventPump.addListener(this);
 }