/**
  * Runs the wizard in a dialog.
  *
  * @generated
  */
 public static void runWizard(Shell shell, Wizard wizard, String settingsKey) {
   IDialogSettings pluginDialogSettings =
       dataMapper.diagram.part.DataMapperDiagramEditorPlugin.getInstance().getDialogSettings();
   IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey);
   if (wizardDialogSettings == null) {
     wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey);
   }
   wizard.setDialogSettings(wizardDialogSettings);
   WizardDialog dialog = new WizardDialog(shell, wizard);
   dialog.create();
   dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), 500);
   dialog.open();
 }
 /** @generated */
 public static void setCharset(IFile file) {
   if (file == null) {
     return;
   }
   try {
     file.setCharset("UTF-8", new NullProgressMonitor()); // $NON-NLS-1$
   } catch (CoreException e) {
     dataMapper
         .diagram
         .part
         .DataMapperDiagramEditorPlugin
         .getInstance()
         .logError("Unable to set charset for file " + file.getFullPath(), e); // $NON-NLS-1$
   }
 }
  /**
   * This method should be called within a workspace modify operation since it creates resources.
   *
   * @generated
   */
  public static Resource createDiagram(
      URI diagramURI, URI modelURI, IProgressMonitor progressMonitor) {
    TransactionalEditingDomain editingDomain =
        GMFEditingDomainFactory.INSTANCE.createEditingDomain();
    progressMonitor.beginTask(
        dataMapper.diagram.part.Messages.DataMapperDiagramEditorUtil_CreateDiagramProgressTask, 3);
    final Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI);
    final Resource modelResource = editingDomain.getResourceSet().createResource(modelURI);
    final String diagramName = diagramURI.lastSegment();
    AbstractTransactionalCommand command =
        new AbstractTransactionalCommand(
            editingDomain,
            dataMapper.diagram.part.Messages.DataMapperDiagramEditorUtil_CreateDiagramCommandLabel,
            Collections.EMPTY_LIST) {
          protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
              throws ExecutionException {
            dataMapper.DataMapperRoot model = createInitialModel();
            attachModelToResource(model, modelResource);

            Diagram diagram =
                ViewService.createDiagram(
                    model,
                    dataMapper.diagram.edit.parts.DataMapperRootEditPart.MODEL_ID,
                    dataMapper.diagram.part.DataMapperDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
            if (diagram != null) {
              diagramResource.getContents().add(diagram);
              diagram.setName(diagramName);
              diagram.setElement(model);
            }

            try {
              modelResource.save(
                  dataMapper.diagram.part.DataMapperDiagramEditorUtil.getSaveOptions());
              diagramResource.save(
                  dataMapper.diagram.part.DataMapperDiagramEditorUtil.getSaveOptions());
            } catch (IOException e) {

              dataMapper
                  .diagram
                  .part
                  .DataMapperDiagramEditorPlugin
                  .getInstance()
                  .logError("Unable to store model and diagram resources", e); // $NON-NLS-1$
            }
            return CommandResult.newOKCommandResult();
          }
        };
    try {
      OperationHistoryFactory.getOperationHistory()
          .execute(command, new SubProgressMonitor(progressMonitor, 1), null);
    } catch (ExecutionException e) {
      dataMapper
          .diagram
          .part
          .DataMapperDiagramEditorPlugin
          .getInstance()
          .logError("Unable to create model and diagram", e); // $NON-NLS-1$
    }
    setCharset(WorkspaceSynchronizer.getFile(modelResource));
    setCharset(WorkspaceSynchronizer.getFile(diagramResource));
    return diagramResource;
  }