protected void createNewODProject() { final IWizardDescriptor descriptor = WizardFinder.findNewWizardDescriptor( "org.gemoc.xdsmlframework.extensions.sirius.wizards.NewGemocSiriusProjectWizard"); // Then if we have a wizard, open it. if (descriptor != null) { NewProjectWorkspaceListener workspaceListener = new NewProjectWorkspaceListener(); ResourcesPlugin.getWorkspace().addResourceChangeListener(workspaceListener); try { IWorkbenchWizard wizard; wizard = descriptor.createWizard(); ((NewGemocSiriusProjectWizard) wizard) .setInitialProjectName(XDSMLProjectHelper.baseProjectName(gemocLanguageIProject)); IWorkbench workbench = PlatformUI.getWorkbench(); wizard.init(workbench, null); WizardDialog wd = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard); wd.create(); wd.setTitle(wizard.getWindowTitle()); int res = wd.open(); if (res == WizardDialog.OK) { ResourcesPlugin.getWorkspace().removeResourceChangeListener(workspaceListener); createdProject = workspaceListener.getLastCreatedProject(); // update the project configuration model if (createdProject != null) { SiriusEditorProject editorProject = Xdsml_baseFactoryImpl.eINSTANCE.createSiriusEditorProject(); editorProject.setProjectName(createdProject.getName()); addOrUpdateProjectToConf(editorProject); } else { Activator.error("not able to detect which project was created by wizard", null); } } } catch (CoreException e) { Activator.error(e.getMessage(), e); } finally { ResourcesPlugin.getWorkspace().removeResourceChangeListener(workspaceListener); } } else { Activator.error( "wizard with id=org.eclipse.sirius.ui.specificationproject.wizard not found", null); } }
protected void createNewXTextProject() { /* * MessageDialog.openWarning( * PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), * "Gemoc Language Workbench UI", * "Action not completly implemented yet"); */ // create xtext project from existing ecore model // wizard id = // org.eclipse.xtext.xtext.ui.wizard.ecore2xtext.NewXtextProjectFromEcoreWizard // launch the appropriate wizard IWizardDescriptor descriptor = WizardFinder.findNewWizardDescriptor( "org.eclipse.xtext.xtext.ui.wizard.ecore2xtext.NewXtextProjectFromEcoreWizard"); // Then if we have a wizard, open it. if (descriptor != null) { // add a listener to capture the creation of the resulting project NewProjectWorkspaceListener workspaceListener = new NewProjectWorkspaceListener(); ResourcesPlugin.getWorkspace().addResourceChangeListener(workspaceListener); try { IWizard wizard; wizard = descriptor.createWizard(); // this wizard need some dedicated initialization // ((EcoreModelerWizard )wizard).init(PlatformUI.getWorkbench(), // (IStructuredSelection) // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection()); // ((EcoreModelWizard)wizard).init(PlatformUI.getWorkbench(), // (IStructuredSelection) selection); WizardDialog wd = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); wd.create(); wd.setTitle(wizard.getWindowTitle()); int res = wd.open(); if (res == WizardDialog.OK) { ResourcesPlugin.getWorkspace().removeResourceChangeListener(workspaceListener); ArrayList<IProject> newlyCreatedProjects = workspaceListener.getNewlyCreatedProjects(); // find the created project with xtext files in it FileFinderVisitor fileFinder = new FileFinderVisitor("xtext"); for (Iterator<IProject> iterator = newlyCreatedProjects.iterator(); iterator.hasNext(); ) { IProject iProject = (IProject) iterator.next(); iProject.accept(fileFinder); if (fileFinder.getFile() != null) { createdProject = iProject; break; } } // update the project configuration model if (createdProject != null) { XTextEditorProject editorProject = Xdsml_baseFactoryImpl.eINSTANCE.createXTextEditorProject(); editorProject.setProjectName(createdProject.getName()); addOrUpdateProjectToConf(editorProject); } else { Activator.error("not able to detect which project was created by wizard", null); } } } catch (CoreException e) { Activator.error(e.getMessage(), e); } finally { // make sure to remove listener in all situations ResourcesPlugin.getWorkspace().removeResourceChangeListener(workspaceListener); } } else { Activator.error( "wizard with id=org.eclipse.xtext.xtext.ui.wizard.ecore2xtext.NewXtextProjectFromEcoreWizard not found", null); } }