/**
  * Returns the image for the element
  *
  * @param editPart the edit part that displays the element
  * @return the image
  */
 public Image getImage(GraphicalEditPart editPart) {
   Element element = getUMLElement(editPart);
   String key = "";
   if (element instanceof NamedElement) {
     key = ((NamedElement) element).getName() + "::" + ((NamedElement) element).getVisibility();
   } else if (element != null) {
     key = element.getClass().getName();
   } else {
     return null;
   }
   ImageRegistry imageRegistry = Activator.getDefault().getImageRegistry();
   Image image = imageRegistry.get(key);
   ImageDescriptor descriptor = null;
   if (image == null) {
     AdapterFactory factory = Activator.getDefault().getItemProvidersAdapterFactory();
     IItemLabelProvider labelProvider =
         (IItemLabelProvider) factory.adapt(getUMLElement(editPart), IItemLabelProvider.class);
     if (labelProvider != null) {
       descriptor =
           ExtendedImageRegistry.getInstance()
               .getImageDescriptor(labelProvider.getImage(getUMLElement(editPart)));
     }
     if (descriptor == null) {
       descriptor = ImageDescriptor.getMissingImageDescriptor();
     }
     imageRegistry.put(key, descriptor);
     image = imageRegistry.get(key);
   }
   return image;
 }
Пример #2
0
  /** @{inheritDoc */
  @Override
  protected IDialogSettings getDialogSettings() {
    IDialogSettings settings =
        Activator.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS);

    if (settings == null) {
      settings = Activator.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS);
    }

    return settings;
  }
 /**
  * Creates a new wizard page with the given name, title, and image.
  *
  * @param part the editor part in which the wizard was created
  */
 public LocalPaletteInformationPage(IEditorPart part) {
   super(
       Messages.Local_Palette_InfoPage_Name,
       Messages.Local_Palette_InfoPage_Title,
       Activator.getImageDescriptor(WIZARD_ICON));
   this.editorPart = part;
 }
Пример #4
0
  /**
   * Find the image (SWT) in registry Store image in registry if it is not found
   *
   * @param umlImage to retrieve as SWT Image in registry
   * @return the stored SWT image
   */
  public static Image getImageInRegistry(
      org.eclipse.uml2.uml.Image umlImage, VisibilityKind visibility) {
    // Retrieve registry
    ImageRegistry papyrusRegistry = getDefault().getImageRegistry();

    // Get image id for registry
    String image_id = ImageUtil.getImageId(umlImage);
    if (visibility != null) {
      image_id = image_id + "_" + visibility.getLiteral();
    }

    // Get SWT image for shape in the registry
    Image image = papyrusRegistry.get(image_id);

    // If image was not found in registry,
    // try to find an image and to update registry
    if (image == null) {

      try {
        // Try to retrieve image from UML Image content property
        image = ImageUtil.getContent(umlImage);
      } catch (Exception e) {
        // Activator.log.error(e);
      }

      // If no image was found in Content
      // Try to retrieve image from UML Image location property
      if (image == null) {
        image = ImageUtil.getImageFromLocation(umlImage);
      }

      // Add visibility decorator
      if (visibility != null) {

        getDefault();
        ImageDescriptor visDesc =
            Activator.getImageDescriptor(
                UML_VIS_ICONS_16x16 + "VisibilityKind_" + visibility.getLiteral() + ".gif");

        // Overlay custom image over base image
        OverlayVisibilityIcon overlayIcon = new OverlayVisibilityIcon(image, visDesc);
        image = overlayIcon.getImage();
      }

      if (image != null) {
        // Store image in registry
        ImageData imdata = image.getImageData();
        papyrusRegistry.put(image_id, ImageDescriptor.createFromImageData(imdata));
        image = papyrusRegistry.get(image_id);
      }
    }

    return image;
  }
Пример #5
0
  /**
   * saves the given root memento with the given key in the preference area
   *
   * @param xmlMemento the memento to save
   * @param key the key for the preference store
   */
  private static void saveMemento(XMLMemento xmlMemento, String key) {
    // save memento
    StringWriter writer = new StringWriter();
    try {
      xmlMemento.save(writer);

      if (getPreferenceStore() != null) {
        getPreferenceStore().setValue(key, writer.toString());
      }
    } catch (IOException e) {
      Activator.getDefault().logError("input/ouput exception", e);
    }
  }
  @Override
  public Image stereotypeIconToDisplay() {

    // retrieve the first stereotype in the list of displayed stereotype

    // String firstStereotypeName = tokenizer.nextToken();
    EList<Stereotype> stereotype_list = getUMLElement().getAppliedStereotypes();
    if (stereotype_list.size() != 0) {
      Stereotype stereotype = stereotype_list.get(0);
      if (stereotype.getName().equals("DataFlowPort")
          || stereotype.getName().equals("ServicePort")) {
        Image icon = Activator.getIconElement(getUMLElement(), stereotype, false);

        IFigure portView = getHostFigure();
        IFigure parentView = portView.getParent().getParent();

        Rectangle parentBounds = parentView.getBounds();
        Rectangle portBounds = portView.getBounds();

        if (portBounds.x() <= parentBounds.x()) {
          // left
          return icon;
        } else if (portBounds.x() >= (parentBounds.right() - portBounds.width())) {
          // right
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 180));
        } else if (portBounds.y() <= parentBounds.y()) {
          // top
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 90));
        } else if (portBounds.y() >= parentBounds.bottom() - portBounds.height()) {
          // bottom
          return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, -90));
        } else {
          return null;
        }
      }
      return Activator.getIconElement(getUMLElement(), stereotype, false);
    }
    return null;
  }
Пример #7
0
 /**
  * Retrieves the root memento from the plugin preferences if there were existing palette
  * customizations.
  *
  * @return the root memento if there were existing customizations; null otherwise
  */
 protected static XMLMemento getExistingCustomizations() {
   String sValue = getPreferenceStore().getString(PALETTE_CUSTOMIZATIONS_ID);
   try {
     if (sValue != null && !sValue.equals("")) { // $NON-NLS-1$
       XMLMemento rootMemento = XMLMemento.createReadRoot(new StringReader(sValue));
       return rootMemento;
     } else {
       return XMLMemento.createWriteRoot(PALETTE_CUSTOMIZATIONS_ID);
     }
   } catch (WorkbenchException e) {
     Activator.getDefault().logError("Impossible to read preferences", e);
   }
   return null;
 }
Пример #8
0
 /**
  * Retrieves the root memento from the plugin preferences if there were existing local palette
  * redefinitions.
  *
  * @return the root memento if there were existing customizations, a newly created one otherwise
  *     (empty one)
  */
 protected static XMLMemento getLocalRedefinitions() {
   String sValue = getPreferenceStore().getString(PALETTE_REDEFINITIONS);
   try {
     if (sValue != null && !sValue.equals("")) { // $NON-NLS-1$
       XMLMemento rootMemento = XMLMemento.createReadRoot(new StringReader(sValue));
       return rootMemento;
     } else {
       return XMLMemento.createWriteRoot(PALETTE_REDEFINITIONS);
     }
   } catch (WorkbenchException e) {
     Activator.getDefault()
         .logError("Impossible to read preferences for palette local redefinitions", e);
   }
   return null;
 }
 public final Image addDecoration(
     IPapyrusDecoration pDecoration, int percentageFromSource, int margin, boolean isVolatile) {
   // use image registry, see bug 401056
   Image image = Activator.getPluginIconImage(Activator.ID, pDecoration.getDecorationImageForGE());
   IDecoration decoration =
       createDecorationImage(decoratorTarget, image, percentageFromSource, margin, isVolatile);
   if (decoration != null) {
     decorations.add(decoration);
     String message = pDecoration.getMessage();
     Label toolTip = getToolTip(message);
     if (decoration instanceof Decoration) {
       ((Decoration) decoration).setToolTip(toolTip);
     }
     return image;
   } else {
     return null;
   }
 }
Пример #10
0
  /**
   * Returns an <code>org.eclipse.swt.graphics.Image</code> identified by its key.<br>
   * By default, it returns a default image. This image is the image placed in the directory
   * <em>resources/icons/default.gif</em>
   *
   * @param key the key of the image
   * @param visKey must not be null : "" || "public" || "private" ...
   * @return the Image
   */
  public static Image getImage(String key, String visKey) {

    String image_id = key;
    if (!"".equals(visKey)) {
      image_id = image_id + "::" + visKey;
    }

    ImageRegistry registry = getDefault().getImageRegistry();
    Image image = registry.get(image_id);

    if (image == null) { // Image not yet in registry

      // Get the descriptor of the image without visibility
      ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(ID, key);

      if (!"".equals(visKey)) { // Add visibility overlay

        Image initialImage = desc.createImage();
        getDefault();
        ImageDescriptor visDesc =
            Activator.getImageDescriptor(UML_VIS_ICONS_16x16 + "VisibilityKind_" + visKey + ".gif");

        // Overlay custom image over base image
        OverlayVisibilityIcon overlayIcon = new OverlayVisibilityIcon(initialImage, visDesc);
        image = overlayIcon.getImage();

        registry.put(image_id, image);

      } else {
        registry.put(key, desc);
      }

      image = registry.get(image_id);
    }

    if ((image == null) && !image_id.equals(DEFAULT_IMAGE)) {
      image = getImage(DEFAULT_IMAGE);
    }

    return image;
  }
 /**
  * Returns the image to be displayed for the applied stereotypes.
  *
  * @return the image that represents the first applied stereotype or <code>null</code> if no image
  *     has to be displayed
  */
 public Collection<Image> stereotypeIconsToDisplay(GraphicalEditPart editPart) {
   String stereotypespresentationKind =
       AppliedStereotypeHelper.getAppliedStereotypePresentationKind((View) editPart.getModel());
   if (stereotypespresentationKind == null) {
     return null;
   }
   if (stereotypespresentationKind.equals(
           UMLVisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION)
       || stereotypespresentationKind.equals(
           UMLVisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION)) {
     // retrieve the first stereotype in the list of displayed stereotype
     String stereotypesToDisplay =
         AppliedStereotypeHelper.getStereotypesToDisplay((View) editPart.getModel());
     Collection<Stereotype> stereotypes = new ArrayList<Stereotype>();
     StringTokenizer tokenizer = new StringTokenizer(stereotypesToDisplay, ",");
     while (tokenizer.hasMoreTokens()) {
       String firstStereotypeName = tokenizer.nextToken();
       stereotypes.add(getUMLElement(editPart).getAppliedStereotype(firstStereotypeName));
     }
     return Activator.getIconElements(getUMLElement(editPart), stereotypes, false);
   }
   return new ArrayList<Image>();
 }
Пример #12
0
 /**
  * Returns the preference store used to store palette preferences.
  *
  * @return the preference store of this plugin
  */
 protected static IPreferenceStore getPreferenceStore() {
   return Activator.getDefault().getPreferenceStore();
 }
Пример #13
0
/**
 * The decorator to represent inherited element This decorator adds a small image ( the
 * generalization icon) next to the UML Element which are inherited. 3 positions are defined for the
 * decoration :
 *
 * <ul>
 *   <li>if the UML Element is represented like an affixed child node : in {@link
 *       PositionConstants#NORTH_WEST} or {@link PositionConstants#SOUTH_EAST} following its
 *       position/parent and margin =1
 *   <li>else if the element is in a compartment list : {@link PositionConstants#EAST} and margin
 *       =-1
 *   <li>else {@link PositionConstants#SOUTH_EAST} and margin = -1
 * </ul>
 */
public class InheritedDecorator implements IDecorator {

  /** the object to be decorated */
  private IDecoratorTarget decoratorTarget;

  /** the decoration being displayed */
  private IDecoration decoration;

  /** the plugin where owning the icons for the UML Element */
  public static final String pluginID = "org.eclipse.papyrus.uml.diagram.common"; // $NON-NLS-1$

  /** the image path */
  public static final String imagePath = "/icons/hyperlink_13x13.gif"; // $NON-NLS-1$

  /** the image used added to represent an inherited element */
  private static final Image ICON_HYPERLINK = Activator.getPluginIconImage(pluginID, imagePath);

  /**
   * Creates a new <code>AbstractDecorator</code> for the decorator target passed in.
   *
   * @param decoratorTarget the object to be decorated
   */
  public InheritedDecorator(IDecoratorTarget decoratorTarget) {
    this.decoratorTarget = decoratorTarget;
  }

  /**
   * Gets the object to be decorated.
   *
   * @return Returns the object to be decorated
   */
  protected IDecoratorTarget getDecoratorTarget() {
    return decoratorTarget;
  }

  /** @return Returns the decoration. */
  public IDecoration getDecoration() {
    return decoration;
  }

  /** @param decoration The decoration to set. */
  public void setDecoration(IDecoration decoration) {
    this.decoration = decoration;
  }

  /** Removes the decoration if it exists and sets it to null. */
  protected void removeDecoration() {
    if (decoration != null) {
      decoratorTarget.removeDecoration(decoration);
      decoration = null;
    }
  }

  /**
   * getDecoratorTargetClassifier Utility method to determine if the decoratorTarget is a supported
   * type for this decorator and return the associated Classifier element.
   *
   * @param decoratorTarget IDecoratorTarget to check and return valid Classifier target.
   * @return node Node if IDecoratorTarget can be supported, null otherwise.
   */
  public static Node getDecoratorTargetNode(IDecoratorTarget decoratorTarget) {
    DescriptionStyle descStyle = null;
    View node = (View) decoratorTarget.getAdapter(View.class);
    if (node != null && !(node instanceof Diagram)) {
      descStyle = (DescriptionStyle) node.getStyle(NotationPackage.eINSTANCE.getDescriptionStyle());

      if (descStyle != null) {
        return (Node) node;
      }
    }
    return null;
  }

  /**
   * Creates the appropriate review decoration if all the criteria is satisfied by the view passed
   * in.
   */
  public void refresh() {
    removeDecoration();

    Node node = getDecoratorTargetNode(getDecoratorTarget());
    IGraphicalEditPart gep =
        (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);

    if (node != null) {
      DescriptionStyle descStyle = getDescriptionStyle(node);

      if (descStyle != null) {
        if (isInherited(node)) {
          // if(Util.isAffixedChildNode(gep)) {

          // setDecoration(getDecoratorTarget().addDecoration(figure,
          // locator, false));
          // } else {
          // setDecoration(getDecoratorTarget().addShapeDecoration(figure,
          // getDirection(node), -1, false));
          // }

          if (gep != null && gep.getRoot() != null) { // if the gep has
            // no parent, we
            // can't test if
            // the container
            // is a
            // compartment
            // list
            // (because, we
            // call the
            // method
            // DiagramEditPartsUtil.getEditPartFromView((View)container,
            // gep);
            IFigure figure = getFigure(ICON_HYPERLINK);
            if (isInCompartmentList(node) && !Util.isAffixedChildNode(gep)) {
              setDecoration(
                  getDecoratorTarget().addShapeDecoration(figure, getDirection(node), -1, false));
            } else {
              Locator locator = new OverlayLocator(gep.getFigure(), getDirection(node));
              setDecoration(getDecoratorTarget().addDecoration(figure, locator, false));
            }
          }
        }
      }
    }
  }

  /**
   * Returns a figure corresponding to this image
   *
   * @param image a image
   * @return a figure corresponding to this image
   */
  public IFigure getFigure(Image image) {
    IMapMode mm =
        MapModeUtil.getMapMode(
            ((IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class))
                .getFigure());
    ImageFigure fig = new ImageFigure();
    fig.setImage(image);
    fig.setSize(mm.DPtoLP(image.getBounds().width), mm.DPtoLP(image.getBounds().height));
    return fig;
  }

  /**
   * Returns the direction to set the decorator for the node
   *
   * @param node the node
   * @return the direction to set the decorator for the node direction can be :
   *     <ul>
   *       <li>{@link PositionConstants#NORTH_WEST} or {@link PositionConstants#SOUTH_EAST} if the
   *           node is an Affixed Child Node
   *       <li>{@link PositionConstants#EAST} if the node is in a compartment list
   *       <li>{@link PositionConstants#SOUTH_EAST} in other cases
   *     </ul>
   */
  protected Direction getDirection(Node node) {
    IGraphicalEditPart gep =
        (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
    assert gep != null;
    // test if its an affixed ChildNode
    // if(Util.isAffixedChildNode(gep)) {
    //
    // IBorderItemLocator loc =
    // ((BorderNamedElementEditPart)gep).getBorderItemLocator();
    // int location = loc.getCurrentSideOfParent();
    // if(PositionConstants.NONE == location) { //sometimes
    // getBorderItemLocator doesn't work correctly!
    // location = PositionConstants.NORTH_WEST;
    // }
    // switch(location) {
    // case PositionConstants.NORTH:
    // case PositionConstants.NORTH_WEST:
    // case PositionConstants.WEST:
    // case PositionConstants.SOUTH_WEST:
    // // return IDecoratorTarget.Direction.NORTH_WEST;
    // default:
    // return IDecoratorTarget.Direction.SOUTH_EAST;
    // }
    // }
    if (gep.getParent() != null) {
      if (isInCompartmentList(node) && !Util.isAffixedChildNode(gep)) {
        return IDecoratorTarget.Direction.EAST;
      }
    }
    return IDecoratorTarget.Direction.SOUTH_WEST;
  }

  /**
   * Tests if the compartment is a compartment list
   *
   * @param node the node on which we want add an Overlay
   * @return <code>true</code> if the compartment is managed by an {@link XYLayoutEditPolicy}
   */
  protected boolean isInCompartmentList(Node node) {
    IGraphicalEditPart gep =
        (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
    if (gep != null && gep.getRoot() != null) {
      EObject container = node.eContainer();
      if (container instanceof View) {
        EditPart EP = DiagramEditPartsUtil.getEditPartFromView((View) container, gep);
        EditPolicy editPolicy = EP.getEditPolicy(EditPolicy.LAYOUT_ROLE);
        if (!(editPolicy instanceof XYLayoutEditPolicy)) { // we are in a
          // compartment
          // list
          return true;
        }
      }
    }
    return false;
  }

  /**
   * Tests if the node is an inherited element
   *
   * @param node a node
   * @return <code>true</code> if the node is an inherited element <code>false</code> if not
   */
  protected boolean isInherited(Node node) {
    EObject element = node.getElement();
    if (element instanceof Element) {
      EObject container = node.eContainer();
      EObject graphicalParent = null;
      if (container instanceof DecorationNode) {
        graphicalParent = ((DecorationNode) container).getElement();
      } else if (container instanceof View) {
        graphicalParent = ((View) container).getElement();
      }
      if (graphicalParent instanceof Property || graphicalParent instanceof Classifier) {
        Classifier classifier = null;
        if (graphicalParent instanceof Property) {
          Type type = ((Property) graphicalParent).getType();
          if (type instanceof Classifier) {
            classifier = (Classifier) type;
          }
        } else {
          classifier = (Classifier) graphicalParent;
        }
        if (classifier != null) {
          EList<NamedElement> inheritedMembers = classifier.getInheritedMembers();
          return inheritedMembers.contains(element);
        }
      }
    }
    return false;
  }

  /**
   * getDescriptionStyle Accessor to retrieve the description style from a Node.
   *
   * @param node Node to retrieve the description style from.
   * @return DescriptionStyle style object
   */
  protected DescriptionStyle getDescriptionStyle(Node node) {
    return (DescriptionStyle) node.getStyle(NotationPackage.eINSTANCE.getDescriptionStyle());
  }

  /** A listener used to listen the change of location and type (for Property) */
  private NotificationListener notificationListener =
      new NotificationListener() {

        /**
         * @see
         *     org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener#notifyChanged(org.eclipse.emf.common.notify.Notification)
         * @param notification
         */
        public void notifyChanged(Notification notification) {

          if (notification.getEventType() == Notification.REMOVE) {
            if (notification.getNotifier() instanceof Classifier) {
              IGraphicalEditPart gep =
                  (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
              assert gep != null;
              // we remove the listener on the container (because it's
              // changing
              DiagramEventBroker.getInstance(gep.getEditingDomain())
                  .removeNotificationListener(
                      (EObject) notification.getNotifier(), notificationListener);
            }
          }
          // we update the listeners It's useful when an Element with overlay
          // changes of parent
          deactivate();
          activate();
          refresh();
        }
      };

  /**
   * Adds listeners on
   *
   * <ul>
   *   <li>Affixed Child Node
   *   <li>graphical parent, when its a {@link Property} (we add the listener on its Type)
   * </ul>
   */
  public void activate() {

    IGraphicalEditPart gep =
        (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
    assert gep != null;
    View view = ((View) gep.getModel());

    if (view instanceof Node) {
      // the location of the decorator can change if it's an Affixed Child
      // Node
      if (isInherited((Node) view) && Util.isAffixedChildNode(gep)) {
        DiagramEventBroker.getInstance(gep.getEditingDomain())
            .addNotificationListener(gep.getNotationView(), notificationListener);
      }
    }

    // if the graphical parent is a Property, we add a listener on the type
    // of the property, to refresh the decoration
    EObject parent = view.eContainer();
    if (parent instanceof DecorationNode) {
      parent = parent.eContainer();
    }
    if (parent instanceof View) {
      EObject el = ((View) parent).getElement();
      if (el instanceof Property) {
        DiagramEventBroker.getInstance(gep.getEditingDomain())
            .addNotificationListener(
                el, UMLPackage.eINSTANCE.getTypedElement_Type(), notificationListener);
      }
    }

    /*
     * We listen the changes on the UML parent, in order to know if the
     * element is changing of parent Adding a listener using the following
     * EReference doesn't work UMLPackage.eINSTANCE.getElement_Owner();
     * UMLPackage.eINSTANCE.getProperty_Class();
     * UMLPackage.eINSTANCE.getNamedElement_Namespace(); that's why we
     * listen the parent
     */
    if (view.getElement() instanceof Element) {
      Element semanticElement = (Element) view.getElement();

      /*
       * We need add a listener only if the element is an element which
       * can be inherited, like Property, Operation, Signal, Classifier...
       */
      if (semanticElement != null && canBeInherited(semanticElement)) {
        // we listen if the container of the element changes!
        if (semanticElement.eContainer() != null) {
          DiagramEventBroker.getInstance(gep.getEditingDomain())
              .addNotificationListener(semanticElement.eContainer(), notificationListener);
        }
      }
    }
  }

  /**
   * Tests if the element can be inherited
   *
   * @param semanticElement the element to test
   * @return <code>true</code> if the element can be inherited
   */
  protected boolean canBeInherited(Element semanticElement) {
    /*
     * maybe we could replace these tests by RedefinableElement? or not?
     */

    if (semanticElement instanceof Classifier) {
      return true;
    } else if (semanticElement instanceof Property) {
      return true;
    } else if (semanticElement instanceof Operation) {
      return true;
    }
    return false;
  }

  /** Removes the listeners and the decorations */
  public void deactivate() {
    removeDecoration();

    IGraphicalEditPart gep =
        (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
    assert gep != null;
    DiagramEventBroker.getInstance(gep.getEditingDomain())
        .removeNotificationListener(gep.getNotationView(), notificationListener);
    View view = ((View) gep.getModel());

    if (view instanceof Node) {
      // the location of the decorator can change if it's an Affixed Child
      // Node
      if (isInherited((Node) view) && Util.isAffixedChildNode(gep)) {
        DiagramEventBroker.getInstance(gep.getEditingDomain())
            .removeNotificationListener(gep.getNotationView(), notificationListener);
      }
    }
    EObject parent = view.eContainer();
    if (parent instanceof View) {
      EObject el = ((View) parent).getElement();
      if (el instanceof Property) {
        DiagramEventBroker.getInstance(gep.getEditingDomain())
            .removeNotificationListener(
                el, UMLPackage.eINSTANCE.getTypedElement_Type(), notificationListener);
      }
    }

    if (view.getElement() instanceof Element) {
      Element semanticElement = (Element) view.getElement();
      if (semanticElement != null) {
        if (semanticElement.eContainer() != null) {
          DiagramEventBroker.getInstance(gep.getEditingDomain())
              .addNotificationListener(semanticElement.eContainer(), notificationListener);
        }
      }
    }
  }
}
 /**
  * Computes the string that displays the stereotypes for the current element
  *
  * @param separator the separator used to split the string representing the stereotypes.
  * @param stereotypesToDisplay the list of stereotypes displayed
  * @param stereotypeWithQualifiedName the list of stereotypes displayed using their qualified
  *     names
  * @return the string that represent the stereotypes
  */
 public String stereotypesToDisplay(
     GraphicalEditPart editPart,
     String separator,
     String stereotypesToDisplay,
     String stereotypeWithQualifiedName) {
   // AL Changes Feb. 07 - Beg
   // Style Handling for STEREOTYPE_NAME_APPEARANCE from
   // ProfileApplicationPreferencePage
   // Stereotype displayed according to UML standard (first letter forced
   // to lower case) -
   // default -
   // or kept as entered by user (user controlled)
   // Get the preference from PreferenceStore. there should be an assert
   final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
   if (store == null) {
     Activator.log.warn("The preference store was not found");
     return "";
   }
   String sNameAppearance =
       store.getString(UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_APPEARANCE);
   StringTokenizer strQualifiedName = new StringTokenizer(stereotypesToDisplay, ",");
   String out = "";
   while (strQualifiedName.hasMoreElements()) {
     String currentStereotype = strQualifiedName.nextToken();
     // check if current stereotype is applied
     final Element umlElement = getUMLElement(editPart);
     Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
     if (stereotype != null) {
       String name = currentStereotype;
       if ((stereotypeWithQualifiedName.indexOf(currentStereotype)) == -1) {
         // property value contains qualifiedName ==> extract name
         // from it
         StringTokenizer strToken = new StringTokenizer(currentStereotype, "::");
         while (strToken.hasMoreTokens()) {
           name = strToken.nextToken();
         }
       }
       // AL Changes Feb. 07 - Beg
       // Handling STEREOTYPE_NAME_APPEARANCE preference (from
       // ProfileApplicationPreferencePage)
       // Previously lowercase forced onto first letter (standard UML)
       // stereotypesToDisplay = stereotypesToDisplay+name.substring(0,
       // 1).toLowerCase()+name.substring(1,
       // name.length())+","+separator;
       // check that the name has not already been added to the
       // displayed string
       if (sNameAppearance.equals(
           UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_DISPLAY_USER_CONTROLLED)) {
         if (out.indexOf(name) == -1) {
           out = out + name + separator;
         }
       } else { // VisualInformationPapyrusConstants.P_STEREOTYPE_NAME_DISPLAY_UML_CONFORM))
         // {
         name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
         if (out.indexOf(name) == -1) {
           out = out + name + separator;
         }
       }
     }
   }
   if (out.endsWith(",")) {
     return out.substring(0, out.length() - 1);
   }
   if (out.endsWith(separator)) {
     return out.substring(0, out.length() - separator.length());
   }
   return out;
 }
 /**
  * Returns a String that displays stereotypes (using their simple name or their qualified name)
  * and their properties
  *
  * @param editPart the edit part for which the label is edited
  * @param separator the separator used to split the string representing the stereotypes.
  * @param stereotypesToDisplay the list of stereotypes displayed
  * @param stereotypeWithQualifiedName the list of stereotypes displayed using their qualified
  *     names
  * @param stereotypesPropertiesToDisplay the list of properties to display
  * @return a string that displays stereotypes (using their simple name or their qualified name)
  *     and their properties
  */
 public String stereotypesAndPropertiesToDisplay(
     GraphicalEditPart editPart,
     String separator,
     String stereotypesToDisplay,
     String stereotypeWithQualifiedName,
     String stereotypesPropertiesToDisplay) {
   // Get the preference from PreferenceStore. there should be an assert
   final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
   if (store == null) {
     Activator.log.warn("The preference store was not found");
     return "";
   }
   // retrieve if the name of the stereotype has to put to lower case or
   // not
   String sNameAppearance =
       store.getString(UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_APPEARANCE);
   // changes the string of properties into a map, where the entries of the
   // map are the
   // stereotype qualified name, and the properties to display are the data
   Map<String, List<String>> propertiesToDisplay =
       parseStereotypeProperties(editPart, stereotypesToDisplay, stereotypesPropertiesToDisplay);
   StringTokenizer strQualifiedName = new StringTokenizer(stereotypesToDisplay, ",");
   String out = "";
   while (strQualifiedName.hasMoreElements()) {
     String currentStereotype = strQualifiedName.nextToken();
     // check if current stereotype is applied
     final Element umlElement = getUMLElement(editPart);
     Stereotype stereotype = umlElement.getAppliedStereotype(currentStereotype);
     if (stereotype != null) {
       String name = currentStereotype;
       if ((stereotypeWithQualifiedName.indexOf(currentStereotype)) == -1) {
         // property value contains qualifiedName ==> extract name
         // from it
         StringTokenizer strToken = new StringTokenizer(currentStereotype, "::");
         while (strToken.hasMoreTokens()) {
           name = strToken.nextToken();
         }
       }
       // AL Changes Feb. 07 - Beg
       // Handling STEREOTYPE_NAME_APPEARANCE preference (from
       // ProfileApplicationPreferencePage)
       // Previously lowercase forced onto first letter (standard UML)
       // stereotypesToDisplay = stereotypesToDisplay+name.substring(0,
       // 1).toLowerCase()+name.substring(1,
       // name.length())+","+separator;
       // check that the name has not already been added to the
       // displayed string
       if (sNameAppearance.equals(
           UMLVisualInformationPapyrusConstant.P_STEREOTYPE_NAME_DISPLAY_USER_CONTROLLED)) {
         if (out.indexOf(name) == -1) {
           out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator;
         }
       } else { // VisualInformationPapyrusConstants.P_STEREOTYPE_NAME_DISPLAY_UML_CONFORM))
         // {
         name = name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
         if (out.indexOf(name) == -1) {
           out = out + Activator.ST_LEFT + name + Activator.ST_RIGHT + separator;
         }
       }
       // now should add all properties associated to this stereotype
       List<String> properties = propertiesToDisplay.get(stereotype.getQualifiedName());
       if (properties != null) {
         // retrieve property
         for (String propertyName : properties) {
           out =
               out
                   + StereotypeUtil.displayPropertyValue(
                       stereotype,
                       StereotypeUtil.getPropertyByName(stereotype, propertyName),
                       getUMLElement(editPart),
                       " ");
         }
       }
     }
   }
   if (out.endsWith(",")) {
     return out.substring(0, out.length() - 1);
   }
   if (out.endsWith(separator)) {
     return out.substring(0, out.length() - separator.length());
   }
   return out;
 }