/** @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 */
  public VespucciNewDiagramFileWizard(
      URI domainModelURI, EObject diagramRoot, TransactionalEditingDomain editingDomain) {
    assert domainModelURI != null : "Domain model uri must be specified"; // $NON-NLS-1$
    assert diagramRoot != null : "Doagram root element must be specified"; // $NON-NLS-1$
    assert editingDomain != null : "Editing domain must be specified"; // $NON-NLS-1$

    myFileCreationPage =
        new WizardNewFileCreationPage(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages
                .VespucciNewDiagramFileWizard_CreationPageName,
            StructuredSelection.EMPTY);
    myFileCreationPage.setTitle(
        de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages
            .VespucciNewDiagramFileWizard_CreationPageTitle);
    myFileCreationPage.setDescription(
        NLS.bind(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages
                .VespucciNewDiagramFileWizard_CreationPageDescription,
            de.tud.cs.st.vespucci.vespucci_model.diagram.edit.parts.ShapesDiagramEditPart
                .MODEL_ID));
    IPath filePath;
    String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment());
    if (domainModelURI.isPlatformResource()) {
      filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true));
    } else if (domainModelURI.isFile()) {
      filePath = new Path(domainModelURI.trimSegments(1).toFileString());
    } else {
      // TODO : use some default path
      throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); // $NON-NLS-1$
    }
    myFileCreationPage.setContainerFullPath(filePath);
    myFileCreationPage.setFileName(
        de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDiagramEditorUtil
            .getUniqueFileName(filePath, fileName, "sad")); // $NON-NLS-1$

    diagramRootElementSelectionPage =
        new DiagramRootElementSelectionPage(
            de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages
                .VespucciNewDiagramFileWizard_RootSelectionPageName);
    diagramRootElementSelectionPage.setTitle(
        de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages
            .VespucciNewDiagramFileWizard_RootSelectionPageTitle);
    diagramRootElementSelectionPage.setDescription(
        de.tud.cs.st.vespucci.vespucci_model.diagram.part.Messages
            .VespucciNewDiagramFileWizard_RootSelectionPageDescription);
    diagramRootElementSelectionPage.setModelElement(diagramRoot);

    myEditingDomain = editingDomain;
  }