Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2016-10-25 11:27:40 -0400
committerGerrit Code Review @ Eclipse.org2016-11-03 10:57:45 -0400
commit4267d2acbf4eb1810d4e199dd3a294ba1c64e3d7 (patch)
tree75774cfc89e77712a904af8c0551cb0a0c6eedff /plugins
parent1bfb6cbc8605a6807bd825ce8034e4a7429ecd23 (diff)
downloadorg.eclipse.papyrus-4267d2acbf4eb1810d4e199dd3a294ba1c64e3d7.tar.gz
org.eclipse.papyrus-4267d2acbf4eb1810d4e199dd3a294ba1c64e3d7.tar.xz
org.eclipse.papyrus-4267d2acbf4eb1810d4e199dd3a294ba1c64e3d7.zip
Bug 506506 - [Model Explorer] Filter shall be compliant with Regex
https://bugs.eclipse.org/bugs/show_bug.cgi?id=506506 - replacement of << and >> by « and » at search field. - Preference available at 'Papyrus > Model Explorer' Change-Id: If73d19941fa4cdef2b8aa2ab937ebe378c30baa0 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringWithClearEditor.java59
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java1
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java25
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties1
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterFieldPreferencesGroup.java12
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterPreferenceInitializer.java1
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java26
7 files changed, 123 insertions, 2 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringWithClearEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringWithClearEditor.java
index c30e8eea1dc..481f176df98 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringWithClearEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringWithClearEditor.java
@@ -13,10 +13,15 @@
package org.eclipse.papyrus.infra.widgets.editors;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
@@ -34,6 +39,7 @@ import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -73,6 +79,8 @@ public class StringWithClearEditor extends AbstractValueEditor implements KeyLis
/** The empty string. */
protected static final String EMPTY = ""; //$NON-NLS-1$
+ /** The map of string which have to be replaced in the text field during the user is typing. */
+ private Map<String, String> stringReplacementMap = new HashMap<>();
/**
*
@@ -350,6 +358,22 @@ public class StringWithClearEditor extends AbstractValueEditor implements KeyLis
@Override
public void modifyText(final ModifyEvent e) {
+ //Replace strings
+ if (0 < stringReplacementMap.size()) {
+ // save the selection point in the text field
+ Point selection = text.getSelection();
+
+ Set<Entry<String, String>> entrySet = stringReplacementMap.entrySet();
+ for (Entry<String, String> entry : entrySet) {
+ if (text.getText().contains(entry.getKey())) {
+ text.setText(getValue().replace(entry.getKey(), entry.getValue()));
+ }
+ }
+
+ // restore the selection in the text field
+ text.setSelection(selection);
+ }
+
// SWT Thread
if (validateOnDelay) {
if (delay == 0) {
@@ -373,7 +397,6 @@ public class StringWithClearEditor extends AbstractValueEditor implements KeyLis
// SWT Thread
@Override
public void run() {
-
commit();
}
});
@@ -516,6 +539,40 @@ public class StringWithClearEditor extends AbstractValueEditor implements KeyLis
}
/**
+ * add a set of string to be replaced in the text field when the user is typing.
+ *
+ * @param oldValue
+ * The value to replace.
+ * @param newValue
+ * The new value to be replace for.
+ */
+ public void addStringToReplace(final String oldValue, final String newValue) {
+ Assert.isNotNull(oldValue);
+ Assert.isNotNull(newValue);
+
+ stringReplacementMap.put(oldValue, newValue);
+ }
+
+ /**
+ * remove an value to be replaced in the text field.
+ *
+ * @param oldValue
+ * The old value which was replace.
+ */
+ public void removeStringToReplace(String oldValue) {
+ Assert.isNotNull(oldValue);
+
+ stringReplacementMap.remove(oldValue);
+ }
+
+ /**
+ * Clear the string replacement map.
+ */
+ public void clearStringToReplace() {
+ stringReplacementMap.clear();
+ }
+
+ /**
* Cancel the change color tasks.
*/
private void cancelChangeColorTask() {
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java
index 09533739e64..4182d2e342e 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/Messages.java
@@ -20,6 +20,7 @@ public class Messages extends NLS {
public static String ExpandPreferencesGroup_ExpandGroupTooltip;
public static String ExpandPreferencesGroup_MaxLevelLabel;
public static String FilterFieldPreferencesGroup_groupTitle;
+ public static String FilterFieldPreferencesGroup_replaceDelimiterLabel;
public static String FilterFieldPreferencesGroup_UseValidationPreferenceLabel;
public static String FilterFieldPreferencesGroup_ValidationDelayPreferenceLabel;
public static String ModelExplorerView_CaseSensitiveCheckBoxLabel;
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
index c9043908651..2e3ca0a0d33 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/ModelExplorerView.java
@@ -17,6 +17,10 @@
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer;
+import static org.eclipse.papyrus.views.modelexplorer.preferences.IFilterPreferenceConstants.ST_LEFT;
+import static org.eclipse.papyrus.views.modelexplorer.preferences.IFilterPreferenceConstants.ST_LEFT_BEFORE;
+import static org.eclipse.papyrus.views.modelexplorer.preferences.IFilterPreferenceConstants.ST_RIGHT;
+import static org.eclipse.papyrus.views.modelexplorer.preferences.IFilterPreferenceConstants.ST_RIGHT_BEFORE;
import java.util.ArrayList;
import java.util.Arrays;
@@ -183,6 +187,9 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
/** The tree viewer filter. */
protected PatternViewerFilter viewerFilter;
+ /** true if the stereotype delimiters have to be replaced. */
+ private boolean stereotypeDelimitersReplaced;
+
/**
* A listener on page (all editors) selection change. This listener is set
* in {@link ModelExplorerView#init(IViewSite)}. It should be dispose to remove
@@ -664,6 +671,17 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
if (e.keyCode == SWT.ARROW_UP) {
getCommonViewer().getControl().setFocus();
}
+
+ // Set the filter text if the replace stereotype delimiters preference have changed
+ if (isStereotypeDelimitersReplaced() != stereotypeDelimitersReplaced) {
+ stereotypeDelimitersReplaced = isStereotypeDelimitersReplaced();
+ if (stereotypeDelimitersReplaced) {
+ filterText.addStringToReplace(ST_LEFT_BEFORE, ST_LEFT);
+ filterText.addStringToReplace(ST_RIGHT_BEFORE, ST_RIGHT);
+ } else {
+ filterText.clearStringToReplace();
+ }
+ }
}
});
@@ -704,6 +722,13 @@ public class ModelExplorerView extends CommonNavigator implements IRevealSemanti
}
/**
+ * Gets the preferences for the stereotype delimiter replacement.
+ */
+ private boolean isStereotypeDelimitersReplaced() {
+ return Activator.getDefault().getPreferenceStore().getBoolean(IFilterPreferenceConstants.PREF_FILTER_STEREOTYPE_REPLACED);
+ }
+
+ /**
* Gets the preferences for the validation delay.
*/
private int getValidationDelay() {
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties
index eadf2761cc3..4fa55659680 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/messages.properties
@@ -16,6 +16,7 @@ ExpandPreferencesGroup_ExpandGroupLabel=Expand
ExpandPreferencesGroup_ExpandGroupTooltip=The expand function is available in model explorer with the + button
ExpandPreferencesGroup_MaxLevelLabel=Max level (-1 for infinite)
FilterFieldPreferencesGroup_groupTitle=Filter field
+FilterFieldPreferencesGroup_replaceDelimiterLabel=Replace '<<' and '>>' with UML stereotype delimiter when typing
FilterFieldPreferencesGroup_UseValidationPreferenceLabel=Use live validation
FilterFieldPreferencesGroup_ValidationDelayPreferenceLabel=Validation delay(ms)
ModelExplorerView_CaseSensitiveCheckBoxLabel=Aa
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterFieldPreferencesGroup.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterFieldPreferencesGroup.java
index ef80cc46954..2075c89581d 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterFieldPreferencesGroup.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterFieldPreferencesGroup.java
@@ -41,9 +41,12 @@ public class FilterFieldPreferencesGroup extends AbstractPreferenceGroup {
/** The group. */
private Group fieldGroup;
- /** The field editor for the lave validation preference. */
+ /** The field editor for the live validation preference. */
private FieldEditor liveValidationfieldEditor;
+ /** The field editor for the stereotype delimiter preference. */
+ private BooleanFieldEditor stereotypeDelimiterfieldEditor;
+
/**
*
* Constructor.
@@ -75,6 +78,7 @@ public class FilterFieldPreferencesGroup extends AbstractPreferenceGroup {
GridDataFactory.fillDefaults().grab(true, false).applyTo(fieldGroup);
+ // live validation preferences
liveValidationfieldEditor = new BooleanFieldEditor(IFilterPreferenceConstants.PREF_FILTER_LIVE_VALIDATION, Messages.FilterFieldPreferencesGroup_UseValidationPreferenceLabel, fieldGroup);
liveValidationfieldEditor.setPage(dialogPage);
addFieldEditor(liveValidationfieldEditor);
@@ -85,11 +89,17 @@ public class FilterFieldPreferencesGroup extends AbstractPreferenceGroup {
liveValidationfieldEditor.setPropertyChangeListener(listener);
+ // delay preferences
delayFieldEditor = new IntegerFieldEditor(IFilterPreferenceConstants.PREF_FILTER_VALIDATION_DELAY, Messages.FilterFieldPreferencesGroup_ValidationDelayPreferenceLabel, fieldGroup);
delayFieldEditor.setPage(dialogPage);
addFieldEditor(delayFieldEditor);
delayFieldEditor.setEnabled(Activator.getDefault().getPreferenceStore().getBoolean(IFilterPreferenceConstants.PREF_FILTER_LIVE_VALIDATION), fieldGroup);
+
+ // stereotype delimiters replacement preferences
+ stereotypeDelimiterfieldEditor = new BooleanFieldEditor(IFilterPreferenceConstants.PREF_FILTER_STEREOTYPE_REPLACED, Messages.FilterFieldPreferencesGroup_replaceDelimiterLabel, fieldGroup);
+ stereotypeDelimiterfieldEditor.setPage(dialogPage);
+ addFieldEditor(stereotypeDelimiterfieldEditor);
}
/**
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterPreferenceInitializer.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterPreferenceInitializer.java
index 62d41da612f..decc20fc413 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterPreferenceInitializer.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/FilterPreferenceInitializer.java
@@ -29,6 +29,7 @@ public class FilterPreferenceInitializer extends AbstractPreferenceInitializer {
IPreferenceStore store = getPreferenceStore();
store.setDefault(IFilterPreferenceConstants.PREF_FILTER_LIVE_VALIDATION, IFilterPreferenceConstants.DEFAULT_FILTER_LIVE_VALIDATION_VALUE);
store.setDefault(IFilterPreferenceConstants.PREF_FILTER_VALIDATION_DELAY, IFilterPreferenceConstants.DEFAULT_VALIDATION_DELAY_VALUE);
+ store.setDefault(IFilterPreferenceConstants.PREF_FILTER_STEREOTYPE_REPLACED, IFilterPreferenceConstants.DEFAULT_FILTER_STEREOTYPE_REPLACED_VALUE);
}
/**
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java
index b96f415db7f..f04172b6b03 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/preferences/IFilterPreferenceConstants.java
@@ -23,10 +23,36 @@ public interface IFilterPreferenceConstants {
/** The preference of the delay of live validation. */
public static final String PREF_FILTER_VALIDATION_DELAY = "validateDelay"; //$NON-NLS-1$
+ /** The preference if the filter is in live validation. */
+ public static final String PREF_FILTER_STEREOTYPE_REPLACED = "replaceStrereotypeDelimiter"; //$NON-NLS-1$
+
/** the default value for validation delay. */
public static final int DEFAULT_VALIDATION_DELAY_VALUE = 600;
/** the default value for the use of live validation in filter. */
public static final boolean DEFAULT_FILTER_LIVE_VALIDATION_VALUE = true;
+ /** the default value for the replacement of stereotype delimiters. */
+ public static final boolean DEFAULT_FILTER_STEREOTYPE_REPLACED_VALUE = true;
+
+ /**
+ * The left stereotype delimiter
+ */
+ public static final String ST_LEFT = "\u00AB";//$NON-NLS-1$
+
+ /**
+ * The right stereotype delimiter
+ */
+ public static final String ST_RIGHT = "\u00BB";//$NON-NLS-1$
+
+ /**
+ * The right stereotype delimiter to be replaced in Text
+ */
+ public static final String ST_RIGHT_BEFORE = ">>";//$NON-NLS-1$
+
+ /**
+ * The left stereotype delimiter to be replaced in fields
+ */
+ public static final String ST_LEFT_BEFORE = "<<";//$NON-NLS-1$
+
}

Back to the top