Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2018-09-18 08:24:06 -0400
committerPatrick Tessier2018-09-24 04:44:39 -0400
commit4a72be5d308762ef1e329cbee86b0dc7956fae61 (patch)
treeced351ae86aa52f5a67f35353764653d34e88996
parent8ce938a4e2d790abb481a0d55f013736d9cb5a53 (diff)
downloadorg.eclipse.papyrus-4a72be5d308762ef1e329cbee86b0dc7956fae61.tar.gz
org.eclipse.papyrus-4a72be5d308762ef1e329cbee86b0dc7956fae61.tar.xz
org.eclipse.papyrus-4a72be5d308762ef1e329cbee86b0dc7956fae61.zip
Bug 539181 - [Toolsmiths][ProfileMigrationTool] The UI should be improve
* Improve dialog when the tool is launched * Improve the layout of the preference page * Manage preferences when the user hit the Cancel button Change-Id: Ida85c1d552f97e0c71bb0228ec0574c5b1cfec9e Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
-rw-r--r--plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/images/userDoc/Papyrus_SelectOldProfile.pngbin0 -> 21390 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/profileMigrationToolUserDoc.mediawiki7
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF2
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml2
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/Messages.java9
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/dialogs/ProfileMigrationToolConfigurationDialog.java241
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/messages.properties9
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/preferences/ProfileMigrationPreferencePage.java45
-rw-r--r--plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration/src/org/eclipse/papyrus/toolsmiths/profilemigration/MigratorProfileApplication.java101
9 files changed, 367 insertions, 49 deletions
diff --git a/plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/images/userDoc/Papyrus_SelectOldProfile.png b/plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/images/userDoc/Papyrus_SelectOldProfile.png
new file mode 100644
index 00000000000..b002af94233
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/images/userDoc/Papyrus_SelectOldProfile.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/profileMigrationToolUserDoc.mediawiki b/plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/profileMigrationToolUserDoc.mediawiki
index 7523681fb79..acf82cb83bb 100644
--- a/plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/profileMigrationToolUserDoc.mediawiki
+++ b/plugins/doc/org.eclipse.papyrus.toolsmiths.profilemigration.doc/src/site/mediawiki/profileMigrationToolUserDoc.mediawiki
@@ -3,11 +3,13 @@ This tool is providing a way to migrate profiled model from a profile version V1
=How to use it=
==Run the migration==
-To run the migration, you just have to '''open the profiled model''' which have to be migrated. The following pop-up will appear, then you just have to select one or many profiles you want to migrate and click on "OK".
+If the Profile migration tool is selected in preferences (see [[#Configuration]], to run the migration, you just have to '''open the profiled model''' which have to be migrated. The following pop-up will appear, then you just have to select one or many profiles you want to migrate and click on "OK".
[[File:images/userDoc/Papyrus_SomeProfilesHaveChanged.png|frame|none|Pop-up asking which profile the user want to migrate]]
-Since the tool is base on the comparison of the old version of the model and the new one, the tool will ask you to select the file corresponding to the profile before modifications. Then the tool will start the migration and if necessary ask you to make some choice.
+Since the tool is base on the comparison of the old version of the model and the new one, the tool will ask you to select the file corresponding to the profile before modifications (pop-up in the following image). Then the tool will start the migration and if necessary ask you to make some choice.
+
+[[File:images/userDoc/Papyrus_SelectOldProfile.png|frame|none|Pop-up asking which profile the user want to migrate]]
==Migration actions==
The tool will determine some actions of migration according to differences between the two version of the profile. Some of this actions will be manage automatically for example: when the ''isUnique'' feature of a property is set to true then the Profile Migration Tool will delete every duplicated values in each slot corresponding to this property. However, some action can't be done without choices of the user.
@@ -39,7 +41,6 @@ In the following lines you will see each case where the tool will ask you to do
[[File:images/userDoc/Papyrus_LowerMultiplicity.png|frame|none|Pop-up add or remove values to match with the new multiplicity]]
'''Note''': note that for each pop-up display you free to tick the box ''"do not show this pop-up again"''. You can still display it again by using preferences (see [[#Configuration]])
-
=Configuration=
To configure the profile migration tool there is two interesting preference pages.
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF
index a6a40e03e59..5c33d841f44 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.papyrus.toolsmiths.profilemigration.ui;singleton:=true
-Bundle-Version: 0.7.0.qualifier
+Bundle-Version: 0.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.ui,
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml
index 7cd452931d5..d9c63cc4812 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.toolsmiths.profilemigration.ui</artifactId>
- <version>0.7.0-SNAPSHOT</version>
+ <version>0.8.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/Messages.java b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/Messages.java
index e5bf431f0c1..b82db7d224a 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/Messages.java
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/Messages.java
@@ -53,8 +53,17 @@ public class Messages extends NLS {
public static String ProfileMigrationPreferenceConstants_ProfileMove;
public static String ProfileMigrationPreferenceConstants_StereotypeMove;
public static String ProfileMigrationPreferenceConstants_SuperStereotypeBecomingAbstract;
+ public static String ProfileMigrationPreferencePage_deleteCachedFileTooptip;
public static String ProfileMigrationPreferencePage_FileInCached;
public static String ProfileMigrationPreferencePage_ShowDialogs;
+ public static String ProfileMigrationToolConfigurationDialog_FileSelectionSelectionDescription;
+ public static String ProfileMigrationToolConfigurationDialog_FileSelection;
+ public static String ProfileMigrationToolConfigurationDialog_FileSelectionSelectionTitle;
+ public static String ProfileMigrationToolConfigurationDialog_ImportButtonName;
+ public static String ProfileMigrationToolConfigurationDialog_ImportButtonTooltip;
+ public static String ProfileMigrationToolConfigurationDialog_SkipButtonName;
+ public static String ProfileMigrationToolConfigurationDialog_SkipButtonTooltip;
+ public static String ProfileMigrationToolConfigurationDialog_Title;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/dialogs/ProfileMigrationToolConfigurationDialog.java b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/dialogs/ProfileMigrationToolConfigurationDialog.java
new file mode 100644
index 00000000000..58a509d92d1
--- /dev/null
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/dialogs/ProfileMigrationToolConfigurationDialog.java
@@ -0,0 +1,241 @@
+/*****************************************************************************
+ * Copyright (c) 2018 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.toolsmiths.profilemigration.ui.dialogs;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.toolsmiths.profilemigration.ui.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * This dialog ask the use to select the old file
+ */
+public class ProfileMigrationToolConfigurationDialog extends FormDialog {
+
+ /**
+ * Skip press return value
+ */
+ public static final int SKIP = 3;
+
+ /**
+ * Widget to access directory browsing
+ */
+ protected Button selectTargetDirectoryButton;
+
+ /**
+ * Widget to display the selected paths
+ */
+ protected Text selectedPathText;
+
+ /**
+ * The selected file path
+ */
+ protected String filePath;
+
+ /**
+ * The Profile name
+ */
+ protected String profileName;
+
+ /**
+ * Files to appear in the selection dialog
+ */
+ protected String fileExtension;
+
+ protected final static String IMPORT_FILE_BUTTON_NAME = Messages.ProfileMigrationToolConfigurationDialog_ImportButtonName;
+
+ protected final static String IMPORT_FILE_BUTTON_TOOLTIP = Messages.ProfileMigrationToolConfigurationDialog_ImportButtonTooltip;
+
+ protected final static String SKIP_BUTTON_NAME = Messages.ProfileMigrationToolConfigurationDialog_SkipButtonName;
+
+ protected final static String SKIP_BUTTON_TOOLTIP = Messages.ProfileMigrationToolConfigurationDialog_SkipButtonTooltip;
+
+ protected final static String DIALOG_TITLE = Messages.ProfileMigrationToolConfigurationDialog_Title;
+
+ protected final static String FILE_SELECTION_SECTION_TITLE = Messages.ProfileMigrationToolConfigurationDialog_FileSelectionSelectionTitle;
+
+ protected final static String FILE_SELECTION_SECTION_DESCRIPTION = Messages.ProfileMigrationToolConfigurationDialog_FileSelectionSelectionDescription;
+
+ private final static String EMPTY_STRING = ""; //$NON-NLS-1$
+
+
+ public ProfileMigrationToolConfigurationDialog(Shell parentShell, String profileName) {
+ super(parentShell);
+ this.fileExtension = "*.profile.uml"; //$NON-NLS-1$
+ this.filePath = EMPTY_STRING;
+ this.profileName = profileName;
+ }
+
+ /**
+ * Disable the Ok button (since the path is empty)
+ *
+ * @see org.eclipse.ui.forms.FormDialog#createButtonBar(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Control control = super.createButtonBar(parent);
+ this.getButton(IDialogConstants.OK_ID).setEnabled(false);
+ return control;
+ }
+
+ /**
+ * Add the skip button to the button bar
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ Button button = createButton(parent, IDialogConstants.SKIP_ID, SKIP_BUTTON_NAME, true);
+ button.setToolTipText(SKIP_BUTTON_TOOLTIP);
+ super.createButtonsForButtonBar(parent);
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm mform) {
+ mform.getForm().setText(DIALOG_TITLE);
+ ScrolledForm scrolledForm = mform.getForm();
+ FormToolkit toolkit = mform.getToolkit();
+ Composite parent = scrolledForm.getBody();
+ parent.setLayout(new GridLayout());
+ createSelectionFileSection(scrolledForm.getBody(), toolkit);
+ }
+
+ @Override
+ protected void buttonPressed(int buttonId) {
+ super.buttonPressed(buttonId);
+ if (buttonId == IDialogConstants.SKIP_ID) {
+ skipPress();
+ }
+ }
+
+ /**
+ * Create the file selection section
+ *
+ * @param body
+ * @param toolkit
+ */
+ private void createSelectionFileSection(Composite body, FormToolkit toolkit) {
+ String lSectionTitle = FILE_SELECTION_SECTION_TITLE;
+ Section lSection = toolkit.createSection(body, ExpandableComposite.EXPANDED | ExpandableComposite.TITLE_BAR);
+ lSection.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ if (lSectionTitle != null) {
+ lSection.setText(lSectionTitle);
+ }
+ ScrolledForm lInsideScrolledForm = toolkit.createScrolledForm(lSection);
+ lInsideScrolledForm.setExpandHorizontal(true);
+ lInsideScrolledForm.setExpandVertical(true);
+ Composite lBody = lInsideScrolledForm.getBody();
+ GridLayout lLayout = new GridLayout();
+ lLayout.numColumns = 1;
+ lBody.setLayout(lLayout);
+ toolkit.createLabel(lBody, NLS.bind(FILE_SELECTION_SECTION_DESCRIPTION, profileName), SWT.WRAP);
+ lSection.setClient(lInsideScrolledForm);
+ createSelectDir(lBody, toolkit);
+ }
+
+ /**
+ * Create the text field and the button to select a file
+ *
+ * @param container
+ * @param toolkit
+ */
+ private void createSelectDir(Composite container, FormToolkit toolkit) {
+ Composite composite = new Composite(container, SWT.NONE);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, true));
+ composite.setBackground(container.getBackground());
+ GridLayout layout = new GridLayout(2, false);
+ composite.setLayout(layout);
+ selectTargetDirectoryButton = new Button(composite, SWT.PUSH);
+ selectTargetDirectoryButton.setText(IMPORT_FILE_BUTTON_NAME);
+ selectTargetDirectoryButton.setToolTipText(IMPORT_FILE_BUTTON_TOOLTIP);
+ selectTargetDirectoryButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ selectedPathText = new Text(composite, SWT.BORDER | SWT.PUSH);
+ selectedPathText.setText(EMPTY_STRING);
+ selectedPathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
+ selectTargetDirectoryButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Shell shell = container.getShell();
+ FileDialog fileDialog;
+ fileDialog = new FileDialog(shell, SWT.NONE);
+ fileDialog.setText(Messages.ProfileMigrationToolConfigurationDialog_FileSelection);
+ if (fileExtension != null && !fileExtension.isEmpty()) {
+ fileDialog.setFilterExtensions(new String[] { fileExtension, "*" }); //$NON-NLS-1$
+ }
+ String filePath = null;
+ if ((filePath = fileDialog.open()) != null) {
+ selectedPathText.setText(filePath);
+ ProfileMigrationToolConfigurationDialog.this.filePath = filePath;
+ }
+ checkInformation();
+ }
+ });
+ }
+
+ /**
+ * Get the file path
+ *
+ * @return the file path
+ */
+ public String getFilePath() {
+ return filePath;
+ }
+
+ /**
+ * Action when skip button press
+ */
+ protected void skipPress() {
+ setReturnCode(SKIP);
+ close();
+ }
+
+ /**
+ * Check if the path is valid, active the OK button if it is valid
+ *
+ * @return true if the path is valid, false otherwise
+ */
+ private boolean checkInformation() {
+ String text = selectedPathText.getText();
+ boolean validSelectedDirectory = text != null && text != EMPTY_STRING;
+ if (validSelectedDirectory) {
+ this.getButton(IDialogConstants.OK_ID).setEnabled(validSelectedDirectory);
+ } else {
+ this.getButton(IDialogConstants.OK_ID).setEnabled(validSelectedDirectory);
+ }
+ return validSelectedDirectory;
+ }
+}
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/messages.properties b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/messages.properties
index 88eb34f0262..38736332205 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/messages.properties
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/messages.properties
@@ -31,5 +31,14 @@ ProfileMigrationPreferenceConstants_PackageMove=A Package has been moved into an
ProfileMigrationPreferenceConstants_ProfileMove=A Profile has been moved into an unapplied Profile
ProfileMigrationPreferenceConstants_StereotypeMove=A Stereotype has been moved into an unapplied Profile
ProfileMigrationPreferenceConstants_SuperStereotypeBecomingAbstract=IsAbstract feature of Stereotype has been modified
+ProfileMigrationPreferencePage_deleteCachedFileTooptip=Delete the selected path from the cache
ProfileMigrationPreferencePage_FileInCached=File names keep in cached
ProfileMigrationPreferencePage_ShowDialogs=Show dialog for these actions
+ProfileMigrationToolConfigurationDialog_FileSelection=Select Files
+ProfileMigrationToolConfigurationDialog_FileSelectionSelectionDescription=Select the file corresponding to the profile {0} before modification
+ProfileMigrationToolConfigurationDialog_FileSelectionSelectionTitle=Profile before modification
+ProfileMigrationToolConfigurationDialog_ImportButtonName=Select file
+ProfileMigrationToolConfigurationDialog_ImportButtonTooltip=Select the file corresponding to the profile before modification
+ProfileMigrationToolConfigurationDialog_SkipButtonName=Skip
+ProfileMigrationToolConfigurationDialog_SkipButtonTooltip=Just reapply the profile with the new version
+ProfileMigrationToolConfigurationDialog_Title=Profile migration tool configuration
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/preferences/ProfileMigrationPreferencePage.java b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/preferences/ProfileMigrationPreferencePage.java
index 20ad8d0fa47..396e71066e9 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/preferences/ProfileMigrationPreferencePage.java
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration.ui/src/org/eclipse/papyrus/toolsmiths/profilemigration/ui/preferences/ProfileMigrationPreferencePage.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2017 CEA LIST.
+ * Copyright (c) 2017, 2018 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,6 +11,7 @@
*
* Contributors:
* Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Initial API and implementation
+ * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 539181
*
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.profilemigration.ui.preferences;
@@ -46,12 +47,12 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* Define the preference page for configuring the Profile migration tool
- *
+ *
* ----------------------
* list of check button to activate or not pop-up
* ----------------------
* list of cached file with a remove button
- *
+ *
*/
public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
@@ -64,6 +65,9 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
/** The list of files in cache */
private static List<String> cachedFiles = new ArrayList<>();
+ /** The original list of files in cache */
+ private static List<String> originalcachedFiles = new ArrayList<>();
+
/** The list of booleanFieldEditor one for each dialog type */
private List<BooleanFieldEditor> booleanFieldEditor;
@@ -84,6 +88,7 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
@Override
public void init(IWorkbench workbench) {
setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ originalcachedFiles = new ArrayList<>(cachedFiles);
}
@Override
@@ -93,6 +98,7 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
Group group = new Group(mainContainer, SWT.SCROLL_PAGE);
group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
group.setText(Messages.ProfileMigrationPreferencePage_FileInCached);
createTreeActionButtons(group);
createCachedFilesPart(group);
@@ -109,6 +115,7 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
protected void createFieldEditors() {
Group group = new Group(mainContainer, SWT.SCROLL_PAGE);
group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
group.setText(Messages.ProfileMigrationPreferencePage_ShowDialogs);
for (Entry<String, String> entry : ProfileMigrationPreferenceConstants.mapPrefConstToLabel.entrySet()) {
BooleanFieldEditor editor = new BooleanFieldEditor(entry.getKey(), entry.getValue(), group);
@@ -118,6 +125,29 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
}
}
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#performCancel()
+ *
+ * @return
+ */
+ @Override
+ public boolean performCancel() {
+ // set the original list of files
+ cachedFiles.clear();
+ cachedFiles.addAll(originalcachedFiles);
+ return super.performCancel();
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#performApply()
+ *
+ */
+ @Override
+ protected void performApply() {
+ // the new list of files is validate so the original list become the new one
+ originalcachedFiles = new ArrayList<>(cachedFiles);
+ super.performApply();
+ }
/**
* Create actions associate to tree viewer.
@@ -136,7 +166,7 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
/**
* Create cached file list
- *
+ *
* @param parent
* Composite where the treeViewer will be added
*/
@@ -155,7 +185,7 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
/**
* Method to create a button with an icon and no label.
- *
+ *
* @param parent
* the composite parent
* @param id
@@ -171,6 +201,7 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
Button button = new Button(parent, SWT.PUSH);
button.setFont(JFaceResources.getDialogFont());
button.setData(new Integer(id));
+ button.setToolTipText(Messages.ProfileMigrationPreferencePage_deleteCachedFileTooptip);
button.addSelectionListener(new SelectionAdapter() {
@Override
@@ -227,7 +258,7 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
/**
* Add file to the cache
- *
+ *
* @param fileName
*/
public static void addFile(String fileName) {
@@ -236,7 +267,7 @@ public class ProfileMigrationPreferencePage extends FieldEditorPreferencePage im
/**
* Get the cache file list
- *
+ *
* @return the cache file list
*/
public static List<String> getCachedFiles() {
diff --git a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration/src/org/eclipse/papyrus/toolsmiths/profilemigration/MigratorProfileApplication.java b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration/src/org/eclipse/papyrus/toolsmiths/profilemigration/MigratorProfileApplication.java
index c4536f18744..34f58a6e420 100644
--- a/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration/src/org/eclipse/papyrus/toolsmiths/profilemigration/MigratorProfileApplication.java
+++ b/plugins/toolsmiths/profilemigration/org.eclipse.papyrus.toolsmiths.profilemigration/src/org/eclipse/papyrus/toolsmiths/profilemigration/MigratorProfileApplication.java
@@ -12,6 +12,7 @@
* Contributors:
* Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Initial API and implementation
* Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 538928
+ * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 539181
*
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.profilemigration;
@@ -38,8 +39,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.edit.tree.TreeNode;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.osgi.util.NLS;
+import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.toolsmiths.profilemigration.factory.IMigratorFactory;
import org.eclipse.papyrus.toolsmiths.profilemigration.factory.MigratorFactory;
import org.eclipse.papyrus.toolsmiths.profilemigration.internal.data.structure.StereotypeApplicationRegistry;
@@ -48,10 +48,9 @@ import org.eclipse.papyrus.toolsmiths.profilemigration.internal.utils.AtomicMigr
import org.eclipse.papyrus.toolsmiths.profilemigration.internal.utils.DifferenceTreeBuilder;
import org.eclipse.papyrus.toolsmiths.profilemigration.migrators.ICompositeMigrator;
import org.eclipse.papyrus.toolsmiths.profilemigration.migrators.atomic.IAtomicMigrator;
+import org.eclipse.papyrus.toolsmiths.profilemigration.ui.dialogs.ProfileMigrationToolConfigurationDialog;
import org.eclipse.papyrus.toolsmiths.profilemigration.ui.preferences.ProfileMigrationPreferencePage;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Profile;
@@ -122,23 +121,45 @@ public class MigratorProfileApplication {
public List<EObject> reapplyProfile(Package package_, Profile profile) {
Resource profileAfterResource = profile.eResource();
- String path = getFileName(profile, profileAfterResource);
- if (path != null) {
+ String path = null;
+ Resource profileBeforeResource = null;
+
+ if (!isAlreadyInCached(profile, profileAfterResource)) {
+ ProfileMigrationToolConfigurationDialog dialog = new ProfileMigrationToolConfigurationDialog(getActiveShell(), profile.getQualifiedName());
+ int dialogResult = dialog.open();
+ switch (dialogResult) {
+ case Window.OK:
+ path = dialog.getFilePath();
+ if (path != null && path != "") { //$NON-NLS-1$
+ URI uri = URI.createFileURI(path);
+ ResourceSet profileBeforeResourceSet = new ResourceSetImpl();
+ profileBeforeResource = profileBeforeResourceSet.getResource(uri, true);
+ saveNewFileInCache(path, profileBeforeResource);
+ }
+ break;
+ case ProfileMigrationToolConfigurationDialog.SKIP:
+ package_.applyProfile(profile);
+ return newStereotypeApplication;
+ case Window.CANCEL:
+ default:
+ return newStereotypeApplication;
+ }
+ } else {
try {
+ path = cacheProfileToFile.get(((XMIResource) profileAfterResource).getID(profile));
URI uri = URI.createFileURI(path);
ResourceSet profileBeforeResourceSet = new ResourceSetImpl();
- Resource profileBeforeResource = profileBeforeResourceSet.getResource(uri, true);
- migrateNewAppliedProfile(package_, profile, profileBeforeResource, profileAfterResource);
+ profileBeforeResource = profileBeforeResourceSet.getResource(uri, true);
} catch (WrappedException e) {
// File is not found so restart reapply profile with asking the user
removeFilePathFromCached(path);
reapplyProfile(package_, profile);
}
- } else {
- MessageDialog message = new MessageDialog(Display.getDefault().getActiveShell(), "Incorect file", null, "The selected path is incorect so the profile will just be reapply.", MessageDialog.INFORMATION, new String[] { "OK" }, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- message.open();
- package_.applyProfile(profile);
}
+ if (path != null && profileBeforeResource != null) {
+ migrateNewAppliedProfile(package_, profile, profileBeforeResource, profileAfterResource);
+ }
+
return newStereotypeApplication;
}
@@ -293,43 +314,49 @@ public class MigratorProfileApplication {
return result;
}
- private String getFileName(Profile profile, Resource profileAfterResource) {
+ /**
+ * Check if there is already the registered file for this profile and update cacheProfileToFile property accordingly
+ *
+ * @param profile
+ * the migrated profile
+ * @param profileAfterResource
+ * the resource associate to tjis migrated profile
+ * @return true if the profile has already an associated file in the cache
+ */
+ private boolean isAlreadyInCached(Profile profile, Resource profileAfterResource) {
if (cacheProfileToFile.containsKey(((XMIResource) profileAfterResource).getID(profile))) {
String path = cacheProfileToFile.get(((XMIResource) profileAfterResource).getID(profile));
if (ProfileMigrationPreferencePage.getCachedFiles().contains(path)) {
- return path;
+ return true;
} else {
cacheProfileToFile.remove(((XMIResource) profileAfterResource).getID(profile));
+ return false;
}
}
+ return false;
+ }
- FileDialog dialog = new FileDialog(getActiveShell(), SWT.OPEN);
- dialog.setText(NLS.bind(Messages.MigratorProfileApplicationDelegate_SelectFileDialogTitle, profile.getName()));
- dialog.setFilterExtensions(new String[] { "*.profile.uml", "*" }); //$NON-NLS-1$ //$NON-NLS-2$
- dialog.setFilterNames(new String[] { "Profiles", "All" }); //$NON-NLS-1$ //$NON-NLS-2$
- String path = dialog.open();
-
- if (path != null) {
- // add all profile to the cache
- URI uri = URI.createFileURI(path);
- ResourceSet profileBeforeResourceSet = new ResourceSetImpl();
- Resource profileBeforeResource = profileBeforeResourceSet.getResource(uri, true);
- TreeIterator<EObject> iter = profileBeforeResource.getAllContents();
- while (iter.hasNext()) {
- EObject object = iter.next();
- if (object instanceof Package) {
- if (object instanceof Profile) {
- cacheProfileToFile.put(((XMIResource) profileBeforeResource).getID(object), path);
- if (!ProfileMigrationPreferencePage.getCachedFiles().contains(path)) {
- ProfileMigrationPreferencePage.addFile(path);
- }
+ /**
+ * Add all profiles contain by the file to the cache
+ *
+ * @param path
+ * the filePath
+ */
+ private void saveNewFileInCache(String path, Resource profileBeforeResource) {
+ TreeIterator<EObject> iter = profileBeforeResource.getAllContents();
+ while (iter.hasNext()) {
+ EObject object = iter.next();
+ if (object instanceof Package) {
+ if (object instanceof Profile) {
+ cacheProfileToFile.put(((XMIResource) profileBeforeResource).getID(object), path);
+ if (!ProfileMigrationPreferencePage.getCachedFiles().contains(path)) {
+ ProfileMigrationPreferencePage.addFile(path);
}
- } else {
- iter.prune();
}
+ } else {
+ iter.prune();
}
}
- return path;
}
/**

Back to the top