public String getXtextPath() { if (createdProject != null) { FileFinderVisitor odesignProjectVisitor = new FileFinderVisitor("xtext"); try { createdProject.accept(odesignProjectVisitor); IFile odesignIFile = odesignProjectVisitor.getFile(); if (odesignIFile != null) { return "/" + createdProject.getName() + "/" + odesignIFile.getProjectRelativePath().toString(); } } catch (CoreException e) { Activator.error(e.getMessage(), e); } } return ""; }
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); } }