Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2015-05-13 14:21:43 +0000
committerCamille Letavernier2015-05-18 11:47:41 +0000
commitb82b959e52b223e6af4bd24a07894cfe1c9fbae4 (patch)
tree52b4354506966671f145adbc5583701671702197
parentb9f2c2a1c911e60625249a3a496b84540f915bea (diff)
downloadorg.eclipse.papyrus-b82b959e52b223e6af4bd24a07894cfe1c9fbae4.tar.gz
org.eclipse.papyrus-b82b959e52b223e6af4bd24a07894cfe1c9fbae4.tar.xz
org.eclipse.papyrus-b82b959e52b223e6af4bd24a07894cfe1c9fbae4.zip
Bug 467227: [Wizard] The new Model/Project wizard should remember the previous category selection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=467227 Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr> Change-Id: I8ad43dd5dcdd73f278ae2668d77a298c0b8c80ed Reviewed-on: https://git.eclipse.org/r/47851 Tested-by: Hudson CI Reviewed-by: Camille Letavernier <camille.letavernier@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java22
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/utils/SettingsHelper.java40
2 files changed, 49 insertions, 13 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java
index 23917413a15..3dc54987da0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectDiagramCategoryPage.java
@@ -62,6 +62,8 @@ public class SelectDiagramCategoryPage extends WizardPage {
/** The my allow several categories. */
private final boolean myAllowSeveralCategories;
+ private SettingsHelper settingsHelper;
+
/**
* Instantiates a new select diagram category page.
*
@@ -92,13 +94,19 @@ public class SelectDiagramCategoryPage extends WizardPage {
@Override
public void setWizard(IWizard newWizard) {
super.setWizard(newWizard);
- SettingsHelper settingsHelper = new SettingsHelper(getDialogSettings());
+ settingsHelper = new SettingsHelper(getDialogSettings());
String[] defaultDiagramCategory = settingsHelper.getDefaultDiagramCategories();
if (defaultDiagramCategory != null && defaultDiagramCategory.length > 0) {
if (myAllowSeveralCategories) {
setDefaultDiagramCategories(defaultDiagramCategory);
} else {
- setDefaultDiagramCategories(new String[] { defaultDiagramCategory[0] });
+ String previousSelection = settingsHelper.getPreviousSelection();
+ // Retrieves the previous selection or the selects the default behavior
+ if (settingsHelper.rememberCurrentSelection(getDialogSettings()) && previousSelection != null) {
+ setDefaultDiagramCategories(new String[] { previousSelection });
+ } else {
+ setDefaultDiagramCategories(new String[] { defaultDiagramCategory[0] });
+ }
}
}
}
@@ -181,9 +189,9 @@ public class SelectDiagramCategoryPage extends WizardPage {
protected boolean validateFileExtension(String... categories) {
IStatus status = ((CreateModelWizard) getWizard()).diagramCategoryChanged(categories);
switch (status.getSeverity()) {
- // case Status.ERROR:
- // setErrorMessage(status.getMessage());
- // return false;
+ // case Status.ERROR:
+ // setErrorMessage(status.getMessage());
+ // return false;
case Status.WARNING:
setMessage(status.getMessage(), IMessageProvider.WARNING);
break;
@@ -256,6 +264,10 @@ public class SelectDiagramCategoryPage extends WizardPage {
} else {
mySelectedDiagramCategoryIds.remove(category);
}
+
+ // Notifies the settings file that the selection has been set and to what
+ settingsHelper.saveRememberCurrentSelection(true);
+ settingsHelper.setCurrentSelection(category);
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/utils/SettingsHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/utils/SettingsHelper.java
index 460527a7557..1f28d479a92 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/utils/SettingsHelper.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/utils/SettingsHelper.java
@@ -38,7 +38,10 @@ public class SettingsHelper {
private static final String SETTINGS_KEY_DIAGRAM_TEMPLATES = "DiagramTemplatesFor_"; //$NON-NLS-1$
/** The Constant LAST_SELECTED_CATEGORY. */
- private static final String LAST_SELECTED_CATEGORY = "diagramCategory"; //$NON-NLS-1$
+ private static final String DIAGRAM_CATEGORIES = "diagramCategory"; //$NON-NLS-1$
+
+ /** The Constant used to access the last selected category */
+ private static final String SETTINGS_KEY_DIAGRAM_CATEGORY = "lastSelectedCategory"; //$NON-NLS-1$
/** The my settings. */
private final IDialogSettings mySettings;
@@ -59,17 +62,17 @@ public class SettingsHelper {
* @return the default diagram category
*/
public String[] getDefaultDiagramCategories() {
- return mySettings.getArray(LAST_SELECTED_CATEGORY);
+ return mySettings.getArray(DIAGRAM_CATEGORIES);
}
/**
* Save default diagram category.
*
* @param categories
- * the categories
+ * the categories
*/
public void saveDefaultDiagramCategory(String[] categories) {
- mySettings.put(LAST_SELECTED_CATEGORY, categories);
+ mySettings.put(DIAGRAM_CATEGORIES, categories);
}
/**
@@ -81,7 +84,7 @@ public class SettingsHelper {
*/
public List<String> getDefaultDiagramKinds(String category) {
String csl = mySettings.get(getKeyForDiagramKind(category));
- if(csl == null || csl.equals("")) { //$NON-NLS-1$
+ if (csl == null || csl.equals("")) { //$NON-NLS-1$
return Collections.emptyList();
}
List<String> result = new ArrayList<String>();
@@ -118,7 +121,7 @@ public class SettingsHelper {
*/
public List<String> getDefaultTemplates(String category) {
String csl = mySettings.get(getKeyForTemplate(category));
- if(csl == null || csl.equals("")) { //$NON-NLS-1$
+ if (csl == null || csl.equals("")) { //$NON-NLS-1$
return Collections.emptyList();
}
List<String> result = new ArrayList<String>();
@@ -168,10 +171,31 @@ public class SettingsHelper {
}
/**
+ * Puts the most recently selected category tag in the settings to retrieve it on the next execution
+ *
+ * @param category
+ * The language tag
+ */
+ public void setCurrentSelection(String category) {
+ mySettings.put(SETTINGS_KEY_DIAGRAM_CATEGORY, category);
+ }
+
+ /**
+ * Retrieves the most recently selected category tag from the settings
+ *
+ * @return
+ * The category tag
+ */
+ public String getPreviousSelection() {
+ return mySettings.get(SETTINGS_KEY_DIAGRAM_CATEGORY);
+ }
+
+
+ /**
* Gets the key for diagram kind.
*
* @param category
- * the category
+ * the category
* @return the key for diagram kind
*/
private String getKeyForDiagramKind(String category) {
@@ -182,7 +206,7 @@ public class SettingsHelper {
* Gets the key for template.
*
* @param category
- * the category
+ * the category
* @return the key for template
*/
private String getKeyForTemplate(String category) {

Back to the top