/** * Returns the label for the specified type name. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ protected String getLabel(String typeName) { try { return SELEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); } catch (MissingResourceException mre) { SELEditorPlugin.INSTANCE.log(mre); } return typeName; }
/** * Do the work after everything is specified. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ @Override public boolean performFinish() { try { // Remember the file. // final IFile modelFile = getModelFile(); // Do the work within an operation. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor progressMonitor) { try { // Create a resource set // ResourceSet resourceSet = new ResourceSetImpl(); // Get the URI of the model file. // URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true); // Create a resource for this file. // Resource resource = resourceSet.createResource(fileURI); // Add the initial model object to the contents. // EObject rootObject = createInitialModel(); if (rootObject != null) { resource.getContents().add(rootObject); } // Save the contents of the resource to the file system. // Map<Object, Object> options = new HashMap<Object, Object>(); options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding()); resource.save(options); } catch (Exception exception) { SELEditorPlugin.INSTANCE.log(exception); } finally { progressMonitor.done(); } } }; getContainer().run(false, false, operation); // Select the new file resource in the current view. // IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = workbenchWindow.getActivePage(); final IWorkbenchPart activePart = page.getActivePart(); if (activePart instanceof ISetSelectionTarget) { final ISelection targetSelection = new StructuredSelection(modelFile); getShell() .getDisplay() .asyncExec( new Runnable() { public void run() { ((ISetSelectionTarget) activePart).selectReveal(targetSelection); } }); } // Open an editor on the new file. // try { page.openEditor( new FileEditorInput(modelFile), workbench .getEditorRegistry() .getDefaultEditor(modelFile.getFullPath().toString()) .getId()); } catch (PartInitException exception) { MessageDialog.openError( workbenchWindow.getShell(), SELEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); return false; } return true; } catch (Exception exception) { SELEditorPlugin.INSTANCE.log(exception); return false; } }