/** @generated */
  public boolean performFinish() {
    LinkedList<IFile> affectedFiles = new LinkedList<IFile>();
    IFile diagramFile = myFileCreationPage.createNewFile();
    de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorUtil.setCharset(
        diagramFile);
    affectedFiles.add(diagramFile);
    URI diagramModelURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
    ResourceSet resourceSet = myEditingDomain.getResourceSet();
    final Resource diagramResource = resourceSet.createResource(diagramModelURI);
    AbstractTransactionalCommand command =
        new AbstractTransactionalCommand(
            myEditingDomain,
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages
                .VespucciNewDiagramFileWizard_InitDiagramCommand,
            affectedFiles) {

          protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
              throws ExecutionException {
            int diagramVID =
                de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciVisualIDRegistry
                    .getDiagramVisualID(diagramRootElementSelectionPage.getModelElement());
            if (diagramVID
                != de.tud.cs.st.vespucci.vespucci_model.diagram.edit.parts.ShapesDiagramEditPart
                    .VISUAL_ID) {
              return CommandResult.newErrorCommandResult(
                  de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages
                      .VespucciNewDiagramFileWizard_IncorrectRootError);
            }
            Diagram diagram =
                ViewService.createDiagram(
                    diagramRootElementSelectionPage.getModelElement(),
                    de.tud.cs.st.vespucci.vespucci_model.diagram.edit.parts.ShapesDiagramEditPart
                        .MODEL_ID,
                    de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorPlugin
                        .DIAGRAM_PREFERENCES_HINT);
            diagramResource.getContents().add(diagram);
            diagramResource.getContents().add(diagram.getElement());
            return CommandResult.newOKCommandResult();
          }
        };
    try {
      OperationHistoryFactory.getOperationHistory()
          .execute(command, new NullProgressMonitor(), null);
      diagramResource.save(
          de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorUtil
              .getSaveOptions());
      de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorUtil.openDiagram(
          diagramResource);
    } catch (ExecutionException e) {
      de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorPlugin.getInstance()
          .logError("Unable to create model and diagram", e); // $NON-NLS-1$
    } catch (IOException ex) {
      de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorPlugin.getInstance()
          .logError("Save operation failed for: " + diagramModelURI, ex); // $NON-NLS-1$
    } catch (PartInitException ex) {
      de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorPlugin.getInstance()
          .logError("Unable to open editor", ex); // $NON-NLS-1$
    }
    return true;
  }
 /** @generated */
 private String getType(IMarker marker) {
   try {
     return marker.getType();
   } catch (CoreException e) {
     de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorPlugin.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) {
        de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorPlugin.getInstance()
            .logError("ViewID access failure", e); // $NON-NLS-1$	
      }
    }
 @Override
 protected Image getImage() {
   ImageDescriptor imageDescriptor =
       VespucciDiagramEditorPlugin.getBundledImageDescriptor(getImagePath());
   return imageDescriptor.createImage();
 }
    /** @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) {
        de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorPlugin.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);
      }
    }