/** @generated */ public static void setCharset(IFile file) { if (file == null) { return; } try { file.setCharset("UTF-8", new NullProgressMonitor()); // $NON-NLS-1$ } catch (CoreException e) { sm_mm.diagram.part.Sm_mm_1DiagramEditorPlugin.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( sm_mm.diagram.part.Messages.Sm_mm_1DiagramEditorUtil_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, sm_mm.diagram.part.Messages.Sm_mm_1DiagramEditorUtil_CreateDiagramCommandLabel, Collections.EMPTY_LIST) { protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { sm_mm.MappingModel model = createInitialModel(); attachModelToResource(model, modelResource); Diagram diagram = ViewService.createDiagram( model, sm_mm.diagram.edit.parts.MappingModelEditPart.MODEL_ID, sm_mm.diagram.part.Sm_mm_1DiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); if (diagram != null) { diagramResource.getContents().add(diagram); diagram.setName(diagramName); diagram.setElement(model); } try { modelResource.save(sm_mm.diagram.part.Sm_mm_1DiagramEditorUtil.getSaveOptions()); diagramResource.save(sm_mm.diagram.part.Sm_mm_1DiagramEditorUtil.getSaveOptions()); } catch (IOException e) { sm_mm.diagram.part.Sm_mm_1DiagramEditorPlugin.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) { sm_mm.diagram.part.Sm_mm_1DiagramEditorPlugin.getInstance() .logError("Unable to create model and diagram", e); // $NON-NLS-1$ } setCharset(WorkspaceSynchronizer.getFile(modelResource)); setCharset(WorkspaceSynchronizer.getFile(diagramResource)); return diagramResource; }
/** * Runs the wizard in a dialog. * * @generated */ public static void runWizard(Shell shell, Wizard wizard, String settingsKey) { IDialogSettings pluginDialogSettings = sm_mm.diagram.part.Sm_mm_1DiagramEditorPlugin.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(); }