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

                  public void run() {
                    StatusDecorator.this.viewId = view != null ? ViewUtil.getIdStr(view) : null;
                  }
                });
      } catch (Exception e) {
        PowerWindowDiagramEditorPlugin.getInstance()
            .logError("ViewID access failure", e); // $NON-NLS-1$	
      }
    }
    /** @generated */
    public void refresh() {
      removeDecoration();
      View view = (View) getDecoratorTarget().getAdapter(View.class);
      if (view == null || view.eResource() == null) {
        return;
      }
      EditPart editPart = (EditPart) getDecoratorTarget().getAdapter(EditPart.class);
      if (editPart == null || editPart.getViewer() == null) {
        return;
      }

      // query for all the validation markers of the current resource
      String elementId = ViewUtil.getIdStr(view);
      if (elementId == null) {
        return;
      }
      int severity = IMarker.SEVERITY_INFO;
      IMarker foundMarker = null;
      IResource resource = WorkspaceSynchronizer.getFile(view.eResource());
      if (resource == null || !resource.exists()) {
        return;
      }
      IMarker[] markers = null;
      try {
        markers = resource.findMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE);
      } catch (CoreException e) {
        PowerWindowDiagramEditorPlugin.getInstance()
            .logError("Validation markers refresh failure", e); // $NON-NLS-1$
      }
      if (markers == null || markers.length == 0) {
        return;
      }
      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) {
        if (view instanceof Edge) {
          setDecoration(getDecoratorTarget().addConnectionDecoration(getImage(severity), 50, true));
        } else {
          int margin = -1;
          if (editPart instanceof org.eclipse.gef.GraphicalEditPart) {
            margin =
                MapModeUtil.getMapMode(((org.eclipse.gef.GraphicalEditPart) editPart).getFigure())
                    .DPtoLP(margin);
          }
          setDecoration(
              getDecoratorTarget()
                  .addShapeDecoration(
                      getImage(severity), IDecoratorTarget.Direction.NORTH_EAST, margin, true));
        }
        getDecoration().setToolTip(toolTip);
      }
    }