Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2015-01-08 13:44:49 +0000
committerQuentin Le Menez2015-01-08 13:52:07 +0000
commite1da56efdce524a442a423322423c950fd180fd3 (patch)
treeb87a5d968f647f18d6bcc267ae56b9e9e3274c9f
parent3f4212c0db41c066642473eb7359bec9eedf6b39 (diff)
downloadorg.eclipse.papyrus-e1da56efdce524a442a423322423c950fd180fd3.tar.gz
org.eclipse.papyrus-e1da56efdce524a442a423322423c950fd180fd3.tar.xz
org.eclipse.papyrus-e1da56efdce524a442a423322423c950fd180fd3.zip
454999: [Model Import - Wizard] The Model Import Wizard should remember the last file selection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=454999 - refactoring of the code, creation of two new composites for reusability purpose - the wizard now take into account the selection in the model explorer and select it from the tree's elements - the wizard now creates a settings file to store the previous file selection when displayed in the configuration page Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
-rwxr-xr-xextraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/constants/TransformationWizardConstants.java38
-rwxr-xr-xextraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/Messages.java41
-rwxr-xr-xextraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/messages.properties24
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/TransformationWizard.java40
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/ConfigurationComposite.java136
-rwxr-xr-xextraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogData.java181
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/SelectionTreeComposite.java120
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationConfigPage.java56
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/TransformationSelectionPage.java48
9 files changed, 582 insertions, 102 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
new file mode 100755
index 00000000000..3318463516a
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/constants/TransformationWizardConstants.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * 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.constants;
+
+import org.eclipse.papyrus.migration.rsa.Activator;
+
+/**
+ * Constants used in the wizard
+ */
+public interface TransformationWizardConstants {
+
+ /**
+ * The extensions used in the default filters
+ */
+ public static final String[] EXTENSIONS = { "*", "*.emx", "*.epx", "*.epx;*.emx" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ public static final String[] EXTENSIONS_NAMES = { "All", "*.emx", "*.epx", "*.epx and *.emx" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ /**
+ * The name used for the settings file
+ */
+ public static final String TRANSFORMATION_WIZARD_SETTINGS = Activator.PLUGIN_ID + "Wizard.lastUnselection"; //$NON-NLS-1$
+
+ /**
+ * The key to retrieve the selection preferences from the settings file
+ */
+ public static final String SELECTION_KEY = "selectionPeferences"; //$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
new file mode 100755
index 00000000000..95b7da17960
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/Messages.java
@@ -0,0 +1,41 @@
+/*****************************************************************************
+ * 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.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * UI text to externalize
+ */
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.migration.rsa.messages.messages"; //$NON-NLS-1$
+ public static String TransformationWizard_Title;
+ public static String TransformationSelectionPage_Name;
+ public static String TransformationSelectionPage_Title;
+ public static String TransformationSelectionPage_Description;
+ 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 MultipleStringFileEditor_2;
+ public static String WrongFileType;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
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
new file mode 100755
index 00000000000..21135fe6cae
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/messages/messages.properties
@@ -0,0 +1,24 @@
+###############################################################################
+# Copyright (c) 2010, 2014 CEA LIST and others.
+#
+# 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
+#
+###############################################################################
+
+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
+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
+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/wizard/TransformationWizard.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/TransformationWizard.java
index 1a1d3f932f4..3b2b3e43706 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,7 +11,6 @@
*****************************************************************************/
package org.eclipse.papyrus.migration.rsa.wizard;
-import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -23,23 +22,35 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
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;
+/**
+ *
+ * Wizard handling the selection and transformation of .emx/.epx files
+ *
+ * @author Quentin Le Menez
+ *
+ */
public class TransformationWizard extends Wizard implements IImportWizard {
- private TransformationSelectionPage selectionPage = new TransformationSelectionPage();
+ protected IWizardPage currentPage;
- private TransformationConfigPage configPage = new TransformationConfigPage();
+ protected DialogData dialogData = new DialogData();
- IWizardPage currentPage;
+ protected TransformationSelectionPage selectionPage = new TransformationSelectionPage(dialogData);
- public TransformationWizard() {
- setWindowTitle("RSA transformation wizard"); //$NON-NLS-1$
+ protected TransformationConfigPage configPage = new TransformationConfigPage(dialogData);
+
+ public TransformationWizard() {
+ setWindowTitle(Messages.TransformationWizard_Title);
}
@Override
@@ -53,8 +64,8 @@ public class TransformationWizard extends Wizard implements IImportWizard {
public IWizardPage getNextPage(IWizardPage currentPage) {
if (currentPage == selectionPage) {
this.currentPage = configPage;
- Collection<Object> selectedFiles = selectionPage.getSelectedFiles();
- configPage.setViewerInput(selectedFiles);
+ // Reset the viewer input in order to show the newly selected elements from the selectionPage
+ configPage.resetViewerInput();
return configPage;
}
if (this.currentPage == configPage) {
@@ -71,25 +82,30 @@ public class TransformationWizard extends Wizard implements IImportWizard {
return false;
}
+
@Override
public boolean performFinish() {
+ // Set or update the unchecked elements for future executions of the plugin
+ dialogData.setSelectionMap();
importFiles();
+
return true;
}
+
/**
*
- * Launches the transformation with the previously selected files and configuration parameters
+ * Launch the transformation with the previously selected files and configuration parameters
*
*/
- public void importFiles() {
- Config config = configPage.getConfig();
+ protected void importFiles() {
+ Config config = dialogData.getConfig();
if (config == null) {
return;
}
Set<IFile> selectedFiles = new HashSet<IFile>();
- for (Object file : configPage.getTransformationFiles()) {
+ for (Object file : dialogData.getTransformationFiles()) {
if (file instanceof IFile) {
selectedFiles.add((IFile) file);
}
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
index 9893906f3eb..cfb3d1104fd 100644
--- 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
@@ -21,6 +21,7 @@ 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;
@@ -35,7 +36,13 @@ 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;
@@ -50,11 +57,25 @@ public class ConfigurationComposite extends Composite {
protected SelectionListener buttonListener;
- private Button selectAll;
+ protected Button selectAll;
+
+ protected Button deselectAll;
- private 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));
@@ -75,8 +96,26 @@ public class ConfigurationComposite extends Composite {
}
/**
+ *
+ * Constructor used when a DialogData class is employed to store the different informations of the dialog
*
- * Fill the selection area with all the files selected previously
+ * @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
@@ -93,8 +132,12 @@ public class ConfigurationComposite extends Composite {
listViewer.setLabelProvider(new WorkbenchLabelProvider() {
@Override
protected String decorateText(String input, Object element) {
- // there are only IFiles in the received list
- return FileUtil.getPath((IFile) element, true);
+ // there should only be IFiles in the received list
+ if (element instanceof IFile) {
+ return FileUtil.getPath((IFile) element, true);
+ } else {
+ return Messages.WrongFileType;
+ }
}
});
@@ -104,29 +147,72 @@ public class ConfigurationComposite extends Composite {
@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);
- listViewer.setAllChecked(true);
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);
- listViewer.setAllChecked(true);
- setTransformationFiles();
+
+ 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);
+ }
}
/**
*
- * Fill the composite with the selection buttons
+ * Fills the composite with the selection buttons
*
* @param parent
+ * The parent composite
*/
public void createSelectionButtons(Composite parent) {
Composite buttonsComposite = new Composite(parent, SWT.NONE);
@@ -137,33 +223,57 @@ public class ConfigurationComposite extends Composite {
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("Select All"); //$NON-NLS-1$
+ 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("Deselect All"); //$NON-NLS-1$
+ 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);
+ }
+ }
+
/**
*
- * Fill the composite with the parameters buttons
+ * Fills the composite with the configuration parameters
*
* @param parent
+ * The parent composite
*/
public void createParamComposite(Composite parent) {
displayEngine = PropertiesDisplayHelper.display(config, parent);
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
new file mode 100755
index 00000000000..1f9e9a79145
--- /dev/null
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/wizard/pages/DialogData.java
@@ -0,0 +1,181 @@
+/*****************************************************************************
+ * 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.dialogs.IDialogSettings;
+import org.eclipse.papyrus.infra.widgets.util.FileUtil;
+import org.eclipse.papyrus.migration.rsa.Activator;
+import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.Config;
+import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.RSAToPapyrusParametersFactory;
+import org.eclipse.papyrus.migration.rsa.constants.TransformationWizardConstants;
+
+/**
+ *
+ * Class containing the bulk of the wizard's data for an easy access throughout the wizard
+ *
+ * @author Quentin Le Menez
+ *
+ */
+public class DialogData {
+
+ protected Collection<Object> selectedFiles;
+
+ protected Collection<Object> transformationFiles;
+
+ protected Config config = RSAToPapyrusParametersFactory.eINSTANCE.createConfig();
+
+ protected Collection<String> unselectedFiles;
+
+ protected IDialogSettings dialogSection;
+
+ protected Collection<Object> uncheckedFiles;
+
+ /**
+ *
+ * Constructor, instantiate the configuration file to store the user's selections, if none exist, or retrieve it
+ *
+ */
+ public DialogData() {
+ // Necessary for storing and recalling the previous selections
+ dialogSection = Activator.getDefault().getDialogSettings().getSection(TransformationWizardConstants.TRANSFORMATION_WIZARD_SETTINGS);
+ if (dialogSection == null) {
+ dialogSection = Activator.getDefault().getDialogSettings().addNewSection(TransformationWizardConstants.TRANSFORMATION_WIZARD_SETTINGS);
+ }
+ }
+
+ /**
+ *
+ * @param selectedFiles
+ * The selected files from the workspace to be displayed in the transformation page
+ */
+ public void setSelectedFiles(Collection<Object> selectedFiles) {
+ this.selectedFiles = selectedFiles;
+ }
+
+ /**
+ *
+ * @param transformationFiles
+ * The selected files in the configuration page to be transformed
+ */
+ public void setTransformationFiles(Collection<Object> transformationFiles) {
+ this.transformationFiles = transformationFiles;
+ }
+
+ /**
+ *
+ * @return
+ * The default extensions used to filter the workspace
+ */
+ public String[] getExtensions() {
+ return TransformationWizardConstants.EXTENSIONS;
+ }
+
+ /**
+ *
+ * @return
+ * The default extensions' name used to filter the workspace
+ */
+ public String[] getExtensionsNames() {
+ return TransformationWizardConstants.EXTENSIONS_NAMES;
+ }
+
+ /**
+ *
+ * @return
+ * The selected files from the workspace
+ */
+ public Collection<Object> getSelectedFiles() {
+ return selectedFiles;
+ }
+
+ /**
+ *
+ * @return
+ * The parameters used for the transformation
+ */
+ public Config getConfig() {
+ return config;
+ }
+
+ /**
+ *
+ * @return
+ * The selected files to be transformed
+ */
+ public Collection<Object> getTransformationFiles() {
+ return transformationFiles;
+ }
+
+ /**
+ *
+ * @param uncheckedFiles
+ * The selected files to be ignored during the transformation
+ */
+ public void setUncheckedFiles(Collection<Object> uncheckedFiles) {
+ this.uncheckedFiles = uncheckedFiles;
+ }
+
+ /**
+ *
+ * Update or create the selection map stored inside the configuration file in order to remember the previous selection choices
+ *
+ */
+ public void setSelectionMap() {
+ // Retrieve or create the list of unselected elements
+ if (getUnSelectionArray() != null) {
+ unselectedFiles = new LinkedList<String>(Arrays.asList(getUnSelectionArray()));
+ }
+ else {
+ unselectedFiles = new LinkedList<String>();
+ }
+ // 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);
+ if (!unselectedFiles.contains(filePath)) {
+ unselectedFiles.add(filePath);
+ }
+ }
+ }
+ // 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);
+ if (unselectedFiles.contains(filePath)) {
+ unselectedFiles.remove(filePath);
+ }
+ }
+ }
+
+ // Update the map
+ dialogSection.put(TransformationWizardConstants.SELECTION_KEY, unselectedFiles.toArray(new String[unselectedFiles.size()]));
+ }
+
+ /**
+ *
+ * Used to set the checked state of the selected files inside the viewer
+ *
+ * @return
+ * The user's previously unchecked files in the configPage
+ */
+ public String[] getUnSelectionArray() {
+ return dialogSection.getArray(TransformationWizardConstants.SELECTION_KEY);
+ }
+
+}
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
index 4eadb31d0de..f7a38043b44 100644
--- 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
@@ -28,16 +28,17 @@ 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.messages.Messages;
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;
@@ -50,31 +51,54 @@ 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;
- private LabelProviderService labelProviderService;
+ protected LabelProviderService labelProviderService;
+
+ protected ILabelProvider labelProvider;
- private ILabelProvider labelProvider;
+ protected WorkspaceContentProvider contentProvider;
- private WorkspaceContentProvider contentProvider;
+ protected ISelectionChangedListener listListener;
protected final List<String> filterNames;
protected final List<String> filterExtensions;
- private Button selectAll;
+ protected Button selectAll;
- private Button deselectAll;
+ protected Button deselectAll;
protected SelectionListener buttonListener;
protected Collection<Object> selectedFiles;
- FillLayout layout;
+ 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));
@@ -89,7 +113,37 @@ public class SelectionTreeComposite extends Composite {
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));
@@ -125,7 +179,7 @@ public class SelectionTreeComposite extends Composite {
treeViewer.setContentProvider(contentProvider);
treeViewer.setLabelProvider(labelProvider);
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ listListener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
@@ -135,14 +189,23 @@ public class SelectionTreeComposite extends Composite {
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;
@@ -166,12 +229,7 @@ public class SelectionTreeComposite extends Composite {
}
- public TreeViewer getTreeViewer() {
- return treeViewer;
- }
-
-
- public void setFilters(String[] filterExtensions, String[] filterNames) {
+ 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);
@@ -190,21 +248,26 @@ public class SelectionTreeComposite extends Composite {
return filters;
}
- public void setFilterExtensions(String[] filterExtensions) {
+ protected void setFilterExtensions(String[] filterExtensions) {
this.filterExtensions.clear();
this.filterExtensions.addAll(Arrays.asList(filterExtensions));
}
- public void setFilterNames(String[] filterNames) {
+ protected void setFilterNames(String[] filterNames) {
this.filterNames.clear();
this.filterNames.addAll(Arrays.asList(filterNames));
}
+ public TreeViewer getTreeViewer() {
+ return treeViewer;
+ }
+
/**
*
- * Fill the composite with the selection buttons
+ * Fills the composite with the selection buttons
*
* @param parent
+ * The parent composite
*/
public void createSelectionButtons(Composite parent) {
Composite buttonsComposite = new Composite(parent, SWT.NONE);
@@ -217,28 +280,36 @@ public class SelectionTreeComposite extends Composite {
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("Select All");
+ 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("Deselect All");
+ 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);
@@ -250,11 +321,11 @@ public class SelectionTreeComposite extends Composite {
/**
*
- * Get all the files from the user's selection in the viewer
+ * Gets all the files from the user's selection in the viewer
*
* @param nestedElements
*/
- public void getNestedFiles(Object[] nestedElements) {
+ protected void getNestedFiles(Object[] nestedElements) {
Collection<Object> projectList = new LinkedList<Object>();
Collection<Object> folderList = new LinkedList<Object>();
List<PatternViewerFilter> currentFilters = new ArrayList<PatternViewerFilter>();
@@ -316,6 +387,9 @@ public class SelectionTreeComposite extends Composite {
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 2164d12f97d..ddf6662c839 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
@@ -11,41 +11,43 @@
*****************************************************************************/
package org.eclipse.papyrus.migration.rsa.wizard.pages;
-import java.util.Collection;
-import java.util.LinkedList;
-
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.Config;
-import org.eclipse.papyrus.migration.rsa.RSAToPapyrusParameters.RSAToPapyrusParametersFactory;
+import org.eclipse.papyrus.migration.rsa.messages.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-
+/**
+ *
+ * Page displaying the selected elements and the migration's configuration options
+ *
+ * @author Quentin Le Menez
+ *
+ */
public class TransformationConfigPage extends WizardPage {
- protected Config config;
-
- protected Collection<Object> transformationFiles;
+ protected ConfigurationComposite configComposite;
- ConfigurationComposite configComposite;
+ protected DialogData dialogData;
/**
*
* Constructor.
*
- * @param selectedFiles
+ * @param dialogData
+ * The instance used to get the previously selected files from both the settings file and the previous page selection,
+ * as well as the configuration used to display the transformation options
*/
- public TransformationConfigPage() {
- super("Parameters selection"); //$NON-NLS-1$
- setTitle("Define the transformation parameters"); //$NON-NLS-1$
- setDescription("Select the files and the configuration options for the transformation"); //$NON-NLS-1$
+ public TransformationConfigPage(DialogData dialogData) {
+ super(Messages.TransformationConfigPage_Name);
+ setTitle(Messages.TransformationConfigPage_Title);
+ setDescription(Messages.TransformationConfigPage_Description);
// String iconPath = "icons/import_wiz_75x66.png"; //$NON-NLS-1$
// ImageDescriptor imgDescriptior = Activator.getDefault().getImageDescriptor(iconPath);
// setImageDescriptor(imgDescriptior);
- transformationFiles = new LinkedList<Object>();
- config = RSAToPapyrusParametersFactory.eINSTANCE.createConfig();
+
+ this.dialogData = dialogData;
}
@Override
@@ -54,22 +56,18 @@ public class TransformationConfigPage extends WizardPage {
Composite pageComposite = new Composite(parent, SWT.NONE);
pageComposite.setLayout(new GridLayout());
- configComposite = new ConfigurationComposite(pageComposite, SWT.NONE, config);
+ configComposite = new ConfigurationComposite(pageComposite, SWT.NONE, dialogData);
setControl(pageComposite);
}
- public Collection<Object> getTransformationFiles() {
- return configComposite.getTransformationFiles();
- }
-
- public Config getConfig() {
- return configComposite.getConfig();
- }
-
- public void setViewerInput(Collection<Object> selectedFiles) {
- configComposite.setViewerInput(selectedFiles);
+ /**
+ *
+ * Used to update the input of the nested composite's viewer
+ *
+ */
+ public void resetViewerInput() {
+ configComposite.setViewerInput(dialogData.getSelectedFiles());
}
-
}
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 95a49c9901e..a93a6d0fe02 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
@@ -11,33 +11,39 @@
*****************************************************************************/
package org.eclipse.papyrus.migration.rsa.wizard.pages;
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.papyrus.migration.rsa.messages.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+/**
+ *
+ * Page displaying the workspace and its elements
+ *
+ * @author Quentin Le Menez
+ *
+ */
public class TransformationSelectionPage extends WizardPage {
- SelectionTreeComposite treeComposite;
-
- Collection<Object> selectedFiles;
-
- String[] extensions = { "*", "*.emx", "*.epx", "*.epx;*.emx" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- String[] extensionsNames = { "All", "*.emx", "*.epx", "*.epx and *.emx" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- public TransformationSelectionPage() {
- super("Workspace selection");
- setTitle("Select a scope for the transformation");
- setDescription("Select the folders or files for the transformation");
+ protected DialogData dialogData;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param dialogData
+ * The instance used to get the selection from the workspace and the filters
+ */
+ public TransformationSelectionPage(DialogData dialogData) {
+ super(Messages.TransformationSelectionPage_Name);
+ setTitle(Messages.TransformationSelectionPage_Title);
+ setDescription(Messages.TransformationSelectionPage_Description);
// String iconPath = "icons/import_wiz_75x66.png"; //$NON-NLS-1$
// ImageDescriptor imgDescriptior = Activator.getDefault().getImageDescriptor(iconPath);
// setImageDescriptor(imgDescriptior);
- selectedFiles = new LinkedList<Object>();
+ this.dialogData = dialogData;
}
@Override
@@ -46,17 +52,9 @@ public class TransformationSelectionPage extends WizardPage {
Composite pageComposite = new Composite(parent, SWT.NONE);
pageComposite.setLayout(new GridLayout());
- treeComposite = new SelectionTreeComposite(pageComposite, SWT.NONE, extensions, extensionsNames);
+ new SelectionTreeComposite(pageComposite, SWT.NONE, dialogData);
setControl(pageComposite);
}
- public TreeViewer getTreeViewer() {
- return treeComposite.getTreeViewer();
- }
-
- public Collection<Object> getSelectedFiles() {
- return treeComposite.getSelectedFiles();
- }
-
}

Back to the top