/** @was-generated */
 private String getType(IMarker marker) {
   try {
     return marker.getType();
   } catch (CoreException e) {
     DiagramPlugin.getDefault().logError(Messages.MarkerObserver_validationMarkerFailureMsg, e);
     return ""; //$NON-NLS-1$
   }
 }
    /** @was-generated */
    public StatusDecorator(IDecoratorTarget decoratorTarget) {
      super(decoratorTarget);
      try {
        final View view = (View) getDecoratorTarget().getAdapter(View.class);
        TransactionUtil.getEditingDomain(view)
            .runExclusive(
                new Runnable() {

                  @Override
                  public void run() {
                    StatusDecorator.this.viewId =
                        view != null ? SiriusGMFHelper.getViewId(view) : null;
                  }
                });
      } catch (Exception e) {
        DiagramPlugin.getDefault().logError(Messages.StatusDecorator_viewIdAccessFailureMsg, e);
      }
    }
 /**
  * Clear cache if necessary and return true if a refresh of figure of opened editors must be done,
  * false otherwise.
  *
  * @param delta , resource delta
  * @return boolean
  */
 private boolean needClearCache(IResource resource) {
   boolean cacheUpdated = false;
   String resourceExtension = resource.getFileExtension();
   if (WorkspaceImageFigure.isSvgImage(resourceExtension)) {
     String svgUri = resource.getFullPath().toString();
     Option<String> removed = SVGWorkspaceImageFigure.removeFromCache(svgUri);
     if (removed.some()) {
       cacheUpdated = true;
     }
   } else {
     URL url;
     try {
       url =
           new File(
                   ResourcesPlugin.getWorkspace()
                       .getRoot()
                       .getLocation()
                       .append(resource.getFullPath())
                       .toOSString())
               .toURI()
               .toURL();
     } catch (MalformedURLException e) {
       DiagramPlugin.getDefault().logError("Invalid uri : " + e.getMessage());
       return false;
     }
     ImageDescriptor bundledImageDescriptor = ImageDescriptor.createFromURL(url);
     boolean removed = DiagramUIPlugin.getPlugin().removeCacheImage(bundledImageDescriptor);
     // If a removed cache action is do, a refresh opened editors
     // is
     // required
     if (removed) {
       cacheUpdated = true;
     }
   }
   return cacheUpdated;
 }
    /** @not-generated */
    @Override
    public void refresh() {
      removeDecoration();
      View view = (View) getDecoratorTarget().getAdapter(View.class);
      Resource viewResource = null;
      if (view != null) {
        viewResource = view.eResource();
      }
      if (viewResource == null) {
        return;
      }
      EditPart editPart = (EditPart) getDecoratorTarget().getAdapter(EditPart.class);
      if (editPart == null || editPart.getParent() == null || editPart.getViewer() == null) {
        return;
      }

      // query for all the validation markers of the current resource
      String elementId = SiriusGMFHelper.getViewId(view);
      if (elementId == null) {
        return;
      }

      // Directly retrieve the main Session resource
      // (session.getSessionResource()) as we know we put the marker on
      // it.
      Session currentSession = null;
      ResourceSet currentRs = viewResource.getResourceSet();
      for (Session session : SessionManager.INSTANCE.getSessions()) {
        if (currentRs == session.getTransactionalEditingDomain().getResourceSet()) {
          currentSession = session;
          break;
        }
      }
      Resource markedResource = currentSession == null ? null : currentSession.getSessionResource();
      IResource resource = WorkspaceSynchronizer.getFile(markedResource);

      if (resource == null || !resource.exists()) {
        return;
      }
      IMarker[] markers = null;
      try {
        markers = resource.findMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE);
      } catch (CoreException e) {
        DiagramPlugin.getDefault()
            .logError(Messages.StatusDecorator_validationMarkersFailureMsg, e);
      }
      if (markers == null || markers.length == 0) {
        return;
      }

      int severity = IMarker.SEVERITY_INFO;
      IMarker foundMarker = null;
      Label toolTip = null;
      for (int i = 0; i < markers.length; i++) {
        IMarker marker = markers[i];
        String attribute =
            marker.getAttribute(
                org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, ""); // $NON-NLS-1$
        if (attribute.equals(elementId)) {
          int nextSeverity = marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
          Image nextImage = getImage(nextSeverity);
          if (foundMarker == null) {
            foundMarker = marker;
            toolTip =
                new Label(
                    marker.getAttribute(IMarker.MESSAGE, ""), // $NON-NLS-1$
                    nextImage);
          } else {
            if (toolTip.getChildren().isEmpty()) {
              Label comositeLabel = new Label();
              FlowLayout fl = new FlowLayout(false);
              fl.setMinorSpacing(0);
              comositeLabel.setLayoutManager(fl);
              comositeLabel.add(toolTip);
              toolTip = comositeLabel;
            }
            toolTip.add(
                new Label(
                    marker.getAttribute(IMarker.MESSAGE, ""), // $NON-NLS-1$
                    nextImage));
          }
          severity = (nextSeverity > severity) ? nextSeverity : severity;
        }
      }
      if (foundMarker == null) {
        return;
      }

      // add decoration
      if (editPart instanceof org.eclipse.gef.GraphicalEditPart) {
        IDecoration decoration = null;

        if (view instanceof Diagram) {
          // There is not yet defined decorator for a diagram
        } else if (view instanceof Edge) {
          decoration = getDecoratorTarget().addConnectionDecoration(getImage(severity), 50, true);
        } else {
          int margin = -1;
          margin =
              MapModeUtil.getMapMode(((org.eclipse.gef.GraphicalEditPart) editPart).getFigure())
                  .DPtoLP(margin);
          decoration =
              getDecoratorTarget()
                  .addShapeDecoration(
                      getImage(severity), IDecoratorTarget.Direction.NORTH_EAST, margin, true);
        }

        if (decoration != null) {
          setDecoration(decoration);

          // getDecaration() returns a {@link Decoration} instead of a
          // {@link IDecoration}
          getDecoration().setToolTip(toolTip);
        }
      }
    }