Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-02-16 09:03:54 -0500
committerGerrit Code Review @ Eclipse.org2015-02-16 09:03:55 -0500
commit006c9ad85a638f94bfdaa3e3c865b61c5c49ccbc (patch)
tree24b69328a4b12be830f9db714c5a663b5ba516cd
parentafc8d2893584cef98d649d1ed7b9acb5b413248a (diff)
parent6c3409c8a82fa7c1893c92bcafdcbd62705ee1eb (diff)
downloadorg.eclipse.papyrus-006c9ad85a638f94bfdaa3e3c865b61c5c49ccbc.tar.gz
org.eclipse.papyrus-006c9ad85a638f94bfdaa3e3c865b61c5c49ccbc.tar.xz
org.eclipse.papyrus-006c9ad85a638f94bfdaa3e3c865b61c5c49ccbc.zip
Merge "Bug 455015: [Model Import - Wizard] Files outside the workspace cannot be imported directly https://bugs.eclipse.org/bugs/show_bug.cgi?id=455015 - added a selection window and a project creation behavior when the selected files are not in a project - refactored the code to allow reuse of the composites - corrected an unwanted behavior when selecting inside the workspace" into streams/1.0-maintenance
-rwxr-xr-xextraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/constants/TransformationWizardConstants.java11
-rwxr-xr-xextraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/Messages.java2
-rwxr-xr-xextraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/messages.properties2
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/utils/CreateFile.java161
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/utils/CreateProject.java132
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/TransformationWizard.java59
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ConfigurationComposite.java305
-rwxr-xr-xextraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogData.java102
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogDataConfigComposite.java200
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogDataTreeComposite.java335
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ImportConfigComposite.java196
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ImportTreeComposite.java540
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/SelectionTreeComposite.java396
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationConfigPage.java6
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationSelectionPage.java3
15 files changed, 1719 insertions, 731 deletions
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/constants/TransformationWizardConstants.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/constants/TransformationWizardConstants.java
index 3318463516a..958d80d5306 100755
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/constants/TransformationWizardConstants.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/constants/TransformationWizardConstants.java
@@ -33,6 +33,15 @@ public interface TransformationWizardConstants {
/**
* The key to retrieve the selection preferences from the settings file
*/
- public static final String SELECTION_KEY = "selectionPeferences"; //$NON-NLS-1$
+ public static final String WIZARD_SELECTION_KEY = "selectionPeferences"; //$NON-NLS-1$
+
+ public static final String FILEDIALOG_SELECTION_KEY = "previousDialogSelection"; //$NON-NLS-1$
+
+ /**
+ * The name of the newly created project's folders
+ */
+ public static final String SRC_FOLDER = "src"; //$NON-NLS-1$
+
+ public static final String RSC_FOLDER = "resources"; //$NON-NLS-1$
}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/Messages.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/Messages.java
index 95b7da17960..8f45fffe7df 100755
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/Messages.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/Messages.java
@@ -23,11 +23,13 @@ public class Messages extends NLS {
public static String TransformationSelectionPage_Name;
public static String TransformationSelectionPage_Title;
public static String TransformationSelectionPage_Description;
+ public static String FileDialogTitle;
public static String TransformationConfigPage_Name;
public static String TransformationConfigPage_Title;
public static String TransformationConfigPage_Description;
public static String Button_SelectAll;
public static String Button_DeselectAll;
+ public static String Button_FileSystemSelection;
public static String MultipleStringFileEditor_2;
public static String WrongFileType;
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/messages.properties b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/messages.properties
index 21135fe6cae..17b3de25719 100755
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/messages.properties
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/messages.properties
@@ -15,10 +15,12 @@ TransformationWizard_Title=RSA transformation wizard
TransformationSelectionPage_Name=Workspace selection
TransformationSelectionPage_Title=Select a scope for the transformation
TransformationSelectionPage_Description=Select the folders or files for the transformation
+FileDialogTitle=Select the files to import
TransformationConfigPage_Name=Parameters selection
TransformationConfigPage_Title=Define the transformation parameters
TransformationConfigPage_Description=Select the files and the configuration options for the transformation
Button_SelectAll=Select All
Button_DeselectAll=Deselect All
+Button_FileSystemSelection=File System Selection
MultipleStringFileEditor_2=FilterExtensions and FilterNames do not match
WrongFileType=Not an IFile, wrong type to transform
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/utils/CreateFile.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/utils/CreateFile.java
new file mode 100644
index 00000000000..1cb5f9fa650
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/utils/CreateFile.java
@@ -0,0 +1,161 @@
+package org.eclipse.papyrus.migration.rsa.utils;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+public class CreateFile {
+
+ public static IFile createFile(String filePath, IContainer container, String content)
+ throws Exception
+ {
+ IFile file = null;
+ if ((container instanceof IProject)) {
+ file = ((IProject) container).getFile(filePath);
+ } else if ((container instanceof IFolder)) {
+ file = ((IFolder) container).getFile(filePath);
+ } else {
+ throw new Exception("Cannot find the file " +
+ filePath +
+ " under " +
+ container.getName());
+ }
+ IContainer parent = file.getParent();
+ if ((parent instanceof IFolder)) {
+ mkdirs((IFolder) parent);
+ }
+ InputStream stream = new ByteArrayInputStream(content.getBytes(file.getCharset()));
+ if (file.exists()) {
+ file.setContents(stream, true, true, null);
+ } else {
+ file.create(stream, true, null);
+ }
+ stream.close();
+
+ return file;
+ }
+
+ public static void mkdirs(IFolder folder)
+ throws CoreException
+ {
+ if (!folder.exists())
+ {
+ if ((folder.getParent() instanceof IFolder)) {
+ mkdirs((IFolder) folder.getParent());
+ }
+ folder.create(true, true, null);
+ }
+ }
+
+ public static String getContents(String relativePath, String resource, Class clazz)
+ throws IOException
+ {
+ String resourcePath = relativePath + '/' + resource;
+ File sourcePrj = getSourceProject(clazz);
+
+
+ JarFile jar = null;
+ InputStream resourceStream;
+ if (sourcePrj.isFile())
+ {
+ jar = new JarFile(sourcePrj);
+ JarEntry resEntry = jar.getJarEntry(resourcePath);
+ resourceStream = jar.getInputStream(resEntry);
+ }
+ else
+ {
+ resourceStream = new FileInputStream(sourcePrj.getAbsolutePath() +
+ "/" +
+ resourcePath);
+ }
+ byte[] buffer = new byte[4096];
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ for (;;)
+ {
+ int read = resourceStream.read(buffer);
+ if (read == -1) {
+ break;
+ }
+ outputStream.write(buffer, 0, read);
+ }
+ outputStream.close();
+ resourceStream.close();
+ if (jar != null) {
+ jar.close();
+ }
+ return outputStream.toString("iso-8859-1");
+ }
+
+ private static File getSourceProject(Class clazz)
+ {
+ ProtectionDomain protectionDomain = clazz.getProtectionDomain();
+ CodeSource codeSource = protectionDomain.getCodeSource();
+ URL location = codeSource.getLocation();
+ File sourcePrj = new File(location.getFile());
+ return sourcePrj;
+ }
+
+ public static void appendContents(IFile pagesFile, String data)
+ throws IOException
+ {
+ File file = pagesFile.getLocation().toFile();
+ if (!file.exists()) {
+ file.createNewFile();
+ }
+ FileWriter fileWriter = new FileWriter(file, true);
+ BufferedWriter buffWriter = new BufferedWriter(fileWriter);
+ PrintWriter writer = new PrintWriter(buffWriter);
+ writer.println(data);
+ writer.close();
+ buffWriter.close();
+ fileWriter.close();
+ }
+
+ public static void replaceContents(IFile file, String template, String newContent)
+ throws CoreException, IOException
+ {
+ String content = getContents(file).replace(template, newContent);
+ InputStream stream = new ByteArrayInputStream(content.getBytes(file.getCharset()));
+ if (file.exists()) {
+ file.setContents(stream, true, true, new NullProgressMonitor());
+ }
+ stream.close();
+ }
+
+ public static String getContents(IFile iFile)
+ throws IOException
+ {
+ File file = iFile.getLocation().toFile();
+ FileInputStream stream = new FileInputStream(file);
+ StringBuffer contents = new StringBuffer();
+ BufferedReader br = new BufferedReader(new InputStreamReader(stream));
+ String line;
+ while ((line = br.readLine()) != null)
+ {
+ contents.append(line).append("\n");
+ }
+ br.close();
+ stream.close();
+ return contents.toString();
+ }
+
+}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/utils/CreateProject.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/utils/CreateProject.java
new file mode 100644
index 00000000000..9ac80857520
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/utils/CreateProject.java
@@ -0,0 +1,132 @@
+package org.eclipse.papyrus.migration.rsa.utils;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.migration.rsa.Activator;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+public class CreateProject {
+
+ protected String projectName;
+
+ protected IProject createdProject;
+
+ protected Collection<Object> inputFiles;
+
+ public CreateProject(Collection<Object> inputFiles) {
+ this.projectName = getProjectName();
+ this.inputFiles = inputFiles;
+
+ if (projectName != null) {
+ try {
+ this.createdProject = createProject();
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+
+
+ protected IProject createProject() throws Exception {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject(projectName);
+
+ if (! project.exists()){
+ project.create(new NullProgressMonitor());
+ }
+
+ if (! project.isOpen()){
+ project.open(new NullProgressMonitor());
+ }
+
+ if (inputFiles != null && !inputFiles.isEmpty()) {
+ // create resource folder
+ createFolder("resources", project, inputFiles);
+ }
+
+ return project;
+ }
+
+ protected void createFolder(String folderName, IProject project, Collection<Object> inputFiles) throws Exception {
+ IFolder folder = project.getFolder(folderName);
+ folder.create(false, true, null);
+
+ List<Object> inputList = new ArrayList<Object>(inputFiles);
+ for (Object object : inputList) {
+ File file = ((File) object);
+ IFile linkedFile = folder.getFile(file.getName());
+ URI fileURI = file.toURI();
+ linkedFile.createLink(fileURI, IResource.NONE, null);
+ }
+
+ }
+
+ protected void createBuildProps(IProject project, List<String> srcFolders) throws Exception {
+ StringBuilder bpContent = new StringBuilder("source.. = ");
+
+ if (srcFolders != null && !srcFolders.isEmpty()) {
+ for (Iterator<String> iterator = srcFolders.iterator(); iterator.hasNext();)
+ {
+ bpContent.append(iterator.next()).append(File.separatorChar);
+ if (iterator.hasNext()) {
+ bpContent.append(",");
+ }
+ }
+ }
+
+ bpContent.append("\n");
+ bpContent.append("bin.includes = META-INF/,.\n");
+ CreateFile.createFile("build.properties", project, bpContent.toString());
+ }
+
+
+ public IProject getCreatedProject() {
+ return this.createdProject;
+ }
+
+ protected String getProjectName() {
+ String init_value = "project_" + System.currentTimeMillis();
+
+ Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+
+ InputDialog dialog = new InputDialog(activeShell, "Create Project", "Provide project name...", init_value, new IInputValidator() {
+ @Override
+ public String isValid(String newText)
+ {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject[] projs = root.getProjects();
+ for (int i = 0; i < projs.length; i++) {
+ if (projs[i].getName().equalsIgnoreCase(newText)) {
+ return "This project already exists";
+ }
+ }
+
+ return null;
+ }
+ });
+
+ if (dialog.open() == Window.CANCEL) {
+ return null;
+ }
+
+ return dialog.getValue();
+ }
+
+}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/TransformationWizard.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/TransformationWizard.java
index 3b2b3e43706..476954d3d45 100644
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/TransformationWizard.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/TransformationWizard.java
@@ -11,23 +11,23 @@
*****************************************************************************/
package org.eclipse.papyrus.migration.rsa.wizard;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.papyrus.migration.rsa.Activator;
import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.Config;
import org.eclipse.papyrus.migration.rsa.messages.Messages;
import org.eclipse.papyrus.migration.rsa.transformation.ImportTransformationLauncher;
import org.eclipse.papyrus.migration.rsa.wizard.pages.TransformationConfigPage;
import org.eclipse.papyrus.migration.rsa.wizard.pages.TransformationSelectionPage;
import org.eclipse.papyrus.migration.rsa.wizard.pages.DialogData;
-import org.eclipse.swt.SWT;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
@@ -64,7 +64,7 @@ public class TransformationWizard extends Wizard implements IImportWizard {
public IWizardPage getNextPage(IWizardPage currentPage) {
if (currentPage == selectionPage) {
this.currentPage = configPage;
- // Reset the viewer input in order to show the newly selected elements from the selectionPage
+ // Resets the viewer input in order to show the newly selected elements from the selectionPage
configPage.resetViewerInput();
return configPage;
}
@@ -82,6 +82,11 @@ public class TransformationWizard extends Wizard implements IImportWizard {
return false;
}
+ @Override
+ public boolean performCancel() {
+ removeWizardImportedProjects();
+ return super.performCancel();
+ }
@Override
public boolean performFinish() {
@@ -89,11 +94,34 @@ public class TransformationWizard extends Wizard implements IImportWizard {
dialogData.setSelectionMap();
importFiles();
+ // Remove the imported projects from the workspace
+ // removeWizardImportedProjects();
+
return true;
}
/**
+ *
+ * Remove any imported projects, through the wizard, from the workspace
+ *
+ */
+ public void removeWizardImportedProjects() {
+ if (/* dialogData != null && */dialogData.getImportedProjects() != null) {
+ for (Object object : dialogData.getImportedProjects()) {
+ if (object instanceof IProject) {
+ IProject project = (IProject) object;
+ try {
+ project.delete(false, true, null);
+ } catch (CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+ }
+ }
+
+ /**
*
* Launch the transformation with the previously selected files and configuration parameters
*
@@ -104,19 +132,17 @@ public class TransformationWizard extends Wizard implements IImportWizard {
return;
}
- Set<IFile> selectedFiles = new HashSet<IFile>();
- for (Object file : dialogData.getTransformationFiles()) {
- if (file instanceof IFile) {
- selectedFiles.add((IFile) file);
- }
- }
-
List<URI> urisToImport = new LinkedList<URI>();
- for (IFile selectedFile : selectedFiles) {
- URI uri = URI.createPlatformResourceURI(selectedFile.getFullPath().toString(), true);
-
- urisToImport.add(uri);
+ for (Object selectedFile : dialogData.getTransformationFiles()) {
+ String path = null;
+ if (selectedFile instanceof IFile) {
+ path = ((IFile) selectedFile).getFullPath().toString();
+ }
+ if (path != null) {
+ URI uri = URI.createPlatformResourceURI(path, true);
+ urisToImport.add(uri);
+ }
}
// The wizard's Shell will be disposed because the transformation is asynchronous. Use the Shell's parent instead
@@ -126,8 +152,7 @@ public class TransformationWizard extends Wizard implements IImportWizard {
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- // TODO Auto-generated method stub
-
+ // nothing
}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ConfigurationComposite.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ConfigurationComposite.java
deleted file mode 100644
index cfb3d1104fd..00000000000
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ConfigurationComposite.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.migration.rsa.wizard.pages;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.papyrus.infra.widgets.util.FileUtil;
-import org.eclipse.papyrus.migration.rsa.messages.Messages;
-import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.Config;
-import org.eclipse.papyrus.views.properties.runtime.DisplayEngine;
-import org.eclipse.papyrus.views.properties.util.PropertiesDisplayHelper;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-/**
- *
- * Actual composite used to display the previously selected elements and the migration options
- *
- * @author Quentin Le Menez
- *
- */
-public class ConfigurationComposite extends Composite {
-
- protected Config config;
-
- protected Collection<Object> transformationFiles;
-
- protected CheckboxTableViewer listViewer;
-
- protected ISelectionChangedListener listListener;
-
- protected DisplayEngine displayEngine;
-
- protected SelectionListener buttonListener;
-
- protected Button selectAll;
-
- protected Button deselectAll;
-
- protected DialogData dialogData;
-
- protected Collection<Object> uncheckedFiles;
-
- /**
- *
- * Constructor.
- *
- * @param parent
- * The parent composite
- * @param style
- * The swt style used for this ConfigurationComposite
- * @param config
- * The configuration used to display the transformation options
- */
- public ConfigurationComposite(Composite parent, int style, Config config) {
- super(parent, style);
- this.setLayout(new GridLayout(1, false));
- this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- this.config = config;
-
- Composite filesComposite = new Composite(this, SWT.BORDER);
- filesComposite.setLayout(new FillLayout());
- filesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- Composite configComposite = new Composite(this, SWT.BORDER);
- configComposite.setLayout(new FillLayout());
- configComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
-
- createFilesComposite(filesComposite);
-
- createParamComposite(configComposite);
- }
-
- /**
- *
- * Constructor used when a DialogData class is employed to store the different informations of the dialog
- *
- * @param parent
- * The parent composite
- * @param style
- * The swt style used for this ConfigurationComposite
- * @param dialogData
- * The DialogData in which is stored all the necessary informations
- */
- public ConfigurationComposite(Composite parent, int style, DialogData dialogData) {
- this(parent, style, dialogData.getConfig());
- this.dialogData = dialogData;
- this.setViewerInput(dialogData.getSelectedFiles());
- }
-
-
- /**
- *
- * Fills the selection area with all the files selected previously
- *
- * @param parent
- * @param selectedFiles
- */
- protected void createFilesComposite(Composite parent) {
- Composite listComposite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout(2, false);
- listComposite.setLayout(gridLayout);
-
- listViewer = CheckboxTableViewer.newCheckList(listComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- GridData viewerGrid = new GridData(SWT.FILL, SWT.FILL, true, true);
- listViewer.getTable().setLayoutData(viewerGrid);
-
- listViewer.setLabelProvider(new WorkbenchLabelProvider() {
- @Override
- protected String decorateText(String input, Object element) {
- // there should only be IFiles in the received list
- if (element instanceof IFile) {
- return FileUtil.getPath((IFile) element, true);
- } else {
- return Messages.WrongFileType;
- }
- }
- });
-
- listViewer.setContentProvider(new ArrayContentProvider());
-
- listListener = new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- transformationFiles = new LinkedList<Object>(Arrays.asList(listViewer.getCheckedElements()));
- setUncheckedFiles();
-
- if (dialogData != null) {
- dialogData.setTransformationFiles(transformationFiles);
- dialogData.setUncheckedFiles(uncheckedFiles);
- }
- }
- };
-
- listViewer.addSelectionChangedListener(listListener);
-
- setTransformationFiles();
-
- createSelectionButtons(listComposite);
-
- }
-
- public CheckboxTableViewer getCheckboxTreeViewer() {
- return listViewer;
- }
-
- /**
- *
- * Used to update the display from a changed selection in the ConfigPage
- *
- * @param selectedFiles
- */
- public void setViewerInput(Collection<Object> selectedFiles) {
- listViewer.setInput(selectedFiles);
-
- if (dialogData != null) {
- if (dialogData.getUnSelectionArray() == null) {
- // Default selection when opening the viewer without previous executions
- listViewer.setAllChecked(true);
- }
- else {
- // Recall the last unselected files to update the display
- Collection<String> previousUnSelection = Arrays.asList(dialogData.getUnSelectionArray());
- for (Object object : selectedFiles) {
- if (object instanceof IFile) {
- IFile file = (IFile) object;
- String filePath = FileUtil.getPath(file, true);
- if (previousUnSelection.contains(filePath)) {
- listViewer.setChecked(object, false);
- }
- else {
- listViewer.setChecked(object, true);
- }
- }
- }
- }
-
- setTransformationFiles();
- setUncheckedFiles();
-
- dialogData.setTransformationFiles(transformationFiles);
- dialogData.setUncheckedFiles(uncheckedFiles);
- }
- }
-
- /**
- *
- * Fills the composite with the selection buttons
- *
- * @param parent
- * The parent composite
- */
- public void createSelectionButtons(Composite parent) {
- Composite buttonsComposite = new Composite(parent, SWT.NONE);
- buttonsComposite.setLayout(new GridLayout());
-
- buttonListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- listViewer.setAllChecked((Boolean) ((Button) event.widget).getData());
- setTransformationFiles();
- setUncheckedFiles();
-
- if (dialogData != null) {
- dialogData.setTransformationFiles(transformationFiles);
- dialogData.setUncheckedFiles(uncheckedFiles);
- }
- }
- };
-
- selectAll = new Button(buttonsComposite, SWT.PUSH);
- selectAll.setData(true);
- selectAll.setText(Messages.Button_SelectAll);
- selectAll.addSelectionListener(buttonListener);
- selectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
-
- deselectAll = new Button(buttonsComposite, SWT.PUSH);
- deselectAll.setData(false);
- deselectAll.setText(Messages.Button_DeselectAll);
- deselectAll.addSelectionListener(buttonListener);
- deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
-
- }
-
- /**
- *
- * Updates the list of files to be transformed
- *
- */
- public void setTransformationFiles() {
- transformationFiles = new LinkedList<Object>(Arrays.asList(listViewer.getCheckedElements()));
- }
-
- public void setUncheckedFiles() {
- if (dialogData != null) {
- uncheckedFiles = new LinkedList<Object>();
- for (Object object : dialogData.getSelectedFiles()) {
- if (!transformationFiles.contains(object)) {
- uncheckedFiles.add(object);
- }
- }
- dialogData.setUncheckedFiles(uncheckedFiles);
- }
- }
-
-
- /**
- *
- * Fills the composite with the configuration parameters
- *
- * @param parent
- * The parent composite
- */
- public void createParamComposite(Composite parent) {
- displayEngine = PropertiesDisplayHelper.display(config, parent);
- }
-
- public Collection<Object> getTransformationFiles() {
- return transformationFiles;
- }
-
- public Config getConfig() {
- return config;
- }
-
- @Override
- public void dispose() {
- if (displayEngine != null) {
- displayEngine.dispose();
- }
- if (buttonListener != null) {
- selectAll.removeSelectionListener(buttonListener);
- deselectAll.removeSelectionListener(buttonListener);
- }
- if (listListener != null) {
- listViewer.removeSelectionChangedListener(listListener);
- }
- super.dispose();
- }
-
-}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogData.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogData.java
index 1f9e9a79145..acef3d78fef 100755
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogData.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogData.java
@@ -11,6 +11,7 @@
*****************************************************************************/
package org.eclipse.papyrus.migration.rsa.wizard.pages;
+import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
@@ -34,16 +35,20 @@ public class DialogData {
protected Collection<Object> selectedFiles;
+ protected Collection<Object> systemSelectedFiles;
+
protected Collection<Object> transformationFiles;
protected Config config = RSAToPapyrusParametersFactory.eINSTANCE.createConfig();
protected Collection<String> unselectedFiles;
- protected IDialogSettings dialogSection;
+ public IDialogSettings dialogSection;
protected Collection<Object> uncheckedFiles;
+ protected Collection<Object> importedProjects;
+
/**
*
* Constructor, instantiate the configuration file to store the user's selections, if none exist, or retrieve it
@@ -55,6 +60,8 @@ public class DialogData {
if (dialogSection == null) {
dialogSection = Activator.getDefault().getDialogSettings().addNewSection(TransformationWizardConstants.TRANSFORMATION_WIZARD_SETTINGS);
}
+
+ systemSelectedFiles = new LinkedList<Object>();
}
/**
@@ -68,6 +75,20 @@ public class DialogData {
/**
*
+ * @param selectedFiles
+ * The selected files outside of the workspace to be displayed in the transformation page
+ */
+ public void setSystemSelectedFiles(Collection<String> systemPaths) {
+ for (String filePath : systemPaths) {
+ File file = new File(filePath);
+ if (file != null && !systemSelectedFiles.contains(file)) {
+ systemSelectedFiles.add(file);
+ }
+ }
+ }
+
+ /**
+ *
* @param transformationFiles
* The selected files in the configuration page to be transformed
*/
@@ -105,6 +126,39 @@ public class DialogData {
/**
*
* @return
+ * The selected files outside of the workspace
+ */
+ public Collection<Object> getSystemSelectedFiles() {
+ return systemSelectedFiles;
+ }
+
+ /**
+ *
+ * @return
+ * The selected files from both workspace and outside selections
+ */
+ public Collection<Object> getAllSelectedFiles() {
+ Collection<Object> allSelectedFiles = new LinkedList<Object>();
+ if (selectedFiles != null && selectedFiles.size() > 0) {
+ // TODO select only the files that are not already present in the selection done outside of the workspace
+ // Test
+ // for (Object object : selectedFiles) {
+ // if (!systemSelectedFiles.contains(object)) {
+ // allSelectedFiles.add(object);
+ // }
+ // }
+ // endTest
+ allSelectedFiles.addAll(selectedFiles);
+ }
+ // if (systemSelectedFiles != null && systemSelectedFiles.size() > 0) {
+ // allSelectedFiles.addAll(systemSelectedFiles);
+ // }
+ return allSelectedFiles;
+ }
+
+ /**
+ *
+ * @return
* The parameters used for the transformation
*/
public Config getConfig() {
@@ -131,6 +185,26 @@ public class DialogData {
/**
*
+ * Sets or updates the projects to be imported in the workspace
+ *
+ * @param importedProjects
+ * The selcted projects
+ */
+ public void setImportedProjects(Collection<Object> importedProjects) {
+ this.importedProjects = importedProjects;
+ }
+
+ /**
+ *
+ * @return
+ * The imported projects
+ */
+ public Collection<Object> getImportedProjects() {
+ return this.importedProjects;
+ }
+
+ /**
+ *
* Update or create the selection map stored inside the configuration file in order to remember the previous selection choices
*
*/
@@ -145,8 +219,15 @@ public class DialogData {
// Updates the unselected files for future references
for (Object object : uncheckedFiles) {
if (object instanceof IFile) {
- IFile file = (IFile) object;
- String filePath = FileUtil.getPath(file, true);
+ IFile ifile = (IFile) object;
+ String ifilePath = FileUtil.getPath(ifile, true);
+ if (!unselectedFiles.contains(ifilePath)) {
+ unselectedFiles.add(ifilePath);
+ }
+ }
+ if (object instanceof File) {
+ File file = (File) object;
+ String filePath = file.getAbsolutePath();
if (!unselectedFiles.contains(filePath)) {
unselectedFiles.add(filePath);
}
@@ -155,8 +236,15 @@ public class DialogData {
// Remove any newly selected files from the unselected files pool
for (Object object : transformationFiles) {
if (object instanceof IFile) {
- IFile file = (IFile) object;
- String filePath = FileUtil.getPath(file, true);
+ IFile ifile = (IFile) object;
+ String ifilePath = FileUtil.getPath(ifile, true);
+ if (unselectedFiles.contains(ifilePath)) {
+ unselectedFiles.remove(ifilePath);
+ }
+ }
+ if (object instanceof File) {
+ File file = (File) object;
+ String filePath = file.getAbsolutePath();
if (unselectedFiles.contains(filePath)) {
unselectedFiles.remove(filePath);
}
@@ -164,7 +252,7 @@ public class DialogData {
}
// Update the map
- dialogSection.put(TransformationWizardConstants.SELECTION_KEY, unselectedFiles.toArray(new String[unselectedFiles.size()]));
+ dialogSection.put(TransformationWizardConstants.WIZARD_SELECTION_KEY, unselectedFiles.toArray(new String[unselectedFiles.size()]));
}
/**
@@ -175,7 +263,7 @@ public class DialogData {
* The user's previously unchecked files in the configPage
*/
public String[] getUnSelectionArray() {
- return dialogSection.getArray(TransformationWizardConstants.SELECTION_KEY);
+ return dialogSection.getArray(TransformationWizardConstants.WIZARD_SELECTION_KEY);
}
}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogDataConfigComposite.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogDataConfigComposite.java
new file mode 100644
index 00000000000..57e4e13d068
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogDataConfigComposite.java
@@ -0,0 +1,200 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.migration.rsa.wizard.pages;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.papyrus.infra.widgets.util.FileUtil;
+import org.eclipse.papyrus.migration.rsa.messages.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ *
+ * Actual composite used to display the previously selected elements and the migration options
+ *
+ * @author Quentin Le Menez
+ *
+ */
+public class DialogDataConfigComposite extends ImportConfigComposite {
+
+ protected DialogData dialogData;
+
+ protected SelectionListener buttonListener;
+
+ protected Button selectAll;
+
+ protected Button deselectAll;
+
+ /**
+ *
+ * Constructor used when a DialogData class is employed to store the different informations of the dialog
+ *
+ * @param parent
+ * The parent composite
+ * @param style
+ * The swt style used for this ConfigurationComposite
+ * @param dialogData
+ * The DialogData in which is stored all the necessary informations
+ */
+ public DialogDataConfigComposite(Composite parent, int style, DialogData dialogData) {
+ super(parent, style, dialogData.getConfig());
+ this.dialogData = dialogData;
+ this.setViewerInput(dialogData.getSelectedFiles());
+ }
+
+
+ /**
+ *
+ * Fills the composite with the selection buttons
+ *
+ * @param parent
+ * The parent composite
+ */
+ @Override
+ protected void createSelectionButtons(Composite parent) {
+ Composite buttonsComposite = new Composite(parent, SWT.NONE);
+ buttonsComposite.setLayout(new GridLayout());
+
+ buttonListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ fireButtonSelectionEvent(event);
+ }
+ };
+
+ selectAll = new Button(buttonsComposite, SWT.PUSH);
+ selectAll.setData(true);
+ selectAll.setText(Messages.Button_SelectAll);
+ selectAll.addSelectionListener(buttonListener);
+ selectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+
+ deselectAll = new Button(buttonsComposite, SWT.PUSH);
+ deselectAll.setData(false);
+ deselectAll.setText(Messages.Button_DeselectAll);
+ deselectAll.addSelectionListener(buttonListener);
+ deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+
+ }
+
+ /**
+ *
+ * Handles the selections inside the tableViewer
+ *
+ * @param event
+ * The event linked to the tableViewer's selection buttons
+ */
+ protected void fireButtonSelectionEvent(SelectionEvent event) {
+ listViewer.setAllChecked((Boolean) ((Button) event.widget).getData());
+ setTransformationFiles();
+ setUncheckedFiles();
+
+ if (dialogData != null) {
+ dialogData.setTransformationFiles(transformationFiles);
+ dialogData.setUncheckedFiles(uncheckedFiles);
+ }
+ }
+
+ @Override
+ protected void fireSelectionEvent(SelectionChangedEvent event) {
+ transformationFiles = new LinkedList<Object>(Arrays.asList(listViewer.getCheckedElements()));
+ setUncheckedFiles();
+
+ if (dialogData != null) {
+ dialogData.setTransformationFiles(transformationFiles);
+ dialogData.setUncheckedFiles(uncheckedFiles);
+ }
+ }
+
+ @Override
+ public void setViewerInput(Collection<Object> selectedFiles) {
+ listViewer.setInput(selectedFiles);
+
+ if (dialogData != null) {
+ if (dialogData.getUnSelectionArray() == null) {
+ // Default selection when opening the viewer without previous executions
+ listViewer.setAllChecked(true);
+ }
+ else {
+ // Recall the last unselected files to update the display
+ Collection<String> previousUnSelection = Arrays.asList(dialogData.getUnSelectionArray());
+ for (Object object : selectedFiles) {
+ if (object instanceof IFile) {
+ IFile ifile = (IFile) object;
+ String ifilePath = FileUtil.getPath(ifile, true);
+ if (previousUnSelection.contains(ifilePath)) {
+ listViewer.setChecked(object, false);
+ }
+ else {
+ listViewer.setChecked(object, true);
+ }
+ }
+ else if (object instanceof File) {
+ File file = (File) object;
+ String filePath = file.getAbsolutePath();
+ if (previousUnSelection.contains(filePath)) {
+ listViewer.setChecked(object, false);
+ }
+ else {
+ listViewer.setChecked(object, true);
+ }
+ }
+ }
+ }
+
+ setTransformationFiles();
+ setUncheckedFiles();
+
+ dialogData.setTransformationFiles(transformationFiles);
+ dialogData.setUncheckedFiles(uncheckedFiles);
+ }
+ }
+
+ /**
+ *
+ * Updates the unchecked files in the wizard's dialog settings to remember the last selection when reopening the wizard
+ *
+ */
+ protected void setUncheckedFiles() {
+ if (dialogData != null) {
+ uncheckedFiles = new LinkedList<Object>();
+ for (Object object : dialogData.getAllSelectedFiles()) {
+ if (!transformationFiles.contains(object)) {
+ uncheckedFiles.add(object);
+ }
+ }
+ dialogData.setUncheckedFiles(uncheckedFiles);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ if (buttonListener != null) {
+ selectAll.removeSelectionListener(buttonListener);
+ deselectAll.removeSelectionListener(buttonListener);
+ }
+
+ super.dispose();
+ }
+
+}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogDataTreeComposite.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogDataTreeComposite.java
new file mode 100644
index 00000000000..96950569dbf
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogDataTreeComposite.java
@@ -0,0 +1,335 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.migration.rsa.wizard.pages;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.widgets.util.FileUtil;
+import org.eclipse.papyrus.migration.rsa.Activator;
+import org.eclipse.papyrus.migration.rsa.constants.TransformationWizardConstants;
+import org.eclipse.papyrus.migration.rsa.messages.Messages;
+import org.eclipse.papyrus.migration.rsa.utils.CreateProject;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+
+
+/**
+ *
+ * Actual composite used to display the workspace and select the wanted elements
+ *
+ * @author Quentin Le Menez
+ *
+ */
+public class DialogDataTreeComposite extends ImportTreeComposite {
+
+ protected DialogData dialogData;
+
+ protected String systemDialogFiles;
+
+ protected SelectionListener selectionButtonListener;
+
+ protected SelectionListener systemSelectionListener;
+
+ protected Button selectAllButton;
+
+ protected Button deselectAllButton;
+
+ protected Button systemSelectionButton;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * The parent composite
+ * @param style
+ * The swt style used for this ConfigurationComposite
+ * @param dialogData
+ * The DialogData in which is stored all the necessary informations
+ */
+ public DialogDataTreeComposite(Composite parent, int style, DialogData dialogData) {
+ super(parent, style, dialogData.getExtensions(), dialogData.getExtensionsNames());
+
+ this.dialogData = dialogData;
+
+ ISelection treeSelection = treeViewer.getSelection();
+ if (treeSelection instanceof StructuredSelection) {
+ setSelectedFiles(((StructuredSelection) treeSelection).toArray());
+ this.dialogData.setSelectedFiles(getSelectedFiles());
+ }
+ }
+
+
+ @Override
+ protected void fireTreeSelectionEvent(SelectionChangedEvent event) {
+ ISelection selection = event.getSelection();
+
+ if (selection instanceof IStructuredSelection) {
+ // Updates the selected files
+ selectedFiles.clear();
+ IStructuredSelection sSelection = (IStructuredSelection) selection;
+ setSelectedFiles(sSelection.toArray());
+
+ if (dialogData != null) {
+ dialogData.setSelectedFiles(selectedFiles);
+ }
+ }
+
+ }
+
+ @Override
+ protected void createSelectionButtons(Composite parent) {
+ // The composite will contain three buttons, two general selection (all and none) and one for selections using a fileDialog window
+ selectionButtonsComposite = new Composite(parent, SWT.NONE);
+ selectionButtonsComposite.setLayout(new GridLayout());
+
+ systemSelectionListener = new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ fireSystemBrowseEvent(event);
+ }
+ };
+
+ systemSelectionButton = new Button(selectionButtonsComposite, SWT.PUSH);
+ systemSelectionButton.setText(Messages.Button_FileSystemSelection);
+ systemSelectionButton.addSelectionListener(systemSelectionListener);
+ systemSelectionButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+
+
+ selectionButtonListener = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ fireButtonSelectionEvent(event);
+ }
+ };
+
+ selectAllButton = new Button(selectionButtonsComposite, SWT.PUSH);
+ selectAllButton.setText(Messages.Button_SelectAll);
+ selectAllButton.setData(true);
+ selectAllButton.addSelectionListener(selectionButtonListener);
+ selectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+
+ deselectAllButton = new Button(selectionButtonsComposite, SWT.PUSH);
+ deselectAllButton.setText(Messages.Button_DeselectAll);
+ deselectAllButton.setData(false);
+ deselectAllButton.addSelectionListener(selectionButtonListener);
+ deselectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ }
+
+
+ /**
+ *
+ * Handles the selectAll/deselectAll options
+ *
+ * @param event
+ * The event linked to the selection buttons
+ */
+ protected void fireButtonSelectionEvent(SelectionEvent event) {
+ if ((Boolean) ((Button) event.widget).getData()) {
+ treeViewer.getTree().selectAll();
+ // Updates the selectedFiles collection
+ getNestedFiles(((IStructuredSelection) treeViewer.getSelection()).toArray());
+
+ if (dialogData != null) {
+ dialogData.setSelectedFiles(selectedFiles);
+ }
+ } else {
+ treeViewer.getTree().deselectAll();
+ selectedFiles.clear();
+
+ if (dialogData != null) {
+ dialogData.setSelectedFiles(selectedFiles);
+ }
+ }
+ }
+
+ /**
+ *
+ * handle the selections outside of the workspace
+ *
+ * @param event
+ * The event linked to the button
+ */
+ protected void fireSystemBrowseEvent(SelectionEvent event) {
+
+ // Clears the previous selection
+ dialogData.getSystemSelectedFiles().clear();
+ // Instantiates a new selection window
+ FileDialog dialog = new FileDialog(treeViewerComposite.getShell(), SWT.MULTI);
+ dialog.setText(Messages.FileDialogTitle);
+ dialog.setFilterExtensions(TransformationWizardConstants.EXTENSIONS);
+ dialog.setFilterNames(TransformationWizardConstants.EXTENSIONS_NAMES);
+
+ if (dialogData != null) {
+ // Fetches the last visited folder or uses the Home of the current user
+ if (dialogData.dialogSection.get(TransformationWizardConstants.FILEDIALOG_SELECTION_KEY) != null) {
+ dialog.setFilterPath(dialogData.dialogSection.get(TransformationWizardConstants.FILEDIALOG_SELECTION_KEY));
+ } else {
+ String homeFolder = System.getProperty("user.home"); //$NON-NLS-1$
+ dialog.setFilterPath(homeFolder);
+ }
+
+ // Opens the selection window and stores the selected files
+ systemDialogFiles = dialog.open();
+ if (systemDialogFiles != null) {
+ // stores the last folder/directory visited
+ dialogData.dialogSection.put(TransformationWizardConstants.FILEDIALOG_SELECTION_KEY, systemDialogFiles);
+ String[] names = dialog.getFileNames();
+ // Empty the list to avoid remembering old selections
+ systemPaths.clear();
+ for (int i = 0, n = names.length; i < n; i++) {
+ StringBuffer buf = new StringBuffer(dialog.getFilterPath());
+ if (buf.charAt(buf.length() - 1) != File.separatorChar) {
+ buf.append(File.separatorChar);
+ }
+ buf.append(names[i]);
+ systemPaths.add(buf.toString());
+ }
+ // clear the list to accept the new input
+ dialogData.getSystemSelectedFiles().clear();
+ dialogData.setSystemSelectedFiles(systemPaths);
+ }
+ }
+
+ Collection<Object> systemSelection = dialogData.getSystemSelectedFiles();
+ getProjects(systemSelection);
+ if (!systemSelection.isEmpty()) {
+ // The selected files are inside a project
+ if (!foundProjects.isEmpty()) {
+ for (Object object : foundProjects) {
+ if (isWorkspaceObject(object)) {
+ revealSelectedFiles(systemSelection);
+ }
+ // Creates the project before revealing any imported files
+ else if (importProjects(foundProjects)) {
+ revealSelectedFiles(systemSelection);
+ }
+ }
+ }
+ // We need to create a project in order to house the selected files
+ else if (systemDialogFiles != null) {
+ try {
+ List<String> srcFolders = new ArrayList<String>();
+ srcFolders.add(TransformationWizardConstants.SRC_FOLDER);
+ CreateProject placeHolder = new CreateProject(dialogData.getSystemSelectedFiles());
+ IProject newProject = placeHolder.getCreatedProject();
+ Collection<Object> revealList = new ArrayList<Object>();
+ // This case can happen by pressing the cancel button and therefore interrupting the creation of the project
+ if (newProject != null) {
+ for (IResource resource : Arrays.asList(newProject.getFolder(TransformationWizardConstants.RSC_FOLDER).members())) {
+ if (resource instanceof IFile) {
+ revealList.add((IFile) resource);
+ }
+ }
+ revealSelectedFiles(revealList);
+ }
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+
+ }
+
+ /**
+ *
+ * Verify if the provided object is or is not inside the workspace
+ *
+ * @param object
+ * The object
+ * @return
+ * True or False
+ */
+ protected boolean isWorkspaceObject(Object object) {
+ if (object instanceof File) {
+ File file = (File) object;
+ IFile ifile = FileUtil.getIFile(file.getAbsolutePath());
+ // Assumes that any files outside the workbench are not IFiles and therefore wont be find, i.e. are null
+ if (ifile != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * Handles the creation of the new workspace projects in case of a selection outside of an existing project or workspace
+ *
+ * @param foundProjects
+ * The projects previously found
+ * @return
+ * The success of the creation
+ */
+ protected boolean importProjects(Collection<Object> foundProjects) {
+ Collection<Object> importedProjects = new LinkedList<Object>();
+ boolean importStatus = false;
+ for (Object object : foundProjects) {
+ if (object instanceof File) {
+ File file = (File) object;
+ Path filePath = new Path(file.getAbsolutePath());
+ try {
+ IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(filePath);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
+ importedProjects.add(project);
+ project.create(description, null);
+ project.open(null);
+ importStatus = true;
+ } catch (CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+
+ dialogData.setImportedProjects(importedProjects);
+ return importStatus;
+ }
+
+ @Override
+ public void dispose() {
+ if (selectionButtonListener != null) {
+ selectAllButton.removeSelectionListener(selectionButtonListener);
+ deselectAllButton.removeSelectionListener(selectionButtonListener);
+ }
+ if (systemSelectionListener != null) {
+ systemSelectionButton.removeSelectionListener(systemSelectionListener);
+ }
+
+ super.dispose();
+ }
+
+}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ImportConfigComposite.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ImportConfigComposite.java
new file mode 100644
index 00000000000..c763095d7a9
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ImportConfigComposite.java
@@ -0,0 +1,196 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.migration.rsa.wizard.pages;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.papyrus.infra.widgets.util.FileUtil;
+import org.eclipse.papyrus.migration.rsa.messages.Messages;
+import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.Config;
+import org.eclipse.papyrus.views.properties.runtime.DisplayEngine;
+import org.eclipse.papyrus.views.properties.util.PropertiesDisplayHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ *
+ * Generic and reusable composite used to display the previously selected elements and the migration options
+ *
+ * @author Quentin Le Menez
+ *
+ */
+public abstract class ImportConfigComposite extends Composite {
+
+ protected Config config;
+
+ protected Collection<Object> transformationFiles;
+
+ protected CheckboxTableViewer listViewer;
+
+ protected ISelectionChangedListener listListener;
+
+ protected DisplayEngine displayEngine;
+
+ protected Collection<Object> uncheckedFiles;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * The parent composite
+ * @param style
+ * The swt style used for this ConfigurationComposite
+ * @param config
+ * The configuration used to display the transformation options
+ */
+ public ImportConfigComposite(Composite parent, int style, Config config) {
+ super(parent, style);
+ this.setLayout(new GridLayout(1, false));
+ this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ this.config = config;
+
+ Composite filesComposite = new Composite(this, SWT.BORDER);
+ filesComposite.setLayout(new FillLayout());
+ filesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Composite configComposite = new Composite(this, SWT.BORDER);
+ configComposite.setLayout(new FillLayout());
+ configComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+
+ createFilesComposite(filesComposite);
+
+ createParamComposite(configComposite);
+ }
+
+
+ /**
+ *
+ * Fills the selection area with all the files selected previously
+ *
+ * @param parent
+ * The parent composite
+ */
+ protected void createFilesComposite(Composite parent) {
+ Composite listComposite = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(2, false);
+ listComposite.setLayout(gridLayout);
+
+ listViewer = CheckboxTableViewer.newCheckList(listComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData viewerGrid = new GridData(SWT.FILL, SWT.FILL, true, true);
+ listViewer.getTable().setLayoutData(viewerGrid);
+
+ listViewer.setLabelProvider(new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFile) {
+ return FileUtil.getPath((IFile) element, true);
+ } else if (element instanceof File) {
+ return ((File) element).getAbsolutePath();
+ } else {
+ return Messages.WrongFileType;
+ }
+ }
+ });
+
+ listViewer.setContentProvider(new ArrayContentProvider());
+
+ listListener = new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ fireSelectionEvent(event);
+ }
+ };
+
+ listViewer.addSelectionChangedListener(listListener);
+
+ setTransformationFiles();
+
+ createSelectionButtons(listComposite);
+
+ }
+
+
+ /**
+ *
+ * Used to update the display from a changed selection in the ConfigPage
+ *
+ * @param selectedFiles
+ * The new list of selected files
+ */
+ abstract void setViewerInput(Collection<Object> selectedFiles);
+
+ /**
+ *
+ * Abstract method to be implemented by the child in order to create the useful buttons to manipulate the tableViewer's elements
+ *
+ * @param parent
+ * The parent composite in which the new buttons will be created
+ */
+ abstract void createSelectionButtons(Composite parent);
+
+ /**
+ *
+ * Abstract method to be implemented by the child in order to handle the transformation options
+ *
+ * @param event
+ * The event linked to the configuration's selection buttons
+ */
+ abstract void fireSelectionEvent(SelectionChangedEvent event);
+
+
+ /**
+ *
+ * Updates the list of files to be transformed
+ *
+ */
+ public void setTransformationFiles() {
+ transformationFiles = new LinkedList<Object>(Arrays.asList(listViewer.getCheckedElements()));
+ }
+
+
+ /**
+ *
+ * Fills the composite with the configuration parameters
+ *
+ * @param parent
+ * The parent composite
+ */
+ public void createParamComposite(Composite parent) {
+ displayEngine = PropertiesDisplayHelper.display(config, parent);
+ }
+
+
+ @Override
+ public void dispose() {
+ if (displayEngine != null) {
+ displayEngine.dispose();
+ }
+ if (listListener != null) {
+ listViewer.removeSelectionChangedListener(listListener);
+ }
+ super.dispose();
+ }
+
+}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ImportTreeComposite.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ImportTreeComposite.java
new file mode 100644
index 00000000000..3dad2a5103d
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ImportTreeComposite.java
@@ -0,0 +1,540 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.migration.rsa.wizard.pages;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.services.labelprovider.service.impl.LabelProviderServiceImpl;
+import org.eclipse.papyrus.infra.widgets.providers.IGraphicalContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter;
+import org.eclipse.papyrus.infra.widgets.providers.WorkspaceContentProvider;
+import org.eclipse.papyrus.migration.rsa.Activator;
+import org.eclipse.papyrus.migration.rsa.messages.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PatternFilter;
+
+
+/**
+ *
+ * Generic and reusable composite used to display the workspace and select the wanted elements
+ *
+ * @author Quentin Le Menez
+ *
+ */
+public abstract class ImportTreeComposite extends Composite {
+
+ protected TreeViewer treeViewer;
+
+ protected LabelProviderService labelProviderService;
+
+ protected ILabelProvider treeViewerlabelProvider;
+
+ protected WorkspaceContentProvider treeViewercontentProvider;
+
+ protected ISelectionChangedListener treeViewerListener;
+
+ protected final List<String> filterNames;
+
+ protected final List<String> filterExtensions;
+
+ protected Collection<Object> selectedFiles;
+
+ protected Collection<String> systemPaths;
+
+ protected FillLayout layout;
+
+ protected Composite treeViewerComposite;
+
+ protected Composite selectionButtonsComposite;
+
+ protected Collection<Object> foundProjects;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * The parent composite
+ * @param style
+ * The swt style used for this ConfigurationComposite
+ * @param extensions
+ * The default extensions used to filter the displayed results
+ * @param extensionsNames
+ * The displayed names of those filters
+ */
+ public ImportTreeComposite(Composite parent, int style, String[] extensions, String[] extensionsNames) {
+ super(parent, style);
+ this.setLayout(new GridLayout(2, false));
+ this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ selectedFiles = new LinkedList<Object>();
+ filterNames = new LinkedList<String>();
+ filterExtensions = new LinkedList<String>();
+ systemPaths = new LinkedList<String>();
+ foundProjects = new LinkedList<Object>();
+
+ createTreeViewerComposite(this, extensions, extensionsNames);
+
+ createSelectionButtons(this);
+ }
+
+
+ /**
+ *
+ * Creates the visual representation of the workspace
+ *
+ * @param parent
+ * The parent Composite
+ * @param extensions
+ * The default extensions used to filter the displayed results
+ * @param extensionsNames
+ * The displayed names of those filters
+ */
+ private void createTreeViewerComposite(Composite parent, String[] extensions, String[] extensionsNames) {
+ treeViewerComposite = new Composite(parent, SWT.NONE);
+ treeViewerComposite.setLayout(new GridLayout(1, true));
+ treeViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ Composite beforeTreeComposite = new Composite(treeViewerComposite, SWT.NONE);
+
+ Composite treeComposite = new Composite(treeViewerComposite, SWT.NONE);
+ treeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ layout = new FillLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ treeComposite.setLayout(layout);
+
+ treeViewer = new TreeViewer(treeComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ treeViewer.setFilters(new ViewerFilter[] { new PatternFilter() });
+
+ labelProviderService = new LabelProviderServiceImpl();
+ try {
+ labelProviderService.startService();
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+
+ treeViewerlabelProvider = labelProviderService.getLabelProvider();
+ treeViewercontentProvider = new WorkspaceContentProvider();
+ setFilters(extensions, extensionsNames);
+
+ treeViewercontentProvider.setExtensionFilters(new LinkedHashMap<String, String>());
+ for (int i = 0; i < Math.min(filterNames.size(), filterExtensions.size()); i++) {
+ treeViewercontentProvider.addExtensionFilter(filterExtensions.get(i), filterNames.get(i));
+ }
+
+ treeViewer.setContentProvider(treeViewercontentProvider);
+ treeViewer.setLabelProvider(treeViewerlabelProvider);
+
+ defaultViewerInput();
+
+ treeViewerListener = new ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ fireTreeSelectionEvent(event);
+ }
+ };
+
+ treeViewer.addSelectionChangedListener(treeViewerListener);
+
+ // This is used to display both of the filters (before and after the treeViewer)
+ if (treeViewercontentProvider instanceof IGraphicalContentProvider) {
+ IGraphicalContentProvider graphicalContentProvider = treeViewercontentProvider;
+
+ beforeTreeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ layout = new FillLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ beforeTreeComposite.setLayout(layout);
+ graphicalContentProvider.createBefore(beforeTreeComposite);
+ beforeTreeComposite.moveAbove(treeViewer.getTree());
+
+ Composite afterTreeComposite = new Composite(treeViewerComposite, SWT.NONE);
+ layout = new FillLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ afterTreeComposite.setLayout(layout);
+ afterTreeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ graphicalContentProvider.createAfter(afterTreeComposite);
+ }
+
+ }
+
+ /**
+ *
+ * Sets the filters for the treeViewer, matching the names with the extensions
+ *
+ * @param filterExtensions
+ * The extensions
+ * @param filterNames
+ * The associated names
+ */
+ protected void setFilters(String[] filterExtensions, String[] filterNames) {
+ if (filterExtensions.length != filterNames.length) {
+ // This is a simple warning. Only valid filters will be retained.
+ Activator.log.warn(Messages.MultipleStringFileEditor_2);
+ }
+
+ setFilterNames(getFilterLabels(filterNames, filterExtensions));
+ setFilterExtensions(filterExtensions);
+ }
+
+ /**
+ *
+ * Builds the filter labels to be displayed
+ *
+ * @param filterNames
+ * @param filterExtensions
+ * @return
+ * The array containing the built labels
+ */
+ protected String[] getFilterLabels(String[] filterNames, String[] filterExtensions) {
+ int size = Math.min(filterNames.length, filterExtensions.length);
+ String[] filters = new String[size];
+ for (int i = 0; i < size; i++) {
+ filters[i] = filterNames[i] + " (" + filterExtensions[i] + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return filters;
+ }
+
+ /**
+ *
+ * Fills the local array to be manipulated
+ *
+ * @param filterExtensions
+ * The input extensions
+ */
+ protected void setFilterExtensions(String[] filterExtensions) {
+ this.filterExtensions.clear();
+ this.filterExtensions.addAll(Arrays.asList(filterExtensions));
+ }
+
+ /**
+ *
+ * Fills the local array to be manipulated
+ *
+ * @param filterNames
+ * The input names
+ */
+ protected void setFilterNames(String[] filterNames) {
+ this.filterNames.clear();
+ this.filterNames.addAll(Arrays.asList(filterNames));
+ }
+
+
+ /**
+ *
+ * This method allows to set the default input of the treeViewer
+ *
+ */
+ protected void defaultViewerInput() {
+ treeViewer.setInput(File.listRoots());
+ // Gets the selection in the workspace at the time of the launch
+ ISelection workbenchSelection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ // Sets the first selection of the treeviewer from the selection in the workspace
+ revealSelection(workbenchSelection);
+ treeViewer.setSelection(workbenchSelection, true);
+ }
+
+
+ /**
+ *
+ * Abstract method to be implemented by the child in order to create the useful buttons to manipulate the tree's elements
+ *
+ * @param parent
+ * The parent composite in which the new buttons will be created
+ */
+ abstract void createSelectionButtons(Composite parent);
+
+ /**
+ *
+ * Abstract method to be implemented by the child in order to handle the treeViewer element selection
+ *
+ * @param event
+ * The event linked to the selections inside the treeViewer
+ */
+ abstract void fireTreeSelectionEvent(SelectionChangedEvent event);
+
+
+ /**
+ *
+ * This method reveals the elements selected outside of the workspace or from the workspace selection at launch by expanding the tree
+ *
+ * @param importedFiles
+ * The list of selected files
+ */
+ protected void revealSelectedFiles(Collection<Object> importedFiles) {
+ // this method calls to expand any folders or projects containg the selected files in order to show the workspace selection
+ Collection<IFile> ifiles = new ArrayList<IFile>();
+ // Collection<IProject> iprojects = new ArrayList<IProject>();
+ // Collection<IFolder> ifolders = new ArrayList<IFolder>();
+ if (importedFiles != null && !importedFiles.isEmpty()) {
+ for (Object object : importedFiles) {
+ treeViewer.refresh();
+ if (object instanceof File) {
+ File file = (File) object;
+ IFile ifile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(file.getAbsolutePath()));
+ if (ifile != null) {
+ ifiles.add(ifile);
+ revealTreeElement(ifile);
+ }
+ }
+ if (object instanceof IFile) {
+ IFile ifile = (IFile) object;
+ ifiles.add(ifile);
+ revealTreeElement(ifile);
+ }
+ // if (object instanceof IFolder) {
+ // IFolder ifolder = (IFolder) object;
+ // ifolders.add(ifolder);
+ // revealTreeElement(ifolder);
+ // }
+ // if (object instanceof IProject) {
+ // IProject iproject = (IProject) object;
+ // iprojects.add(iproject);
+ // // As a project is a root element, no need to expand it
+ // }
+ }
+ }
+
+ treeViewer.setSelection(new StructuredSelection(ifiles.toArray()), true);
+ // treeViewer.setSelection(new StructuredSelection(ifolders.toArray()), true);
+ // treeViewer.setSelection(new StructuredSelection(iprojects.toArray()), true);
+ }
+
+ /**
+ *
+ * Handles the workspace selection
+ *
+ * @param iselection
+ * The selection
+ */
+ protected void revealSelection(ISelection iselection) {
+ if (iselection instanceof IStructuredSelection) {
+ IStructuredSelection sselection = (IStructuredSelection) iselection;
+ revealSelectedFiles(Arrays.asList(sselection.toArray()));
+ }
+ }
+
+ /**
+ *
+ * Reveal each elements from the selected elements list
+ *
+ * @param object
+ * The selected object
+ */
+ protected void revealTreeElement(Object object) {
+ // verify the possibility of getting the file's parent and that the root directory is not already selected
+ if (object instanceof IFile && !(object instanceof IProject)) {
+ IFile ifile = (IFile) object;
+ treeViewer.setExpandedState(ifile.getParent(), true);
+ if (!(ifile.getParent() instanceof IProject)) {
+ revealTreeElement(ifile.getParent());
+ }
+ }
+ if (object instanceof IFolder && !(object instanceof IProject)) {
+ IFolder ifolder = (IFolder) object;
+ treeViewer.setExpandedState(ifolder.getParent(), true);
+ if (!(ifolder.getParent() instanceof IProject)) {
+ revealTreeElement(ifolder.getParent());
+ }
+ }
+ }
+
+ /**
+ *
+ * This method is used to get the projects containing the selected objects
+ *
+ * @param systemSelection
+ * The selection outside of the workspace
+ * @return
+ * The list of projects found
+ */
+ protected Collection<Object> getProjects(Collection<Object> systemSelection) {
+ if (systemSelection != null && !systemSelection.isEmpty()) {
+ for (Object object : systemSelection) {
+ if (object instanceof File) {
+ File file = (File) object;
+ getProject(file);
+ }
+ }
+ }
+ return foundProjects;
+ }
+
+ /**
+ *
+ * This method is used to get the projects containing the file
+ *
+ * @param file
+ * The selected file
+ */
+ protected void getProject(File file) {
+ File parentFile = file.getParentFile();
+ if (parentFile == null) {
+ // No containing project has been found
+ return;
+ }
+
+ Collection<File> parentChildren = Arrays.asList(parentFile.listFiles());
+ for (File nestedFile : parentChildren) {
+ // String fileExtension = Files.getFileExtension(nestedFile.getAbsolutePath());
+ String fileExtension = getFileExtensions(nestedFile);
+ if (fileExtension.equals(".project") && !foundProjects.contains(nestedFile)) { // $NON-NLS-1$
+ // A containing project has been found
+ foundProjects.add(nestedFile);
+ return;
+ }
+ }
+
+ getProject(parentFile);
+ }
+
+ /**
+ *
+ * This method gathers the file extensions in order to filter them
+ *
+ * @param file
+ * The file
+ * @return
+ * The file's extension
+ */
+ protected String getFileExtensions(File file) {
+ String fileName = file.getName();
+ if (fileName.lastIndexOf(".") != -1 /* && fileName.lastIndexOf(".") != 0 */) { // $NON-NLS-1$
+ return fileName.substring(fileName.lastIndexOf(".")); // $NON-NLS-1$
+ } else {
+ return "";
+ }
+ }
+
+ /**
+ *
+ * Constructs the list of the treeViewer's selected files
+ *
+ * @param elements
+ */
+ public void setSelectedFiles(Object[] elements) {
+ // get the viewer selection to obtain the filtered files
+ getNestedFiles(elements);
+ }
+
+ /**
+ *
+ * getter used to access the selectedFiles list
+ *
+ * @return
+ * the list of selected files
+ */
+ public Collection<Object> getSelectedFiles() {
+ return selectedFiles;
+ }
+
+ /**
+ *
+ * Gets all the files from the user's selection in the viewer and updates the local selection list
+ *
+ * @param nestedElements
+ * The array containing the selected elements, be they files or folders
+ */
+ protected void getNestedFiles(Object[] nestedElements) {
+ Collection<Object> projectList = new LinkedList<Object>();
+ Collection<Object> folderList = new LinkedList<Object>();
+ List<PatternViewerFilter> currentFilters = new ArrayList<PatternViewerFilter>();
+ for (ViewerFilter filter : treeViewer.getFilters()) {
+ if (filter instanceof PatternViewerFilter) {
+ currentFilters.add((PatternViewerFilter) filter);
+ }
+ }
+
+ for (Object element : nestedElements) {
+ if (element instanceof IProject) {
+ projectList.add(element);
+ }
+ if (element instanceof IFolder) {
+ folderList.add(element);
+ }
+ if (element instanceof IFile) {
+ Boolean isVisible = false;
+ IFile selectedFile = (IFile) element;
+ String fileExtension = "*." + selectedFile.getFileExtension(); //$NON-NLS-1$
+ if (filterExtensions.contains(fileExtension) && !selectedFiles.contains(selectedFile)) {
+ isVisible = true;
+ }
+ for (int index = 0; index < currentFilters.size() && isVisible; index++) {
+ isVisible = currentFilters.get(index).isVisible(treeViewer, selectedFile.getParent(), selectedFile);
+ }
+ if (isVisible) {
+ selectedFiles.add(selectedFile);
+ }
+ }
+ }
+
+ if (projectList.size() > 0) {
+ for (Object element : projectList) {
+ IProject selectedProject = (IProject) element;
+ try {
+ getNestedFiles(selectedProject.members());
+ } catch (CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+
+ if (folderList.size() > 0) {
+ for (Object element : folderList) {
+ IFolder selectedFolder = (IFolder) element;
+ try {
+ getNestedFiles(selectedFolder.members());
+ } catch (CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void dispose() {
+ if (treeViewerListener != null) {
+ treeViewer.removeSelectionChangedListener(treeViewerListener);
+ }
+ super.dispose();
+ }
+
+}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/SelectionTreeComposite.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/SelectionTreeComposite.java
deleted file mode 100644
index f7a38043b44..00000000000
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/SelectionTreeComposite.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Quentin Le Menez (CEA LIST) quentin.lemenez@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.migration.rsa.wizard.pages;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.papyrus.infra.services.labelprovider.service.impl.LabelProviderServiceImpl;
-import org.eclipse.papyrus.infra.widgets.providers.IGraphicalContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter;
-import org.eclipse.papyrus.infra.widgets.providers.WorkspaceContentProvider;
-import org.eclipse.papyrus.migration.rsa.Activator;
-import org.eclipse.papyrus.migration.rsa.messages.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PatternFilter;
-
-/**
- *
- * Actual composite used to display the workspace and select the wanted elements
- *
- * @author Quentin Le Menez
- *
- */
-public class SelectionTreeComposite extends Composite {
-
- protected TreeViewer treeViewer;
-
- protected LabelProviderService labelProviderService;
-
- protected ILabelProvider labelProvider;
-
- protected WorkspaceContentProvider contentProvider;
-
- protected ISelectionChangedListener listListener;
-
- protected final List<String> filterNames;
-
- protected final List<String> filterExtensions;
-
- protected Button selectAll;
-
- protected Button deselectAll;
-
- protected SelectionListener buttonListener;
-
- protected Collection<Object> selectedFiles;
-
- protected FillLayout layout;
-
- protected DialogData dialogData;
-
- /**
- *
- * Constructor.
- *
- * @param parent
- * The parent composite
- * @param style
- * The swt style used for this ConfigurationComposite
- * @param extensions
- * The default extensions used to filter the displayed results
- * @param extensionsNames
- * The displayed names of those filters
- */
- public SelectionTreeComposite(Composite parent, int style, String[] extensions, String[] extensionsNames) {
- super(parent, style);
- this.setLayout(new GridLayout(2, false));
- this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- selectedFiles = new LinkedList<Object>();
- filterNames = new LinkedList<String>();
- filterExtensions = new LinkedList<String>();
-
- createTreeViewerComposite(extensions, extensionsNames);
-
- createSelectionButtons(this);
- }
-
- /**
- *
- * Constructor used when a DialogData class is employed to store the different informations of the dialog
- *
- * @param parent
- * The parent composite
- * @param style
- * The swt style used for this ConfigurationComposite
- * @param dialogData
- * The DialogData in which is stored all the necessary informations
- */
- public SelectionTreeComposite(Composite parent, int style, DialogData dialogData) {
- this(parent, style, dialogData.getExtensions(), dialogData.getExtensionsNames());
- this.dialogData = dialogData;
- ISelection treeSelection = treeViewer.getSelection();
- if (treeSelection instanceof StructuredSelection) {
- setSelectedFiles(((StructuredSelection) treeSelection).toArray());
- this.dialogData.setSelectedFiles(getSelectedFiles());
- }
-
- }
-
- /**
- *
- * Creates the visual representation of the workspace
- *
- * @param extensions
- * The default extensions used to filter the displayed results
- * @param extensionsNames
- * The displayed names of those filters
- */
- private void createTreeViewerComposite(String[] extensions, String[] extensionsNames) {
- Composite treeViewerComposite = new Composite(this, SWT.NONE);
- treeViewerComposite.setLayout(new GridLayout(1, true));
- treeViewerComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Composite beforeTreeComposite = new Composite(treeViewerComposite, SWT.NONE);
-
- Composite treeComposite = new Composite(treeViewerComposite, SWT.NONE);
- treeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- layout = new FillLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- treeComposite.setLayout(layout);
-
- treeViewer = new TreeViewer(treeComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- treeViewer.setFilters(new ViewerFilter[] { new PatternFilter() });
-
- labelProviderService = new LabelProviderServiceImpl();
- try {
- labelProviderService.startService();
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- }
-
- labelProvider = labelProviderService.getLabelProvider();
- contentProvider = new WorkspaceContentProvider();
- setFilters(extensions, extensionsNames);
-
- contentProvider.setExtensionFilters(new LinkedHashMap<String, String>());
- for (int i = 0; i < Math.min(filterNames.size(), filterExtensions.size()); i++) {
- contentProvider.addExtensionFilter(filterExtensions.get(i), filterNames.get(i));
- }
-
- treeViewer.setContentProvider(contentProvider);
- treeViewer.setLabelProvider(labelProvider);
-
- listListener = new ISelectionChangedListener() {
-
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- selectedFiles.clear();
- IStructuredSelection sSelection = (IStructuredSelection) selection;
- setSelectedFiles(sSelection.toArray());
-
- if (dialogData != null) {
- dialogData.setSelectedFiles(selectedFiles);
- }
- }
- }
- };
-
- treeViewer.addSelectionChangedListener(listListener);
-
- treeViewer.setInput(File.listRoots());
-
- // get the selection in the workspace at the time of the launch
- ISelection workbenchSelection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
- // set the first selection of the treeviewer from the selection in the workspace
- treeViewer.setSelection(workbenchSelection, true);
- // treeViewer.setSelection(new StructuredSelection(dialogData), true);
-
- if (contentProvider instanceof IGraphicalContentProvider) {
- IGraphicalContentProvider graphicalContentProvider = contentProvider;
-
- beforeTreeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- layout = new FillLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- beforeTreeComposite.setLayout(layout);
- graphicalContentProvider.createBefore(beforeTreeComposite);
- beforeTreeComposite.moveAbove(treeViewer.getTree());
-
- Composite afterTreeComposite = new Composite(treeViewerComposite, SWT.NONE);
- layout = new FillLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- afterTreeComposite.setLayout(layout);
- afterTreeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- graphicalContentProvider.createAfter(afterTreeComposite);
- }
-
- }
-
- protected void setFilters(String[] filterExtensions, String[] filterNames) {
- if (filterExtensions.length != filterNames.length) {
- // This is a simple warning. Only valid filters will be retained.
- Activator.log.warn(Messages.MultipleStringFileEditor_2);
- }
-
- setFilterNames(getFilterLabels(filterNames, filterExtensions));
- setFilterExtensions(filterExtensions);
- }
-
- protected String[] getFilterLabels(String[] filterNames, String[] filterExtensions) {
- int size = Math.min(filterNames.length, filterExtensions.length);
- String[] filters = new String[size];
- for (int i = 0; i < size; i++) {
- filters[i] = filterNames[i] + " (" + filterExtensions[i] + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return filters;
- }
-
- protected void setFilterExtensions(String[] filterExtensions) {
- this.filterExtensions.clear();
- this.filterExtensions.addAll(Arrays.asList(filterExtensions));
- }
-
- protected void setFilterNames(String[] filterNames) {
- this.filterNames.clear();
- this.filterNames.addAll(Arrays.asList(filterNames));
- }
-
- public TreeViewer getTreeViewer() {
- return treeViewer;
- }
-
- /**
- *
- * Fills the composite with the selection buttons
- *
- * @param parent
- * The parent composite
- */
- public void createSelectionButtons(Composite parent) {
- Composite buttonsComposite = new Composite(parent, SWT.NONE);
- buttonsComposite.setLayout(new GridLayout());
- // Color defaultColor = new Color(Display.getDefault(), new RGB(255, 255, 255));
- // treeViewerComposite.setBackground(defaultColor);
-
- buttonListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- if ((Boolean) ((Button) event.widget).getData()) {
- treeViewer.getTree().selectAll();
- // updates the selectedFiles collection
- getNestedFiles(((IStructuredSelection) treeViewer.getSelection()).toArray());
-
- if (dialogData != null) {
- dialogData.setSelectedFiles(selectedFiles);
- }
- } else {
- treeViewer.getTree().deselectAll();
- selectedFiles.clear();
-
- if (dialogData != null) {
- dialogData.setSelectedFiles(selectedFiles);
- }
- }
- }
- };
-
- selectAll = new Button(buttonsComposite, SWT.PUSH);
- selectAll.setText(Messages.Button_SelectAll);
- selectAll.setData(true);
- selectAll.addSelectionListener(buttonListener);
- selectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
-
- deselectAll = new Button(buttonsComposite, SWT.PUSH);
- deselectAll.setText(Messages.Button_DeselectAll);
- deselectAll.setData(false);
- deselectAll.addSelectionListener(buttonListener);
- deselectAll.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
- }
-
- public void setSelectedFiles(Object[] elements) {
- // get the viewer selection to obtain the filtered files
- getNestedFiles(elements);
- }
-
- public Collection<Object> getSelectedFiles() {
- return selectedFiles;
- }
-
- /**
- *
- * Gets all the files from the user's selection in the viewer
- *
- * @param nestedElements
- */
- protected void getNestedFiles(Object[] nestedElements) {
- Collection<Object> projectList = new LinkedList<Object>();
- Collection<Object> folderList = new LinkedList<Object>();
- List<PatternViewerFilter> currentFilters = new ArrayList<PatternViewerFilter>();
- for (ViewerFilter filter : treeViewer.getFilters()) {
- if (filter instanceof PatternViewerFilter) {
- currentFilters.add((PatternViewerFilter) filter);
- }
- }
-
- for (Object element : nestedElements) {
- if (element instanceof IProject) {
- projectList.add(element);
- }
- if (element instanceof IFolder) {
- folderList.add(element);
- }
- if (element instanceof IFile) {
- Boolean isVisible = false;
- IFile selectedFile = (IFile) element;
- String fileExtension = "*." + selectedFile.getFileExtension(); //$NON-NLS-1$
- if (filterExtensions.contains(fileExtension) && !selectedFiles.contains(selectedFile)) {
- isVisible = true;
- }
- for (int index = 0; index < currentFilters.size() && isVisible; index++) {
- isVisible = currentFilters.get(index).isVisible(treeViewer, selectedFile.getParent(), selectedFile);
- }
- if (isVisible) {
- selectedFiles.add(selectedFile);
- }
- }
- }
-
- if (projectList.size() > 0) {
- for (Object element : projectList) {
- IProject selectedProject = (IProject) element;
- try {
- getNestedFiles(selectedProject.members());
- } catch (CoreException e) {
- Activator.log.error(e);
- }
- }
- }
-
- if (folderList.size() > 0) {
- for (Object element : folderList) {
- IFolder selectedFolder = (IFolder) element;
- try {
- getNestedFiles(selectedFolder.members());
- } catch (CoreException e) {
- Activator.log.error(e);
- }
- }
- }
- }
-
- @Override
- public void dispose() {
- if (buttonListener != null) {
- selectAll.removeSelectionListener(buttonListener);
- deselectAll.removeSelectionListener(buttonListener);
- }
- if (listListener != null) {
- treeViewer.removeSelectionChangedListener(listListener);
- }
- super.dispose();
- }
-
-}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationConfigPage.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationConfigPage.java
index ddf6662c839..f57305731b2 100644
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationConfigPage.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationConfigPage.java
@@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Composite;
*/
public class TransformationConfigPage extends WizardPage {
- protected ConfigurationComposite configComposite;
+ protected DialogDataConfigComposite dialogDataConfigComposite;
protected DialogData dialogData;
@@ -56,7 +56,7 @@ public class TransformationConfigPage extends WizardPage {
Composite pageComposite = new Composite(parent, SWT.NONE);
pageComposite.setLayout(new GridLayout());
- configComposite = new ConfigurationComposite(pageComposite, SWT.NONE, dialogData);
+ dialogDataConfigComposite = new DialogDataConfigComposite(pageComposite, SWT.NONE, dialogData);
setControl(pageComposite);
}
@@ -67,7 +67,7 @@ public class TransformationConfigPage extends WizardPage {
*
*/
public void resetViewerInput() {
- configComposite.setViewerInput(dialogData.getSelectedFiles());
+ dialogDataConfigComposite.setViewerInput(dialogData.getAllSelectedFiles());
}
}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationSelectionPage.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationSelectionPage.java
index a93a6d0fe02..dcce3bc5c2e 100644
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationSelectionPage.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationSelectionPage.java
@@ -52,9 +52,8 @@ public class TransformationSelectionPage extends WizardPage {
Composite pageComposite = new Composite(parent, SWT.NONE);
pageComposite.setLayout(new GridLayout());
- new SelectionTreeComposite(pageComposite, SWT.NONE, dialogData);
+ new DialogDataTreeComposite(pageComposite, SWT.NONE, dialogData);
setControl(pageComposite);
}
-
}

Back to the top