protected void selectExistingSiriusProject() { // launch the appropriate wizard // TODO filter only projects related to the current domain model SelectAnyIProjectDialog dialog = new SelectODesignIProjectDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); int res = dialog.open(); if (res == WizardDialog.OK) { // update the project model String projectName = ((IResource) dialog.getResult()[0]).getName(); EditorProject editorProject = Xdsml_baseFactoryImpl.eINSTANCE.createSiriusEditorProject(); editorProject.setProjectName(projectName); // TODO detection of the current extension addOrUpdateProjectToConf(editorProject); } }
/** * if an editor of the same concrete kind exist, then the new one will replace it Ie. only one * Sirius editor, one XtextEditor, etc * * @param editorProject */ protected void addOrUpdateProjectToConf( EditorProject editorProject, LanguageDefinition language) { // add missing data to conf EditorProject existingEditor = null; String searchedClass = editorProject.getClass().getName(); // search first existing editor for (EditorProject possibleExistingEditor : language.getEditorProjects()) { if (possibleExistingEditor.getClass().getName().equals(searchedClass)) { existingEditor = possibleExistingEditor; break; } } if (existingEditor == null) { // simply add the new editor language.getEditorProjects().add(editorProject); } else { // replace the existing editor int index = language.getEditorProjects().indexOf(existingEditor); language.getEditorProjects().set(index, editorProject); } }