/**
  * return the collection {@link Style} instances currently in the diagram.
  *
  * @return the collection {@link Style} instances currently in the diagram.
  */
 public Collection<Style> getAllStyles() {
   Collection<Style> result = new ArrayList<Style>();
   for (DDiagramElement dDiagramElement : getDiagramElements()) {
     Style style = dDiagramElement.getStyle();
     if (style != null) {
       result.add(style);
     }
   }
   return result;
 }
 /**
  * Get all the hidden existing diagram elements related to a semantic element.
  *
  * @param semanticElement Semantic element
  * @param containerView Container view
  * @return List of all existing diagram elements for the given semantic element which are
  *     currently hidden in the diagram
  */
 private List<DDiagramElement> getHiddenExistingDiagramElements(
     EObject semanticElement, DSemanticDecorator containerView) {
   final List<DDiagramElement> existingDiagramElements = Lists.newArrayList();
   if (containerView instanceof DSemanticDiagram) {
     for (final DDiagramElement element :
         ((DSemanticDiagram) containerView).getDiagramElements()) {
       if (semanticElement.equals(element.getTarget())) {
         final DDiagramElementQuery query = new DDiagramElementQuery(element);
         if (query.isHidden()) {
           existingDiagramElements.add(element);
         }
         // Get the hidden parent container of the element to reveal,
         // in order to reveal all the
         // hierarchy
         existingDiagramElements.addAll(getHiddenParentContainerViews(element));
       }
     }
   }
   return existingDiagramElements;
 }
 /**
  * Builds the command which will execute the user-specified operations to create a new observation
  * point.
  *
  * @param diagramElement the clicked diagram element.
  * @param tool the tool to use to create the execution.
  * @param startingEndPredecessor the event end graphically preceding the starting position of the
  *     new execution.
  * @param finishingEndPredecessor the event end graphically preceding the finishing position of
  *     the new execution.
  * @return a command to create the execution.
  */
 public static Command buildCreateObservationPointCommandFromTool(
     final DDiagramElement diagramElement,
     final ObservationPointCreationTool tool,
     final EventEnd startingEndPredecessor,
     final EventEnd finishingEndPredecessor) {
   NodeCreationCommandBuilder builder =
       new ObservationPointCreationCommandBuilder(
           tool, diagramElement, startingEndPredecessor, finishingEndPredecessor);
   Session session = SessionManager.INSTANCE.getSession(diagramElement.getTarget());
   return getCommand(builder, session);
 }
 /**
  * Get all the hidden diagram element in the hierarchy of a given diagram element.
  *
  * @param diagramElement Diagram element
  * @return List of all the hidden parent container element
  */
 private List<DDiagramElement> getHiddenParentContainerViews(DDiagramElement diagramElement) {
   final List<DDiagramElement> containerViews = Lists.newArrayList();
   EObject containerView = diagramElement.eContainer();
   while (!(containerView instanceof DDiagram) && containerView instanceof DDiagramElement) {
     final DDiagramElementQuery query = new DDiagramElementQuery((DDiagramElement) containerView);
     if (query.isHidden()) {
       containerViews.add((DDiagramElement) containerView);
     }
     containerView = containerView.eContainer();
   }
   return containerViews;
 }
 /**
  * Default constructor.
  *
  * @param adapterFactory The factory is used as a key so that we always know which factory created
  *     this adapter.
  * @param parentDDiagramElement The parent of the label
  */
 public AbstractDDiagramElementLabelItemProvider(
     AdapterFactory adapterFactory, DDiagramElement parentDDiagramElement) {
   super(adapterFactory);
   parentDDiagramElement.eAdapters().add(this);
 }
 /**
  * Indicates if the given element can be pinned/unpinned.
  *
  * @param element the element to check.
  * @return true if the given element can be pinned/unpinned.
  */
 public static boolean allowsPinUnpin(DDiagramElement element) {
   return element != null && allowsPinUnpin(element.getParentDiagram()).apply(element);
 }