Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2014-01-16 15:18:36 +0000
committervlorenzo2014-01-16 15:18:36 +0000
commit226fc6f1a62ec5cdf57e6952284edb4c108d9c78 (patch)
tree418b1df097dac74f9edbdfd62586bb7a85b1fd8d /plugins/infra
parentf7dda07713b6ff343dfb5f9129bbb08b7cee30ad (diff)
downloadorg.eclipse.papyrus-226fc6f1a62ec5cdf57e6952284edb4c108d9c78.tar.gz
org.eclipse.papyrus-226fc6f1a62ec5cdf57e6952284edb4c108d9c78.tar.xz
org.eclipse.papyrus-226fc6f1a62ec5cdf57e6952284edb4c108d9c78.zip
425890: [Table2]/[Diagram] PapyrusPreferenceStore must be refactored to
be used by all Papyrus Editors https://bugs.eclipse.org/bugs/show_bug.cgi?id=425890 refactore the diagram preferences + add preferences support for table
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java6
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/PapyrusPreferenceStore.java213
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/Messages.java4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/messages.properties2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/AbstractPreferenceKeyDialog.java220
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java174
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java84
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java24
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java14
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java28
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/preferences/PapyrusTablePreferenceStore.java68
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/preferences/TablePreferencesConstantsHelper.java87
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/Messages.java8
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/messages.properties4
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/AbstractPapyrusPreferenceStore.java293
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/PapyrusScopedPreferenceStore.java (renamed from plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/PapyrusScopedPreferenceStore.java)12
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/ui/dialog/AbstractApplyValueOnPreferenceKeyDialog.java71
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/ui/dialog/AbstractPreferenceKeyDialog.java105
21 files changed, 962 insertions, 461 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java
index 333472d9390..1ff44b8c5a6 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/preferences/PreferencesConstantsHelper.java
@@ -50,17 +50,17 @@ public class PreferencesConstantsHelper {
/**
* Prefix for preference for Papyrus Level editor
*/
- public static String PAPYRUS_EDITOR_PREFERENCE_PREFIX = "PAPYRUS_EDITOR"; //$NON-NLS-1$
+ public final static String PAPYRUS_EDITOR_PREFERENCE_PREFIX = "PAPYRUS_EDITOR"; //$NON-NLS-1$
/**
* Prefix for preference for Diagram Level
*/
- public static String DIAGRAM_PREFERENCE_PREFIX = "DIAGRAM_"; //$NON-NLS-1$
+ public final static String DIAGRAM_PREFERENCE_PREFIX = "DIAGRAM_"; //$NON-NLS-1$
/**
* Prefix for preference for element Level
*/
- public static String DIAGRAM_ELEMENT = "ELEMENT_"; //$NON-NLS-1$
+ public final static String DIAGRAM_ELEMENT = "ELEMENT_"; //$NON-NLS-1$
private final static String COLOR = "color."; //$NON-NLS-1$
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF
index 7690f0eab37..f0102ff4fbd 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF
@@ -2,7 +2,8 @@ Manifest-Version: 1.0
Require-Bundle: org.eclipse.gmf.runtime.diagram.ui.properties,
org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
- com.ibm.icu
+ com.ibm.icu,
+ org.eclipse.papyrus.infra.tools;bundle-version="1.0.0"
Export-Package: org.eclipse.papyrus.infra.gmfdiag.preferences,
org.eclipse.papyrus.infra.gmfdiag.preferences.initializer,
org.eclipse.papyrus.infra.gmfdiag.preferences.jface.preference;x-internal:=true,
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/PapyrusPreferenceStore.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/PapyrusPreferenceStore.java
index 9aa7376e7c5..4b982b4cf8d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/PapyrusPreferenceStore.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/PapyrusPreferenceStore.java
@@ -13,239 +13,58 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.preferences;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
import org.eclipse.papyrus.infra.gmfdiag.preferences.ui.dialog.ApplyValueOnPreferenceKeyDialog;
+import org.eclipse.papyrus.infra.tools.preferences.AbstractPapyrusPreferenceStore;
+import org.eclipse.papyrus.infra.tools.preferences.ui.dialog.AbstractApplyValueOnPreferenceKeyDialog;
/**
* this class is a specific store that is used to look for value of element
* by taking account the structure of preferences : papyrus editor-> Diagram -> Elements of Diagram
*
*/
-public class PapyrusPreferenceStore extends PapyrusScopedPreferenceStore {
+public class PapyrusPreferenceStore extends AbstractPapyrusPreferenceStore {
/**
- * this method is used to overload all value under a level of preferences.
- * In order to overload a pop-up is opened, and the user can choose value to overload
*
- * @param level
- * of preference: Editor or diagram
- */
-
- public void deleteAllSubPreference(String level) {
- //remove all sub value diagram+ element
- ArrayList<String> keytoRemove = new ArrayList<String>();
- //key to collect
- ArrayList<String> elementKey = new ArrayList<String>();
- try {
- for(int i = 0; i < getStorePreferences().keys().length; i++) {
- //level diagram collect only element
- if(level.startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
- if(getStorePreferences().keys()[i].startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
- elementKey.add(getStorePreferences().keys()[i]);
- }
- }
- //editor level, collect all element+diagram
- else if(level.startsWith(PreferencesConstantsHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX)) {
- if((getStorePreferences().keys()[i].startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) || (getStorePreferences().keys()[i].startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX))) {
- elementKey.add(getStorePreferences().keys()[i]);
- }
- }
-
- }
-
- } catch (Exception e) {
- Activator.log.error(e);
- }
- if(elementKey.size() > 0) {
- String[] keyRoconsult = new String[elementKey.size()];
- ApplyValueOnPreferenceKeyDialog dialog = new ApplyValueOnPreferenceKeyDialog(elementKey.toArray(keyRoconsult));
- dialog.open();
- keytoRemove = dialog.getKeyToRemove();
-
- //remove key
- Iterator<String> iterator = keytoRemove.iterator();
- while(iterator.hasNext()) {
- String key = (String)iterator.next();
- getStorePreferences().remove(key);
- }
- }
- }
-
-
- /**
- * constructor
+ * Constructor.
*
* @param context
- * the scope to store to
* @param qualifier
- * the qualifier used to look up the preference node
- */
- public PapyrusPreferenceStore(IScopeContext context, String qualifier) {
- super(context, qualifier);
- }
-
- /**
- * constructor
- *
- * @param context
- * the scope to store to
- * @param qualifier
- * the qualifier used to look up the preference node
* @param defaultQualifierPath
- * the qualifier used when looking up the defaults
*/
public PapyrusPreferenceStore(IScopeContext context, String qualifier, String defaultQualifierPath) {
- super(context, qualifier, defaultQualifierPath);
+ super(context, qualifier, defaultQualifierPath, PreferencesConstantsHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX, PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX, PreferencesConstantsHelper.DIAGRAM_ELEMENT);
}
- // each get value will be overloaded
- //if not value is found for an element, a value is look for in DIAGRAM
- // if a the value is not find for Diagram a value is find for Papyrus editor
-
/**
- * this method is used to find a key that a got a value:
- * if the key is an element. The method look for if this key exist. If no value exists, it look for the key for diagram
- * if the key for diagram do not exist it look for key for papyrus Editor
- * the structure of Key is:
- * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
- * Diagram : DIAGRAM_DiagramKind.preferenceKind
- * Editor: PAPYRUS_EDITOR.preferenceKind
*
- */
- protected String findKeyWithAValue(String initialKey) {
- String foundedKey = null;
- //first look for in value stack
- foundedKey = findKeyAStoreValue(initialKey);
- //then look for in default stack
- if(foundedKey == null) {
- foundedKey = findKeyWithADefaultValue(initialKey);
- }
- if(foundedKey == null) {
- foundedKey = initialKey;
- }
- return foundedKey;
-
- }
-
- /**
- * look for a key with a value in the store stack
+ * Constructor.
*
- * @param initialKey
- * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
- * Diagram : DIAGRAM_DiagramKind.preferenceKind
- * Editor: PAPYRUS_EDITOR.preferenceKind
- * @return the key that returns a value or null if there is no value
+ * @param context
+ * @param qualifier
*/
- protected String findKeyAStoreValue(String initialKey) {
- String foundedKey = null;
- if(getStorePreferences().get(initialKey, null) != null) {
- foundedKey = initialKey;
- }
-
- if(foundedKey == null && hasPrefix(initialKey)) {
- foundedKey = findKeyAStoreValue(getUpperKey(initialKey));
- }
- return foundedKey;
+ public PapyrusPreferenceStore(IScopeContext context, String qualifier) {
+ super(context, qualifier, PreferencesConstantsHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX, PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX, PreferencesConstantsHelper.DIAGRAM_ELEMENT);
}
- /**
- * this method is used to find a key that a got a value:
- * if the key is an element. The method look for if this key exist. If no value exists, it look for the key for diagram
- * if the key for diagram do not exist it look for key for papyrus Editor
- * the structure of Key is:
- * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
- * Diagram : DIAGRAM_DiagramKind.preferenceKind
- * Editor: PAPYRUS_EDITOR.preferenceKind
- *
- */
- protected String findKeyWithADefaultValue(String initialKey) {
- String foundedKey = null;
-
- if(getDefaultPreferences().get(initialKey, null) != null) {
- foundedKey = initialKey;
- }
-
- if(foundedKey == null && hasPrefix(initialKey)) {
- return findKeyWithADefaultValue(getUpperKey(initialKey));
- } else {
- foundedKey = initialKey;
- }
- return foundedKey;
-
- }
/**
- * get the upper Key from the initial Key
- * * the structure of Key is:
- * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
- * Diagram : DIAGRAM_DiagramKind.preferenceKind
- * Editor: PAPYRUS_EDITOR.preferenceKind
*
- * @param initialKey
- * @return the upperKey
+ * @see org.eclipse.papyrus.infra.tools.preferences.AbstractPapyrusPreferenceStore#createPreferenceKeyDialog(java.lang.String[])
*
+ * @param keys
+ * @return
*/
- protected String getUpperKey(String initialKey) {
-
- String out = initialKey.toString();
- if(initialKey.startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
- out = initialKey.toString().replaceAll(PreferencesConstantsHelper.DIAGRAM_ELEMENT, PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX);
- out = out.substring(0, out.lastIndexOf("_")) + out.substring(out.indexOf("."), out.length());
- }
- if(initialKey.startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
- // out=initialKey.toString().replaceAll(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX, PreferencesConstantsHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX);
- out = PreferencesConstantsHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX + out.substring(out.indexOf("."), out.length());
- }
- return out;
+ @Override
+ protected AbstractApplyValueOnPreferenceKeyDialog createPreferenceKeyDialog(String[] keys) {
+ return new ApplyValueOnPreferenceKeyDialog(keys);
}
- protected boolean hasPrefix(String key) {
- if(key.startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT) || key.startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
- return true;
- }
- return false;
- }
- /**
- * get the value from a key
- *
- * @param key
- * @return the value
- */
- protected String internalGet(String key) {
- String newKey = findKeyWithAValue(key);
- //System.err.println("-->Initial Key "+key+"--> "+ newKey);
- return Platform.getPreferencesService().get(newKey, null, getPreferenceNodes(true));
- }
-
- public boolean getDefaultBoolean(String name) {
-
- return super.getDefaultBoolean(findKeyWithADefaultValue(name));
- }
- public double getDefaultDouble(String name) {
- return super.getDefaultDouble(findKeyWithADefaultValue(name));
- }
-
- public float getDefaultFloat(String name) {
- return super.getDefaultFloat(findKeyWithADefaultValue(name));
- };
-
- public int getDefaultInt(String name) {
- return super.getDefaultInt(findKeyWithADefaultValue(name));
- }
- public long getDefaultLong(String name) {
- return super.getDefaultLong(findKeyWithADefaultValue(name));
- }
- public String getDefaultString(String name) {
- return super.getDefaultString(findKeyWithADefaultValue(name));
- }
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/Messages.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/Messages.java
index 1db6cf676fb..181355afe8a 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/Messages.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/Messages.java
@@ -19,6 +19,10 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.gmfdiag.preferences.messages.messages"; //$NON-NLS-1$
+ public static String ApplyValueOnPreferenceKeyDialog_DIAGRAM;
+
+ public static String ApplyValueOnPreferenceKeyDialog_ELEMENT;
+
public static String LabelGroup_Labels_To_Display;
public static String RulersAndGridGroup_GridColor;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/messages.properties
index 32eec8f4ccd..f84dfb59fe8 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/messages.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/messages/messages.properties
@@ -2,6 +2,8 @@ LabelGroup_Labels_To_Display=Labels to display
RulersAndGridGroup_GridColor=Grid Color
RulersAndGridGroup_GridInFront=Grid In Front
RulersAndGridGroup_GridStyle=Grid Style
+ApplyValueOnPreferenceKeyDialog_DIAGRAM=DIAGRAM
+ApplyValueOnPreferenceKeyDialog_ELEMENT=ELEMENT
RulersAndGridGroup_GridColor=Grid Color
RulersAndGridGroup_GridInFront=Grid In Front
RulersAndGridGroup_GridStyle=Grid Style
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/AbstractPreferenceKeyDialog.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/AbstractPreferenceKeyDialog.java
deleted file mode 100644
index 6f44dee5bdb..00000000000
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/AbstractPreferenceKeyDialog.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.preferences.ui.dialog;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableColorProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
-import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * The Class AbstractPreferenceKeyDialog display all preference key that are given in parameters
- */
-public class AbstractPreferenceKeyDialog extends org.eclipse.jface.dialogs.StatusDialog {
-
- /** The key table. */
- protected Table keyTable;
-
- /** The table viewer. */
- protected TableViewer tableViewer;
-
- /** The keys. */
- protected String[] keys;
-
- /**
- * Instantiates a new abstract preference key dialog.
- *
- * @param keys
- * the array of preference jy to display
- */
- public AbstractPreferenceKeyDialog(String[] keys) {
- super(new Shell());
- this.keys = keys;
- setStatusLineAboveButtons(true);
- updateStatus(new Status(IStatus.INFO, Activator.PLUGIN_ID, "Would you like to overload those preferences?"));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite)super.createDialogArea(parent);
- keyTable = new Table(composite, SWT.CHECK | SWT.BORDER);
- tableViewer = new TableViewer(keyTable);
- tableViewer.setLabelProvider(new KeyLabelProvider());
- tableViewer.setContentProvider(new KeyContentProvider());
-
- TableColumn column = new TableColumn(keyTable, SWT.NONE);
- column.setWidth(150);
- column.setText("Pref. kind ");
-
- column = new TableColumn(keyTable, SWT.NONE);
- column.setWidth(90);
- column.setText("Level");
-
- column = new TableColumn(keyTable, SWT.NONE);
- column.setWidth(200);
- column.setText("Localization");
- tableViewer.setInput(keys);
- keyTable.setHeaderVisible(true);
-
-
- return composite;
-
- }
-
- /**
- * The Class KeyLabelProvider.
- */
- protected class KeyLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider {
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int)
- */
- public Color getForeground(Object element, int columnIndex) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int)
- */
- public Color getBackground(Object element, int columnIndex) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- if(columnIndex == 0) {
- if(element.toString().startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
- return Activator.getPluginIconImage(Activator.PLUGIN_ID, "/icons/pref.gif");
- }
- if(element.toString().startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
- return Activator.getPluginIconImage(Activator.PLUGIN_ID, "/icons/diag.gif");
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- String initialKey = element.toString();
- String out = initialKey.toString();
- if(columnIndex == 0) {
- out = out.substring(out.indexOf(".") + 1, out.length()).toUpperCase();
- }
- if(columnIndex == 1) {
- if(element.toString().startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
- return "ELEMENT";
- }
- if(element.toString().startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
- return "DIAGRAM";
- }
- }
- if(columnIndex == 2) {
- if(initialKey.startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
- out = initialKey.toString().replaceAll(PreferencesConstantsHelper.DIAGRAM_ELEMENT, "");
- // Reorganize display
- if(out.indexOf(".") > 0) {
- String beforePoint = out.substring(0, out.indexOf("."));
- if(beforePoint.lastIndexOf("_") > 0) {
- out = out.substring(beforePoint.lastIndexOf("_") + 1, out.indexOf(".")) + " (" + beforePoint.substring(0, beforePoint.lastIndexOf("_")) + ")";
- }
- }
- }
- if(initialKey.startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
- out = initialKey.toString().replaceAll(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX, "");
- out = out.substring(0, out.indexOf("."));
- }
- }
- return out;
- }
- }
-
-
- /**
- * The Class KeyContentProvider.
- */
- protected class KeyContentProvider implements IStructuredContentProvider {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- ArrayList<String> result = new ArrayList<String>();
- for(int i = 0; i < keys.length; i++) {
- if(keys[i].startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
- result.add(keys[i]);
- }
- if(keys[i].startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
- result.add(keys[i]);
- }
- }
- return result.toArray();
- }
-
- }
-
-}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java
index 8587f0f91e5..aadcc60934b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java
@@ -15,61 +15,169 @@ package org.eclipse.papyrus.infra.gmfdiag.preferences.ui.dialog;
import java.util.ArrayList;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.preferences.messages.Messages;
+import org.eclipse.papyrus.infra.tools.preferences.ui.dialog.AbstractApplyValueOnPreferenceKeyDialog;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+
/**
* The Class ApplyValueOnPreferenceKeyDialog display all the preference key and give all selected keys
*/
-public class ApplyValueOnPreferenceKeyDialog extends AbstractPreferenceKeyDialog {
-
- /** The checked key. */
- protected ArrayList<String> checkedKey;
+public class ApplyValueOnPreferenceKeyDialog extends AbstractApplyValueOnPreferenceKeyDialog {
- /**
- * Instantiates a new apply value on preference key dialog.
- *
- * @param keys
- * the keys
- */
public ApplyValueOnPreferenceKeyDialog(String[] keys) {
super(keys);
- checkedKey = new ArrayList<String>();
- // TODO Auto-generated constructor stub
}
/**
- * Gets the key to remove.
- *
- * @return the key to remove
+ *
*/
- public ArrayList<String> getKeyToRemove() {
- return checkedKey;
+ @Override
+ protected IBaseLabelProvider createLabelProvider() {
+ return new KeyLabelProvider();
}
- /*
- * (non-Javadoc)
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.tools.preferences.ui.dialog.AbstractPreferenceKeyDialog#createContentProvider()
*
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ * @return
*/
@Override
- protected void okPressed() {
+ protected IContentProvider createContentProvider() {
+ return new KeyContentProvider();
+ }
+
+ /**
+ * The Class KeyLabelProvider.
+ */
+ protected static class KeyLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int)
+ */
+ public Color getForeground(Object element, int columnIndex) {
+ //nothing to do
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int)
+ */
+ public Color getBackground(Object element, int columnIndex) {
+ //nothing to do
+ return null;
+ }
- for(int i = 0; i < keyTable.getItems().length; i++) {
- if(keyTable.getItems()[i].getChecked()) {
- checkedKey.add((String)keyTable.getItems()[i].getData());
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ if(columnIndex == 0) {
+ if(element.toString().startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
+ return Activator.getPluginIconImage(Activator.PLUGIN_ID, "/icons/pref.gif"); //$NON-NLS-1$
+ }
+ if(element.toString().startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ return Activator.getPluginIconImage(Activator.PLUGIN_ID, "/icons/diag.gif"); //$NON-NLS-1$
+ }
}
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ String initialKey = element.toString();
+ String out = initialKey.toString();
+ if(columnIndex == 0) {
+ out = out.substring(out.indexOf(".") + 1, out.length()).toUpperCase(); //$NON-NLS-1$
+ }
+ if(columnIndex == 1) {
+ if(element.toString().startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
+ return Messages.ApplyValueOnPreferenceKeyDialog_ELEMENT;
+ }
+ if(element.toString().startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ return Messages.ApplyValueOnPreferenceKeyDialog_DIAGRAM;
+ }
+ }
+ if(columnIndex == 2) {
+ if(initialKey.startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
+ out = initialKey.toString().replaceAll(PreferencesConstantsHelper.DIAGRAM_ELEMENT, ""); //$NON-NLS-1$
+ // Reorganize display
+ if(out.indexOf(".") > 0) { //$NON-NLS-1$
+ String beforePoint = out.substring(0, out.indexOf(".")); //$NON-NLS-1$
+ if(beforePoint.lastIndexOf("_") > 0) { //$NON-NLS-1$
+ out = out.substring(beforePoint.lastIndexOf("_") + 1, out.indexOf(".")) + " (" + beforePoint.substring(0, beforePoint.lastIndexOf("_")) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+ }
+ }
+ if(initialKey.startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ out = initialKey.toString().replaceAll(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX, ""); //$NON-NLS-1$
+ out = out.substring(0, out.indexOf(".")); //$NON-NLS-1$
+ }
+ }
+ return out;
}
- super.okPressed();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+
+ /**
+ * The Class KeyContentProvider.
*/
- @Override
- protected void cancelPressed() {
- super.cancelPressed();
- checkedKey = new ArrayList<String>();
+ protected class KeyContentProvider implements IStructuredContentProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ ArrayList<String> result = new ArrayList<String>();
+ for(int i = 0; i < keys.length; i++) {
+ if(keys[i].startsWith(PreferencesConstantsHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ result.add(keys[i]);
+ }
+ if(keys[i].startsWith(PreferencesConstantsHelper.DIAGRAM_ELEMENT)) {
+ result.add(keys[i]);
+ }
+ }
+ return result.toArray();
+ }
+
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
index 8f301af0ce2..c61647079cf 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/editor/AbstractEMFNattableEditor.java
@@ -14,11 +14,14 @@
package org.eclipse.papyrus.infra.nattable.common.editor;
+import java.io.IOException;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
@@ -58,6 +61,13 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
private PartNameSynchronizer synchronizer;
/**
+ * the workspace preference store for this table editor
+ */
+ @SuppressWarnings("unused")
+ //not yet used in the table
+ private PreferenceStore workspacePreferenceStore;
+
+ /**
* @param servicesRegistry
* @param rawModel
*
@@ -66,8 +76,69 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
this.servicesRegistry = servicesRegistry;
this.tableManager = new NattableModelManager(rawModel);
this.synchronizer = new PartNameSynchronizer(rawModel);
+ this.workspacePreferenceStore = getWorkspaceViewerPreferenceStore();
+ }
+
+ /**
+ * Returns the workspace viewer <code>PreferenceStore</code>
+ *
+ * @return the workspace viewer <code>PreferenceStore</code>
+ */
+ public PreferenceStore getWorkspaceViewerPreferenceStore() {
+ //not yet used by tables
+ return null;
+
+ // if(this.workspacePreferenceStore != null) {
+ // return this.workspacePreferenceStore;
+ // } else {
+ // // Try to load it
+ // IPath path = Activator.getDefault().getStateLocation();
+ // String id = getIdStr(this.tableManager.getTable());
+ //
+ // String fileName = path.toString() + "/" + id;//$NON-NLS-1$
+ // java.io.File file = new File(fileName);
+ // this.workspacePreferenceStore = new PreferenceStore(fileName);
+ // if(file.exists()) {
+ // // Load it
+ // try {
+ // this.workspacePreferenceStore.load();
+ // } catch (Exception e) {
+ // // Create the default
+ // addDefaultPreferences();
+ // }
+ // } else {
+ // // Create it
+ // addDefaultPreferences();
+ // }
+ // return this.workspacePreferenceStore;
+ // }
}
+ // /**
+ // * returns the unique GUID of the view
+ // *
+ // * @param view
+ // * the view
+ // * @return String the GUID of a view (constant)
+ // */
+ // private static String getIdStr(Table table) {
+ // Resource resource = table.eResource();
+ // if(resource instanceof XMLResource) {
+ // String id = ((XMLResource)resource).getID(table);
+ // if(id != null) {
+ // return id;
+ // }
+ // }
+ //
+ // // Remain compatible with previous behavior.
+ // return StringStatics.BLANK;
+ // }
+
+ // not used : add a workspace preference to the table
+ // private void addDefaultPreferences() {
+ // final IPreferenceStore globalPreferenceStore = Activator.getDefault().getPreferenceStore();
+ // String tableKind = this.tableManager.getTable().getTableConfiguration().getType();
+ // }
/**
*
@@ -134,7 +205,7 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
}
@Override
- public Object getAdapter(final Class adapter) {
+ public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapter) {
if(adapter == INattableModelManager.class) {
return this.tableManager;
}
@@ -153,11 +224,22 @@ public abstract class AbstractEMFNattableEditor extends EditorPart {
@Override
public void dispose() {
+ saveLocalPreferenceStoreValues();
this.tableManager.dispose();
this.synchronizer.dispose();
super.dispose();
}
+ protected void saveLocalPreferenceStoreValues() {
+ // Write the settings, if necessary
+ try {
+ if(getWorkspaceViewerPreferenceStore() != null && getWorkspaceViewerPreferenceStore().needsSaving())
+ getWorkspaceViewerPreferenceStore().save();
+ } catch (IOException ioe) {
+ Activator.log.warn("Preferences can' be saved"); //$NON-NLS-1$
+ }
+ }
+
/**
* A class taking in charge the synchronization of the partName and the table name.
* When table name change, the other is automatically updated.
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
index 0c3ff4c6a4f..4d5061bd4b3 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
@@ -37,6 +37,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable,
org.eclipse.papyrus.infra.nattable.nattableconfiguration,
org.eclipse.papyrus.infra.nattable.painter,
org.eclipse.papyrus.infra.nattable.paste,
+ org.eclipse.papyrus.infra.nattable.preferences,
org.eclipse.papyrus.infra.nattable.provider,
org.eclipse.papyrus.infra.nattable.reorder,
org.eclipse.papyrus.infra.nattable.tester,
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java
index db654b72350..2117b5c6af2 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/Activator.java
@@ -13,7 +13,10 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.papyrus.infra.nattable.preferences.PapyrusTablePreferenceStore;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -31,6 +34,12 @@ public class Activator extends AbstractUIPlugin {
public static LogHelper log;
/**
+ * Storage for preferences.
+ */
+ protected IPreferenceStore papyrusPreferenceStore;
+
+
+ /**
* The constructor
*/
public Activator() {
@@ -66,4 +75,19 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
+ /**
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#getPreferenceStore()
+ *
+ * @return
+ */
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ // Create the preference store lazily.
+ if(this.papyrusPreferenceStore == null) {
+ this.papyrusPreferenceStore = new PapyrusTablePreferenceStore(new InstanceScope(), getBundle().getSymbolicName());
+ }
+ return this.papyrusPreferenceStore;
+ }
+
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
index 1245111f82f..7bb978e574f 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.infra.nattable.manager.table;
import java.util.Collection;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
@@ -179,4 +180,17 @@ public interface INattableModelManager extends ITableAxisElementProvider, IDispo
*/
public IAxisManager getRowAxisManager();
+ /**
+ *
+ * @return
+ * the local preference store for the table instance or <code>null</code>
+ */
+ public PreferenceStore getTablePreferenceStore();
+
+ /**
+ *
+ * @param store
+ * the table preference store
+ */
+ public void setWorkspacePreferenceStore(final PreferenceStore store);
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
index d3b387a026c..b3166a86baa 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -42,6 +42,7 @@ import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.window.Window;
@@ -151,6 +152,11 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
private BiMap<CellMapKey, Cell> cellsMap;
/**
+ * the local preference store for the table
+ */
+ private PreferenceStore localPreferenceStore;
+
+ /**
*
* Constructor.
*
@@ -1333,4 +1339,26 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
return new CellMapKey(cell.getColumnWrapper().getElement(), cell.getRowWrapper().getElement());
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getTablePreferenceStore()
+ *
+ * @return
+ */
+ @Override
+ public PreferenceStore getTablePreferenceStore() {
+ return this.localPreferenceStore;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#setWorkspacePreferenceStore(org.eclipse.jface.preference.PreferenceStore)
+ *
+ * @param store
+ */
+ @Override
+ public void setWorkspacePreferenceStore(final PreferenceStore store) {
+ this.localPreferenceStore = store;
+ }
+
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/preferences/PapyrusTablePreferenceStore.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/preferences/PapyrusTablePreferenceStore.java
new file mode 100644
index 00000000000..867d19b639f
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/preferences/PapyrusTablePreferenceStore.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.preferences;
+
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.papyrus.infra.tools.preferences.AbstractPapyrusPreferenceStore;
+import org.eclipse.papyrus.infra.tools.preferences.ui.dialog.AbstractApplyValueOnPreferenceKeyDialog;
+
+/**
+ * this class is a specific store that is used to look for value of element
+ * by taking account the structure of preferences : papyrus editor-> Diagram -> Elements of Diagram
+ *
+ */
+public class PapyrusTablePreferenceStore extends AbstractPapyrusPreferenceStore {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param context
+ * @param qualifier
+ * @param defaultQualifierPath
+ */
+ public PapyrusTablePreferenceStore(IScopeContext context, String qualifier, String defaultQualifierPath) {
+ super(context, qualifier, defaultQualifierPath, TablePreferencesConstantsHelper.PAPYRUS_TABLE_EDITOR_PREFERENCE_PREFIX, TablePreferencesConstantsHelper.TABLE_PREFERENCE_PREFIX, TablePreferencesConstantsHelper.TABLE_ELEMENT);
+ }
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param context
+ * @param qualifier
+ */
+ public PapyrusTablePreferenceStore(IScopeContext context, String qualifier) {
+ super(context, qualifier, TablePreferencesConstantsHelper.PAPYRUS_TABLE_EDITOR_PREFERENCE_PREFIX, TablePreferencesConstantsHelper.TABLE_PREFERENCE_PREFIX, TablePreferencesConstantsHelper.TABLE_ELEMENT);
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.tools.preferences.AbstractPapyrusPreferenceStore#createPreferenceKeyDialog(java.lang.String[])
+ *
+ * @param keys
+ * @return
+ */
+ @Override
+ protected AbstractApplyValueOnPreferenceKeyDialog createPreferenceKeyDialog(String[] keys) {
+ throw new UnsupportedOperationException("not yet implemented"); //$NON-NLS-1$
+ }
+
+
+
+
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/preferences/TablePreferencesConstantsHelper.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/preferences/TablePreferencesConstantsHelper.java
new file mode 100644
index 00000000000..18d18a94ae2
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/preferences/TablePreferencesConstantsHelper.java
@@ -0,0 +1,87 @@
+/*****************************************************************************
+ * 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:
+ *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.preferences;
+
+
+/**
+ *
+ * @author VL222926
+ *
+ */
+public class TablePreferencesConstantsHelper {
+
+ private TablePreferencesConstantsHelper() {
+ //to prevent instanciation
+ }
+
+ /**
+ * Prefix for preference for Papyrus nattable Level editor
+ */
+ public final static String PAPYRUS_TABLE_EDITOR_PREFERENCE_PREFIX = "PAPYRUS_TABLE_EDITOR"; //$NON-NLS-1$
+
+ /**
+ * Prefix for preference for Diagram Level
+ */
+ public final static String TABLE_PREFERENCE_PREFIX = "NATTABLE_"; //$NON-NLS-1$
+
+ /**
+ * Prefix for preference for element Level
+ */
+ public final static String TABLE_ELEMENT = "TABLE_ELEMENT_"; //$NON-NLS-1$
+
+
+ /**
+ * Get the preference constant used to store the preference of an element.
+ *
+ * @param elementName
+ * the name of the element
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link TablePreferencesConstantsHelper}
+ * @return the constant used.
+ */
+ public static String getConstant(String elementName, int preferenceType) {
+ throw new UnsupportedOperationException("Not yet implemented");//$NON-NLS-1$
+ // StringBuffer sb = new StringBuffer();
+ // sb.append(elementName);
+ // sb.append("."); //$NON-NLS-1$
+ // switch(preferenceType) {
+ //
+ // default:
+ // break;
+ // }
+ // return sb.toString();
+ }
+
+ /**
+ *
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link TablePreferencesConstantsHelper}
+ * @return get the preference key at the papyrus editor level
+ */
+ public static String getPapyrusEditorConstant(int preferenceType) {
+ return getConstant(PAPYRUS_TABLE_EDITOR_PREFERENCE_PREFIX, preferenceType);
+ }
+
+ /**
+ *
+ * @param diagramKind
+ * the kind of diagram.
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the preference key at the diagram level
+ */
+ public static String getNatTableConstant(String tableKind, int preferenceType) {
+ return TABLE_PREFERENCE_PREFIX + getConstant(tableKind, preferenceType);
+ }
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF b/plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF
index e30edd30a7d..b340145fdce 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/META-INF/MANIFEST.MF
@@ -11,6 +11,8 @@ Require-Bundle: org.eclipse.ui,
Export-Package: org.eclipse.papyrus.infra.tools.comparator,
org.eclipse.papyrus.infra.tools.converter,
org.eclipse.papyrus.infra.tools.databinding,
+ org.eclipse.papyrus.infra.tools.preferences,
+ org.eclipse.papyrus.infra.tools.preferences.ui.dialog,
org.eclipse.papyrus.infra.tools.util
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/Messages.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/Messages.java
index 77a155d1a10..79e543913ce 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/Messages.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/Messages.java
@@ -19,6 +19,14 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.tools.messages.messages"; //$NON-NLS-1$
+ public static String AbstractPreferenceKeyDialog_Level;
+
+ public static String AbstractPreferenceKeyDialog_Localization;
+
+ public static String AbstractPreferenceKeyDialog_Pref_Kind;
+
+ public static String AbstractPreferenceKeyDialog_WouldYouLikeOverloadPreferences;
+
public static String AbstractStringValueConverter_NoXReprensentedByYHaveBeenFound;
public static String AbstractStringValueConverter_SomeStringsAreNotValidToCreateY;
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/messages.properties b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/messages.properties
index dea12a89919..aae5ef667df 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/messages.properties
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/messages/messages.properties
@@ -1,3 +1,7 @@
+AbstractPreferenceKeyDialog_Level=Level
+AbstractPreferenceKeyDialog_Localization=Localization
+AbstractPreferenceKeyDialog_Pref_Kind=Pref. kind
+AbstractPreferenceKeyDialog_WouldYouLikeOverloadPreferences=Would you like to overload those preferences?
AbstractStringValueConverter_NoXReprensentedByYHaveBeenFound=No {0} represented by {1} have been found
AbstractStringValueConverter_SomeStringsAreNotValidToCreateY=Some Strings are not valid to create {0}
AbstractStringValueConverter_SomeStringsCantBeResolvedToFindY=Some Strings can't be resolved to find {0}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/AbstractPapyrusPreferenceStore.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/AbstractPapyrusPreferenceStore.java
new file mode 100644
index 00000000000..8abda344be2
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/AbstractPapyrusPreferenceStore.java
@@ -0,0 +1,293 @@
+/*****************************************************************************
+ * 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:
+ *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.tools.preferences;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.papyrus.infra.tools.Activator;
+import org.eclipse.papyrus.infra.tools.preferences.ui.dialog.AbstractApplyValueOnPreferenceKeyDialog;
+
+public abstract class AbstractPapyrusPreferenceStore extends PapyrusScopedPreferenceStore {
+
+ /**
+ * key for element level
+ */
+ private final String elementLevelPrefix;
+
+ /**
+ * key for editor level
+ */
+ private final String instanceEditorLevelPrefix;
+
+ /**
+ * key for all editor of the same kind
+ */
+ private final String editorLevelPrefix;
+
+ /**
+ * constructor
+ *
+ * @param context
+ * the scope to store to
+ * @param qualifier
+ * the qualifier used to look up the preference node
+ * @param key
+ * for all editor of the same kind (all diagrams, all tables, ...)
+ * @param key
+ * for an instance of this editor
+ * @param key
+ * for an element
+ */
+ public AbstractPapyrusPreferenceStore(IScopeContext context, String qualifier, String editorLevelPrefix, String instanceEditorLevelPrefix, String elementLevelPrefix) {
+ super(context, qualifier);
+ this.editorLevelPrefix = editorLevelPrefix;
+ this.instanceEditorLevelPrefix = instanceEditorLevelPrefix;
+ this.elementLevelPrefix = elementLevelPrefix;
+ }
+
+ /**
+ * constructor
+ *
+ * @param context
+ * the scope to store to
+ * @param qualifier
+ * the qualifier used to look up the preference node
+ * @param defaultQualifierPath
+ * the qualifier used when looking up the defaults
+ * @param key
+ * for all editor of the same kind (all diagrams, all tables, ...)
+ * @param key
+ * for an instance of this editor
+ * @param key
+ * for an element
+ */
+ public AbstractPapyrusPreferenceStore(IScopeContext context, String qualifier, String defaultQualifierPath, String editorLevelPrefix, String instanceEditorLevelPrefix, String elementLevelPrefix) {
+ super(context, qualifier, defaultQualifierPath);
+ this.editorLevelPrefix = editorLevelPrefix;
+ this.instanceEditorLevelPrefix = instanceEditorLevelPrefix;
+ this.elementLevelPrefix = elementLevelPrefix;
+ }
+
+
+
+
+ /**
+ * this method is used to overload all value under a level of preferences.
+ * In order to overload a pop-up is opened, and the user can choose value to overload
+ *
+ * @param level
+ * of preference: Editor or diagram
+ */
+
+ public void deleteAllSubPreference(String level) {
+ //remove all sub value diagram+ element
+
+ //key to collect
+ List<String> elementKey = new ArrayList<String>();
+ try {
+ for(int i = 0; i < getStorePreferences().keys().length; i++) {
+ //level diagram collect only element
+ if(level.startsWith(instanceEditorLevelPrefix)) {
+ if(getStorePreferences().keys()[i].startsWith(elementLevelPrefix)) {
+ elementKey.add(getStorePreferences().keys()[i]);
+ }
+ }
+ //editor level, collect all element+diagram
+ else if(level.startsWith(editorLevelPrefix)) {
+ if((getStorePreferences().keys()[i].startsWith(elementLevelPrefix)) || (getStorePreferences().keys()[i].startsWith(instanceEditorLevelPrefix))) {
+ elementKey.add(getStorePreferences().keys()[i]);
+ }
+ }
+
+ }
+
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ if(elementKey.size() > 0) {
+ List<String> keytoRemove = new ArrayList<String>();
+ String[] keyRoconsult = new String[elementKey.size()];
+ AbstractApplyValueOnPreferenceKeyDialog dialog = createPreferenceKeyDialog(elementKey.toArray(keyRoconsult));
+ dialog.open();
+ keytoRemove = dialog.getKeyToRemove();
+
+ //remove key
+ Iterator<String> iterator = keytoRemove.iterator();
+ while(iterator.hasNext()) {
+ String key = (String)iterator.next();
+ getStorePreferences().remove(key);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param keys
+ * @return
+ * the dialog to apply values
+ */
+ protected abstract AbstractApplyValueOnPreferenceKeyDialog createPreferenceKeyDialog(String[] keys);
+
+
+
+ // each get value will be overloaded
+ //if not value is found for an element, a value is look for in DIAGRAM
+ // if a the value is not find for Diagram a value is find for Papyrus editor
+
+
+ /**
+ * this method is used to find a key that a got a value:
+ * if the key is an element. The method look for if this key exist. If no value exists, it look for the key for diagram
+ * if the key for diagram do not exist it look for key for papyrus Editor
+ * the structure of Key is:
+ * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
+ * Diagram : DIAGRAM_DiagramKind.preferenceKind
+ * Editor: PAPYRUS_EDITOR.preferenceKind
+ *
+ */
+ protected String findKeyWithAValue(String initialKey) {
+ String foundedKey = null;
+ //first look for in value stack
+ foundedKey = findKeyAStoreValue(initialKey);
+ //then look for in default stack
+ if(foundedKey == null) {
+ foundedKey = findKeyWithADefaultValue(initialKey);
+ }
+ if(foundedKey == null) {
+ foundedKey = initialKey;
+ }
+ return foundedKey;
+
+ }
+
+ /**
+ * look for a key with a value in the store stack
+ *
+ * @param initialKey
+ * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
+ * Diagram : DIAGRAM_DiagramKind.preferenceKind
+ * Editor: PAPYRUS_EDITOR.preferenceKind
+ * @return the key that returns a value or null if there is no value
+ */
+ protected String findKeyAStoreValue(String initialKey) {
+ String foundedKey = null;
+ if(getStorePreferences().get(initialKey, null) != null) {
+ foundedKey = initialKey;
+ }
+
+ if(foundedKey == null && hasPrefix(initialKey)) {
+ foundedKey = findKeyAStoreValue(getUpperKey(initialKey));
+ }
+ return foundedKey;
+ }
+
+ /**
+ * this method is used to find a key that a got a value:
+ * if the key is an element. The method look for if this key exist. If no value exists, it look for the key for diagram
+ * if the key for diagram do not exist it look for key for papyrus Editor
+ * the structure of Key is:
+ * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
+ * Diagram : DIAGRAM_DiagramKind.preferenceKind
+ * Editor: PAPYRUS_EDITOR.preferenceKind
+ *
+ */
+ protected String findKeyWithADefaultValue(String initialKey) {
+ String foundedKey = null;
+
+ if(getDefaultPreferences().get(initialKey, null) != null) {
+ foundedKey = initialKey;
+ }
+
+ if(foundedKey == null && hasPrefix(initialKey)) {
+ return findKeyWithADefaultValue(getUpperKey(initialKey));
+ } else {
+ foundedKey = initialKey;
+ }
+ return foundedKey;
+
+ }
+
+ /**
+ * get the upper Key from the initial Key
+ * * the structure of Key is:
+ * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
+ * Diagram : DIAGRAM_DiagramKind.preferenceKind
+ * Editor: PAPYRUS_EDITOR.preferenceKind
+ *
+ * @param initialKey
+ * @return the upperKey
+ *
+ */
+ protected String getUpperKey(String initialKey) {
+
+ String out = initialKey.toString();
+ if(initialKey.startsWith(elementLevelPrefix)) {
+ out = initialKey.toString().replaceAll(elementLevelPrefix, instanceEditorLevelPrefix);
+ out = out.substring(0, out.lastIndexOf("_")) + out.substring(out.indexOf("."), out.length());
+ }
+ if(initialKey.startsWith(instanceEditorLevelPrefix)) {
+ // out=initialKey.toString().replaceAll(instanceEditorLevelPrefix, editorLevelPrefix);
+ out = editorLevelPrefix + out.substring(out.indexOf("."), out.length());
+ }
+ return out;
+ }
+
+ protected boolean hasPrefix(String key) {
+ if(key.startsWith(elementLevelPrefix) || key.startsWith(instanceEditorLevelPrefix)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * get the value from a key
+ *
+ * @param key
+ * @return the value
+ */
+ protected String internalGet(String key) {
+ String newKey = findKeyWithAValue(key);
+ //System.err.println("-->Initial Key "+key+"--> "+ newKey);
+ return Platform.getPreferencesService().get(newKey, null, getPreferenceNodes(true));
+ }
+
+ public boolean getDefaultBoolean(String name) {
+
+ return super.getDefaultBoolean(findKeyWithADefaultValue(name));
+ }
+
+ public double getDefaultDouble(String name) {
+ return super.getDefaultDouble(findKeyWithADefaultValue(name));
+ }
+
+ public float getDefaultFloat(String name) {
+ return super.getDefaultFloat(findKeyWithADefaultValue(name));
+ };
+
+ public int getDefaultInt(String name) {
+ return super.getDefaultInt(findKeyWithADefaultValue(name));
+ }
+
+ public long getDefaultLong(String name) {
+ return super.getDefaultLong(findKeyWithADefaultValue(name));
+ }
+
+ public String getDefaultString(String name) {
+ return super.getDefaultString(findKeyWithADefaultValue(name));
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/PapyrusScopedPreferenceStore.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/PapyrusScopedPreferenceStore.java
index f64d6a84c30..59a3595cfc2 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/PapyrusScopedPreferenceStore.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/PapyrusScopedPreferenceStore.java
@@ -11,7 +11,7 @@
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
*
*****************************************************************************/
-package org.eclipse.papyrus.infra.gmfdiag.preferences;
+package org.eclipse.papyrus.infra.tools.preferences;
/***************************************************************************
Copyright (c) 2010 CEA LIST.
@@ -235,13 +235,13 @@ public class PapyrusScopedPreferenceStore extends EventManager implements IPrefe
if(obj instanceof String) {
return defaults.get(key, STRING_DEFAULT_DEFAULT);
} else if(obj instanceof Integer) {
- return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT));
+ return Integer.valueOf(defaults.getInt(key, INT_DEFAULT_DEFAULT));
} else if(obj instanceof Double) {
return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
} else if(obj instanceof Float) {
return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
} else if(obj instanceof Long) {
- return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
+ return Long.valueOf(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
} else if(obj instanceof Boolean) {
return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE : Boolean.FALSE;
} else {
@@ -664,7 +664,7 @@ public class PapyrusScopedPreferenceStore extends EventManager implements IPrefe
// removing a non-existing preference is a no-op so call the Core
// API directly
getStorePreferences().remove(name);
- if(oldValue != defaultValue) {
+ if(!oldValue.equals(defaultValue)) {
dirty = true;
firePropertyChangeEvent(name, oldValue, defaultValue);
}
@@ -744,7 +744,7 @@ public class PapyrusScopedPreferenceStore extends EventManager implements IPrefe
getStorePreferences().putInt(name, value);
}
dirty = true;
- firePropertyChangeEvent(name, new Integer(oldValue), new Integer(value));
+ firePropertyChangeEvent(name, Integer.valueOf(oldValue), Integer.valueOf(value));
} finally {
silentRunning = false;// Restart listening to preferences
}
@@ -769,7 +769,7 @@ public class PapyrusScopedPreferenceStore extends EventManager implements IPrefe
getStorePreferences().putLong(name, value);
}
dirty = true;
- firePropertyChangeEvent(name, new Long(oldValue), new Long(value));
+ firePropertyChangeEvent(name, Long.valueOf(oldValue), Long.valueOf(value));
} finally {
silentRunning = false;// Restart listening to preferences
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/ui/dialog/AbstractApplyValueOnPreferenceKeyDialog.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/ui/dialog/AbstractApplyValueOnPreferenceKeyDialog.java
new file mode 100644
index 00000000000..ea08721e158
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/ui/dialog/AbstractApplyValueOnPreferenceKeyDialog.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.tools.preferences.ui.dialog;
+
+import java.util.ArrayList;
+
+/**
+ * The Class ApplyValueOnPreferenceKeyDialog display all the preference key and give all selected keys
+ */
+public abstract class AbstractApplyValueOnPreferenceKeyDialog extends AbstractPreferenceKeyDialog {
+
+ /** The checked key. */
+ protected ArrayList<String> checkedKey;
+
+ /**
+ * Instantiates a new apply value on preference key dialog.
+ *
+ * @param keys
+ * the keys
+ */
+ public AbstractApplyValueOnPreferenceKeyDialog(String[] keys) {
+ super(keys);
+ checkedKey = new ArrayList<String>();
+ }
+
+ /**
+ * Gets the key to remove.
+ *
+ * @return the key to remove
+ */
+ public ArrayList<String> getKeyToRemove() {
+ return checkedKey;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ for(int i = 0; i < keyTable.getItems().length; i++) {
+ if(keyTable.getItems()[i].getChecked()) {
+ checkedKey.add((String)keyTable.getItems()[i].getData());
+ }
+ }
+ super.okPressed();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+ */
+ @Override
+ protected void cancelPressed() {
+ super.cancelPressed();
+ checkedKey = new ArrayList<String>();
+ }
+}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/ui/dialog/AbstractPreferenceKeyDialog.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/ui/dialog/AbstractPreferenceKeyDialog.java
new file mode 100644
index 00000000000..127e87a3f15
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/preferences/ui/dialog/AbstractPreferenceKeyDialog.java
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.tools.preferences.ui.dialog;
+
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.papyrus.infra.tools.Activator;
+import org.eclipse.papyrus.infra.tools.messages.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+/**
+ * The Class AbstractPreferenceKeyDialog display all preference key that are given in parameters
+ */
+public abstract class AbstractPreferenceKeyDialog extends org.eclipse.jface.dialogs.StatusDialog {
+
+ /** The key table. */
+ protected Table keyTable;
+
+ /** The table viewer. */
+ protected TableViewer tableViewer;
+
+ /** The keys. */
+ protected String[] keys;
+
+ /**
+ * Instantiates a new abstract preference key dialog.
+ *
+ * @param keys
+ * the array of preference jy to display
+ */
+ public AbstractPreferenceKeyDialog(String[] keys) {
+ super(new Shell());
+ this.keys = Arrays.copyOf(keys, keys.length);
+ setStatusLineAboveButtons(true);
+ updateStatus(new Status(IStatus.INFO, Activator.PLUGIN_ID, Messages.AbstractPreferenceKeyDialog_WouldYouLikeOverloadPreferences));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ keyTable = new Table(composite, SWT.CHECK | SWT.BORDER);
+ tableViewer = new TableViewer(keyTable);
+ tableViewer.setLabelProvider(createLabelProvider());
+ tableViewer.setContentProvider(createContentProvider());
+
+ TableColumn column = new TableColumn(keyTable, SWT.NONE);
+ column.setWidth(150);
+ column.setText(Messages.AbstractPreferenceKeyDialog_Pref_Kind);
+
+ column = new TableColumn(keyTable, SWT.NONE);
+ column.setWidth(90);
+ column.setText(Messages.AbstractPreferenceKeyDialog_Level);
+
+ column = new TableColumn(keyTable, SWT.NONE);
+ column.setWidth(200);
+ column.setText(Messages.AbstractPreferenceKeyDialog_Localization);
+ tableViewer.setInput(keys);
+ keyTable.setHeaderVisible(true);
+
+
+ return composite;
+
+ }
+
+ /**
+ *
+ * @return
+ * the label provider for the table viewer
+ */
+ protected abstract IBaseLabelProvider createLabelProvider();
+
+ /**
+ *
+ * @return
+ * the content provider for the table viewer
+ */
+ protected abstract IContentProvider createContentProvider();
+
+}

Back to the top