Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael ADAM2016-10-19 07:21:59 +0000
committerGerrit Code Review @ Eclipse.org2016-10-20 11:36:23 +0000
commit4050371ec3c56720bd678581cd7dec87aed9311b (patch)
tree52731cc6bb723b61d206801e11f13f88222ee8b3 /plugins/infra/ui
parent5d0424a6ffc0bf3bf6af9379759fd3720df35d86 (diff)
downloadorg.eclipse.papyrus-4050371ec3c56720bd678581cd7dec87aed9311b.tar.gz
org.eclipse.papyrus-4050371ec3c56720bd678581cd7dec87aed9311b.tar.xz
org.eclipse.papyrus-4050371ec3c56720bd678581cd7dec87aed9311b.zip
Bug 505797 - [Model Explorer] The validation of search field should
allow ^ and $ wildcards https://bugs.eclipse.org/bugs/show_bug.cgi?id=505797 Change-Id: I2f6393a7c73e26f4020d97cd025340a8897ed157 Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'plugins/infra/ui')
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/PatternViewerFilter.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/PatternViewerFilter.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/PatternViewerFilter.java
index 571de9a043c..ed209dd9627 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/PatternViewerFilter.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/providers/PatternViewerFilter.java
@@ -9,6 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Mickaël ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500290: add ignore case boolean and some refactore
+ * Mickaël ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 505797 - The validation of search field should allow ^ and $ wildcards
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.providers;
@@ -32,6 +33,12 @@ import org.eclipse.ui.internal.misc.StringMatcher;
*/
public class PatternViewerFilter extends AbstractTreeFilter {
+ /** The wildcare to indicate that the end of a pattern is strict. */
+ private static final String END_STRICT_WILDCARE = "$";//$NON-NLS-1$
+
+ /** The wildcare to indicate that the start of a pattern is strict. */
+ private static final String START_STRICT_WILDCARE = "^";//$NON-NLS-1$
+
/** the wilcard ? */
private static final String SEMI_COLON = ";";//$NON-NLS-1$
@@ -90,10 +97,24 @@ public class PatternViewerFilter extends AbstractTreeFilter {
this.validPatterns = new StringMatcher[patterns.length];
int i = 0;
for (String pattern : patterns) {
+ StringBuilder patternBuilder = new StringBuilder();
if (!strict) {
- pattern = ASTERISK + pattern.trim() + ASTERISK;
+ if (pattern.startsWith(START_STRICT_WILDCARE)) {
+ patternBuilder.append(pattern.subSequence(1, pattern.length()));
+ } else {
+ patternBuilder.append(ASTERISK);
+ patternBuilder.append(pattern.trim());
+ }
+
+ if (pattern.endsWith(END_STRICT_WILDCARE)) {
+ patternBuilder.setLength(patternBuilder.length() - 1);
+ } else {
+ patternBuilder.append(ASTERISK);
+ }
+ } else {
+ patternBuilder.append(pattern);
}
- validPatterns[i++] = new StringMatcher(pattern, ignoreCase, false);
+ validPatterns[i++] = new StringMatcher(patternBuilder.toString(), ignoreCase, false);
}
clearCache();

Back to the top