/* * (non-Javadoc) * * @see org.eclipse.jface.wizard.Wizard#performFinish() */ @Override public boolean performFinish() { final String packageName = page.getPackageName(); /* make sure the package does exist */ if (packageName.length() > 0) { WorkspaceModifyOperation createPkg = new NewPackageCreationOperation(page.getSourceFolder(), packageName); try { createPkg.run(null); } catch (InvocationTargetException e) { e.printStackTrace(); return false; } catch (InterruptedException e) { e.printStackTrace(); return false; } } WorkspaceModifyOperation modifyOp = new NewFragmentCreationOperation( page.getSourceFolder(), packageName, page.getTypeName(), page.getFragmentKind()); try { this.getContainer().run(false, false, modifyOp); } catch (InvocationTargetException e) { e.printStackTrace(); return false; } catch (InterruptedException e) { e.printStackTrace(); return false; } return true; }
public void addPages() { page = new NewModelicaFragmentWizardPage("New Modelica class"); addPage(page); ISelection sel = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection(); IModelicaResource modelicaResource = EModelicaPlugin.extractSelectionModelicaResource(sel); IResource resource = EModelicaPlugin.extractSelectionResource(sel); /* walk up tree */ while (modelicaResource != null) { if (modelicaResource instanceof IModelicaPackage) { page.setPkg((IModelicaPackage) modelicaResource); } if (modelicaResource instanceof IMosilabSource) { page.setSourceDir((IMosilabSource) modelicaResource); } modelicaResource = modelicaResource.getParent(); } if (resource != null) { IProject prj = resource.getProject(); IMosilabProject project = EModelicaPlugin.getDefault().getProjectManager().getMosilabProject(prj); if (project != null && project.getSrcFolders().size() > 0 && (page.getDefaultSrc() == null)) page.setSourceDir(project.getSrcFolders().get(0)); } page.setKind("class"); }