Index tokenized lowercase versions of name and types for UI searches 67/2867/1
authorJussi Koskela <jussi.koskela@semantum.fi>
Fri, 26 Apr 2019 08:31:36 +0000 (11:31 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 26 Apr 2019 20:39:13 +0000 (23:39 +0300)
* Added support for different name/label in search parameter selection.
* Fixed resource search to form wildcard query separately for each term.
* Added utility methods to SearchQuery for lower/uppercasing the query

gitlab #291

Resolved conflicts from:
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/DependenciesRelation.java
bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/SearchResourceDialog.java
bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/actions/SearchLinksAction.java
bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/function/SearchFunction.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/SearchFunction.java

Change-Id: I86fffd2ce272ac089e281348d8f5ac8aa2f9410a
(cherry picked from commit 4e7fd7de62f57825448d4dcc2636d0b59646a7ef)

16 files changed:
bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/Queries.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/Dependencies.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/DependenciesRelation.java
bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/SearchResourceDialog.java
bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/actions/SearchLinksAction.java
bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/function/SearchFunction.java
bundles/org.simantics.document.ui/src/org/simantics/document/ui/function/SearchFunction.java
bundles/org.simantics.workbench.search/search/header.ftl
bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/DependenciesSearchFunction.java
bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/SearchData.java
bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/SearchEngine.java
bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/SearchParam.java [new file with mode: 0644]
bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/SearchQuery.java
bundles/org.simantics.workbench/src/org/simantics/workbench/internal/contributions/search/BrowserView.java
bundles/org.simantics.workbench/src/org/simantics/workbench/internal/contributions/search/SearchServiceImpl.java
bundles/org.simantics.workbench/src/org/simantics/workbench/internal/contributions/search/SearchTrim.java

index 21a25d7..21b32fa 100644 (file)
@@ -12,6 +12,7 @@
  *******************************************************************************/
 package org.simantics.db.indexing;
 
+import java.io.IOException;
 import java.io.Reader;
 import java.util.HashMap;
 import java.util.Map;
@@ -20,12 +21,14 @@ import java.util.regex.Pattern;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenFilter;
+import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.Tokenizer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
 import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper;
 import org.apache.lucene.analysis.pattern.PatternReplaceFilter;
 import org.apache.lucene.analysis.pattern.PatternTokenizer;
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.util.CharTokenizer;
 import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.queryparser.classic.QueryParser;
@@ -34,6 +37,7 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.util.AttributeFactory;
 import org.apache.lucene.util.Version;
 import org.simantics.databoard.util.ObjectUtils;
+import org.simantics.db.layer0.genericrelation.Dependencies;
 import org.simantics.utils.datastructures.Pair;
 
 public class Queries {
@@ -94,14 +98,35 @@ public class Queries {
         }
     }
 
+    final static class LowercaseFilter extends TokenFilter {
+        private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
+
+        public LowercaseFilter(TokenStream in) {
+            super(in);
+        }
+
+        @Override
+        public boolean incrementToken() throws IOException {
+            if (!input.incrementToken()) return false;
+            String lowercase = termAtt.toString().toLowerCase();
+            termAtt.setEmpty().append(lowercase);
+            return true;
+        }
+    }
+
     static final class TypeStringAnalyzer extends Analyzer {
+        private boolean lowercase;
 
-               @Override
-               protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
+        public TypeStringAnalyzer(Boolean lowercase) {
+            this.lowercase = lowercase;
+        }
+        
+        @Override
+        protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
                        Tokenizer tokenizer = new PatternTokenizer(reader, Pattern.compile("(([^\\\\ ]|\\\\\\\\|\\\\ )+)( *)"), 1);
                        TokenFilter filter = new PatternReplaceFilter(tokenizer, Pattern.compile("(\\\\(\\\\| ))"), "$2", true);
                        
-                       return new TokenStreamComponents(tokenizer, filter);
+                       return new TokenStreamComponents(tokenizer, lowercase ? new LowercaseFilter(filter) : filter);
                }
                
        }
@@ -118,7 +143,9 @@ public class Queries {
        analyzerPerField.put("Resource", new KeywordAnalyzer());
        analyzerPerField.put("GUID", new KeywordAnalyzer());
        analyzerPerField.put("Name", new KeywordAnalyzer());
-       analyzerPerField.put("Types", new TypeStringAnalyzer());
+       analyzerPerField.put("Types", new TypeStringAnalyzer(false));
+       analyzerPerField.put(Dependencies.FIELD_NAME_SEARCH, new LowerCaseWhitespaceAnalyzer(Version.LUCENE_4_9));
+       analyzerPerField.put(Dependencies.FIELD_TYPES_SEARCH, new TypeStringAnalyzer(true));
        
         PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new LowerCaseWhitespaceAnalyzer(Version.LUCENE_4_9), analyzerPerField);
         return analyzer;
index 60ccf99..3ca66ce 100644 (file)
@@ -36,13 +36,15 @@ public class Dependencies extends FunctionImpl4<ReadGraph, Resource, String, Int
     public static final String FIELD_NAME     = "Name";
     public static final String FIELD_TYPES    = "Types";
     public static final String FIELD_GUID    = "GUID";
+    public static final String FIELD_NAME_SEARCH = "NameSearch";
+    public static final String FIELD_TYPES_SEARCH = "TypesSearch";
 
     protected Resource getIndexRelation(ReadGraph graph) {
         return Layer0X.getInstance(graph).DependenciesRelation;
     }
 
     protected static String getBindingPattern() {
-        return "bfffff";
+        return "bfffffff";
     }
 
     @Override
index 033efc9..e300384 100644 (file)
@@ -77,7 +77,9 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                Pair.make(Dependencies.FIELD_RESOURCE, "Long"),
                Pair.make(Dependencies.FIELD_NAME, "String"),
                Pair.make(Dependencies.FIELD_TYPES, "Text"),
-               Pair.make(Dependencies.FIELD_GUID, "Text")
+               Pair.make(Dependencies.FIELD_GUID, "Text"),
+               Pair.make(Dependencies.FIELD_NAME_SEARCH, "Text"),
+               Pair.make(Dependencies.FIELD_TYPES_SEARCH, "Text")
        };
 
        final Resource resource;
@@ -233,7 +235,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                                ArrayList<Object[]> result = new ArrayList<Object[]>();
                                for (Entry entry : entries) {
                                        if(entry.name == null) continue;
-                                       result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id });
+                                       result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id, entry.name, entry.types });
                                }
                                return result;
 
@@ -249,21 +251,21 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
 
        @Override
        public List<Map<String, Object>> query(RequestProcessor session, String search, String bindingPattern, Object[] constants, int maxResultCount) {
-               if(!Dependencies.getBindingPattern().equals(bindingPattern)) throw new IllegalArgumentException("DependenciesRelation supports indexing only with 'bfffff'");
+               if(!Dependencies.getBindingPattern().equals(bindingPattern)) throw new IllegalArgumentException("DependenciesRelation supports indexing only with 'bfffffff'");
                IndexedRelations indexer = session.getService(IndexedRelations.class);
                return indexer.query(null, search, session, resource, (Resource)constants[0], maxResultCount);
        }
        
        @Override
        public List<Resource> queryResources(RequestProcessor session, String search, String bindingPattern, Object[] constants, int maxResultCount) {
-               if(!Dependencies.getBindingPattern().equals(bindingPattern)) throw new IllegalArgumentException("DependenciesRelation supports indexing only with 'bfffff'");
+               if(!Dependencies.getBindingPattern().equals(bindingPattern)) throw new IllegalArgumentException("DependenciesRelation supports indexing only with 'bfffffff'");
                IndexedRelations indexer = session.getService(IndexedRelations.class);
                return indexer.queryResources(null, search, session, resource, (Resource)constants[0], maxResultCount);
        }
 
        @Override
        public List<Map<String, Object>> list(RequestProcessor session, String bindingPattern, Object[] constants, int maxResultCount) {
-               if(!Dependencies.getBindingPattern().equals(bindingPattern)) throw new IllegalArgumentException("DependenciesRelation supports indexing only with 'bfffff'");
+               if(!Dependencies.getBindingPattern().equals(bindingPattern)) throw new IllegalArgumentException("DependenciesRelation supports indexing only with 'bfffffff'");
                IndexedRelations indexer = session.getService(IndexedRelations.class);
                return indexer.query(null, null, session, resource, (Resource)constants[0], maxResultCount);
        }
@@ -417,7 +419,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                                                if(!entry.isValid(graph)) continue;
                                            Resource parent = graph.getPossibleObject(entry.component, L0.PartOf);
                                            if (parent != null) {
-                                               _additions.add(new Object[] { ss.getRandomAccessId(parent), ss.getRandomAccessId(entry.component), name, types, id != null ? id.indexString() : "" });
+                                               _additions.add(new Object[] { ss.getRandomAccessId(parent), ss.getRandomAccessId(entry.component), name, types, id != null ? id.indexString() : "", name, types});
                                            } else {
                                                    //LOGGER.info("resource " + entry.component + ": no parent for entry " + name + " " + types);
                                            }
@@ -438,7 +440,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                                                if(part != null) {
                                                    _replacementKeys.add(ss.getRandomAccessId(entry.component));
                                                    _replacementObjects.add(new Object[] { ss.getRandomAccessId(part), 
-                                                           ss.getRandomAccessId(entry.component), name, types, id != null ? id.indexString() : "" });
+                                                           ss.getRandomAccessId(entry.component), name, types, id != null ? id.indexString() : "", name, types});
                                                }
                                            }
                                        }
@@ -622,7 +624,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
 
                ArrayList<Object[]> result = new ArrayList<Object[]>(entries.size());
                for (Entry entry : entries) {
-                       result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id });
+                       result.add(new Object[] { ss.getRandomAccessId(entry.parent), ss.getRandomAccessId(entry.resource), entry.name, entry.types, entry.id, entry.name, entry.types });
                }
 
                Layer0X L0X = Layer0X.getInstance(graph);
index 8532be1..06710f6 100644 (file)
@@ -13,6 +13,7 @@
 package org.simantics.debug.ui;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
@@ -23,6 +24,7 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -56,6 +58,8 @@ import org.simantics.db.common.request.UniqueRead;
 import org.simantics.db.common.uri.UnescapedChildMapOfResource;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.genericrelation.Dependencies;
+import org.simantics.db.layer0.genericrelation.IndexQueries;
 import org.simantics.db.layer0.migration.OntologiesFromLibrary;
 import org.simantics.db.layer0.variable.Variables.Role;
 import org.simantics.db.request.Read;
@@ -302,13 +306,19 @@ public class SearchResourceDialog extends FilteredItemsSelectionDialog {
                                 }
                             }
                         } else {
+                            String[] terms = pattern.trim().split("\\s+"); //$NON-NLS-1$
+                            if (terms.length == 0) return;
+
                             Resource project = Simantics.peekProjectResource();
                             if (project != null) {
                                 IResourceFilter rf = resourceFilter;
                                 String filter = getFilterForResourceFilter(rf);
                                 if (!filter.isEmpty())
                                     filter += " AND "; //$NON-NLS-1$
-                                filter += "Name:" + pattern + "*"; //$NON-NLS-1$ //$NON-NLS-2$
+                                
+                                filter += Dependencies.FIELD_NAME_SEARCH + ":("; //$NON-NLS-1$
+                                filter += Arrays.stream(terms).map(term -> "+" + IndexQueries.escape(term.toLowerCase(), false) + "*").collect(Collectors.joining(" ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                                filter +=")"; //$NON-NLS-1$
 
                                 Layer0 L0 = Layer0.getInstance(graph);
 
index 5fec36f..eddeb3e 100644 (file)
@@ -7,6 +7,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.db.layer0.genericrelation.Dependencies;
 import org.simantics.db.request.Read;
 import org.simantics.document.linking.ontology.DocumentLink;
 import org.simantics.layer0.Layer0;
@@ -41,7 +42,7 @@ public class SearchLinksAction implements ActionFactory {
                                        });
                                        ISearchService searchService = (ISearchService) PlatformUI.getWorkbench().getService(ISearchService.class);
                                        SearchQuery query = new SearchQuery(name);
-                                       query.setSearchFlag("Name", "on"); //$NON-NLS-1$ //$NON-NLS-2$
+                                       query.setSearchFlag(Dependencies.FIELD_NAME_SEARCH, "on"); //$NON-NLS-1$
                                        query.setSearchFlag(DocumentLink.URIs.SearchFunction, "on"); //$NON-NLS-1$
                                        searchService.performQuery(query, ISearchService.ResultBrowser.VIEW, true);
                                } catch (DatabaseException e) {
index c04a1f4..7f14520 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.db.common.utils.Logger;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.Instances;
+import org.simantics.db.layer0.genericrelation.Dependencies;
 import org.simantics.document.linking.ontology.DocumentLink;
 import org.simantics.document.linking.utils.SourceLinkUtil;
 import org.simantics.scl.runtime.function.FunctionImpl5;
@@ -104,8 +105,8 @@ public class SearchFunction extends FunctionImpl5<IProgressMonitor, ReadGraph, R
         SearchResult result = new SearchResult(columns);
         Set<Resource> processed = new HashSet<Resource>();
 
-       NameComparator c = new NameComparator(query.getQuery("Name")); //$NON-NLS-1$
-        
+        NameComparator c = new NameComparator(query.getQuery(Dependencies.FIELD_NAME_SEARCH));
+
         for (Resource source : results) {
                  // Prevent index corruption from producing duplicate results.
             if (!processed.add(source))
index 39ae073..32d84eb 100644 (file)
@@ -27,7 +27,7 @@ public class SearchFunction extends FunctionImpl5<IProgressMonitor, ReadGraph, R
        public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {
                 try {
                         Collection<Map<String, Object>> results = Searching.performSearch(graph, Layer0X.getInstance(graph).Dependencies, model,
-                           query.escaped(false).getQuery("Name","Types"), maxResults); //$NON-NLS-1$ //$NON-NLS-2$
+                           query.escapedWithForcedCase(false, false).getQuery(Dependencies.FIELD_NAME_SEARCH, Dependencies.FIELD_TYPES_SEARCH), maxResults);
                        return generateSearchResults(graph, results);
                } catch (DatabaseException e) {
                    Logger.defaultLogError(e);
index 89ae231..a32ef1e 100644 (file)
@@ -28,7 +28,7 @@
     </ul>
     <div id="tabs-1">
       <#list getAllSearchParams() as param>
-         <input type="checkbox" name="${param}" value="on" <#if query.getBooleanFlag("${param}")> checked </#if>> ${param}
+         <input type="checkbox" name="${param.getName()}" value="on" <#if query.getBooleanFlag("${param.getName()}")> checked </#if>> ${param.getLabel()}
       </#list>
     </div>
     <div id="tabs-2">
index 8a04022..ffbfc5f 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.genericrelation.Dependencies;
 import org.simantics.operation.Layer0X;
 import org.simantics.scl.runtime.function.FunctionImpl5;
 
@@ -34,7 +35,9 @@ public class DependenciesSearchFunction extends FunctionImpl5<IProgressMonitor,
     public SearchResult apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {
         try {
             Collection<Map<String, Object>> results = Searching.performSearch(graph,
-                    Layer0X.getInstance(graph).Dependencies, model, query.getQuery("Name","Types"), maxResults);
+                    Layer0X.getInstance(graph).Dependencies, model,
+                    query.escapedWithForcedCase(false, false).getQuery(Dependencies.FIELD_NAME_SEARCH, Dependencies.FIELD_TYPES_SEARCH),
+                    maxResults);
 
             return Searching.generateDependenciesSearchResult(graph, results);
         } catch (DatabaseException e) {
index 37f7d63..f3783f0 100644 (file)
@@ -2,8 +2,8 @@ package org.simantics.workbench.search;
 
 import java.io.File;
 import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.Map;
+import java.util.TreeMap;
 
 
 /**
@@ -44,11 +44,14 @@ public class SearchData {
                return searchEngines;
        }
     
-    public Set<String> getAllSearchParams() {
-       Set<String> params = new HashSet<String>();
-       for (SearchEngine engine : searchEngines)
-               params.addAll(engine.getSupportedParams());
-       return params;
+    public Collection<SearchParam> getAllSearchParams() {
+        Map<String, SearchParam> params = new TreeMap<>();
+        for (SearchEngine engine : searchEngines) {
+            for (SearchParam param : engine.getSupportedParams()) {
+                params.put(param.getName(), param);
+            }
+        }
+        return params.values();
     }
 
     public NamedResource getModel() {
index 0c0c92c..93fdf10 100644 (file)
@@ -13,7 +13,7 @@ public class SearchEngine {
        private String id;
        private String name;
        private Function5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult> searchFunction;
-       private Set<String> supportedParams = new HashSet<String>();
+       private Set<SearchParam> supportedParams = new HashSet<>();
        private boolean enabledByDefault;
        
        public SearchEngine(String id, Function5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult> searchFunction, boolean enabledByDefault) {
@@ -48,11 +48,15 @@ public class SearchEngine {
                return id.hashCode();
        }
 
-       public void addSupportedParam(String param) {
-               this.supportedParams.add(param);
+       public void addSupportedParam(String name) {
+               addSupportedParam(name, name);
        }
        
-       public Set<String> getSupportedParams() {
+       public void addSupportedParam(String name, String label) {
+               this.supportedParams.add(new SearchParam(name, label));
+       }
+       
+       public Set<SearchParam> getSupportedParams() {
                return supportedParams;
        }
        
diff --git a/bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/SearchParam.java b/bundles/org.simantics.workbench.search/src/org/simantics/workbench/search/SearchParam.java
new file mode 100644 (file)
index 0000000..b47c1ef
--- /dev/null
@@ -0,0 +1,19 @@
+package org.simantics.workbench.search;
+
+public class SearchParam {
+    private String name;
+    private String label;
+
+    public SearchParam(String name, String label) {
+        this.name = name;
+        this.label = label;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+}
\ No newline at end of file
index d90a90e..1852316 100644 (file)
@@ -108,6 +108,26 @@ public class SearchQuery {
                return withOriginalQuery( IndexQueries.escape( originalQuery, escapeWildcards ) );
        }
 
+       /**
+        * @param uppercase <code>true</code> for uppercased query, <code>false</code>
+        *                  for lowercased query
+        * @return a clone of this query with the query string in lower or uppercase
+        */
+       public SearchQuery withForcedCase(boolean uppercase) {
+               return withOriginalQuery(uppercase ? originalQuery.toUpperCase() : originalQuery.toLowerCase());
+       }
+
+       /**
+        * @param uppercase       <code>true</code> for uppercased query,
+        *                        <code>false</code> for lowercased query
+        * @param escapeWildcards passed to {@link #escaped(boolean)}
+        * @return a clone of this query with the query string escaped and in lower or
+        *         uppercase
+        */
+       public SearchQuery escapedWithForcedCase(boolean uppercase, boolean escapeWildcards) {
+               return withForcedCase(uppercase).escaped(escapeWildcards);
+       }
+
        public static URL encode(File file, SearchQuery query) throws IOException {
                URL url = file.toURI().toURL();
                String s = url.toString() + "?search=" + URLEncoder.encode(query.getOriginalQuery(), "UTF-8");
index aa96ed1..01d015d 100644 (file)
@@ -21,6 +21,7 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.ViewPart;
 import org.simantics.Simantics;
 import org.simantics.db.Session;
+import org.simantics.db.layer0.genericrelation.Dependencies;
 import org.simantics.db.layer0.request.ActiveModels;
 import org.simantics.db.management.ISessionContext;
 import org.simantics.db.management.ISessionContextChangedListener;
@@ -132,8 +133,8 @@ public class BrowserView extends ViewPart {
 
     protected void initializeViewContent() {
         SearchQuery query = new SearchQuery("");
-        query.setSearchFlag("Name", "on");
-        query.setSearchFlag("Types", "on");
+        query.setSearchFlag(Dependencies.FIELD_NAME_SEARCH, "on");
+        query.setSearchFlag(Dependencies.FIELD_TYPES_SEARCH, "on");
         ISearchService searchService = (ISearchService) PlatformUI.getWorkbench().getService(ISearchService.class);
         if (searchService != null)
             searchService.performQuery(query, ResultBrowser.VIEW, false);
index e0a96ed..733bebd 100644 (file)
@@ -45,6 +45,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.Instances;
+import org.simantics.db.layer0.genericrelation.Dependencies;
 import org.simantics.db.layer0.request.ActiveModels;
 import org.simantics.db.request.Read;
 import org.simantics.db.service.SerialisationSupport;
@@ -567,8 +568,8 @@ public class SearchServiceImpl implements ISearchService{
                        @SuppressWarnings("unchecked")
                        SearchEngine engine = new SearchEngine(id,name,(Function5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult>)f, true);
                        {
-                               engine.addSupportedParam("Name");
-                               engine.addSupportedParam("Types");
+                               engine.addSupportedParam(Dependencies.FIELD_NAME_SEARCH, "Name");
+                               engine.addSupportedParam(Dependencies.FIELD_TYPES_SEARCH, "Types");
                        }
                        searchEngines.add(engine);
                    }
@@ -661,8 +662,8 @@ public class SearchServiceImpl implements ISearchService{
                @SuppressWarnings("unchecked")
                SearchEngine engine = new SearchEngine(id,name,(Function5<IProgressMonitor, ReadGraph, Resource, SearchQuery, Integer, SearchResult>)f, enabled);
                {
-                       engine.addSupportedParam("Name");
-                       engine.addSupportedParam("Types");
+                       engine.addSupportedParam(Dependencies.FIELD_NAME_SEARCH, "Name");
+                       engine.addSupportedParam(Dependencies.FIELD_TYPES_SEARCH, "Types");
                }
                return engine;
        }
index 069e31a..25aa1d2 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.swt.IFocusService;
+import org.simantics.db.layer0.genericrelation.Dependencies;
 import org.simantics.utils.ui.BundleUtils;
 import org.simantics.workbench.search.ISearchService;
 import org.simantics.workbench.search.SearchQuery;
@@ -151,7 +152,7 @@ public class SearchTrim extends Composite {
         query = filter(query);
 
         SearchQuery searchQuery = new SearchQuery(originalInput);
-        searchQuery.setSearchFlag("Name", "on");
+        searchQuery.setSearchFlag(Dependencies.FIELD_NAME_SEARCH, "on");
         performQuery(searchQuery, browserType);
     }
 
@@ -166,7 +167,7 @@ public class SearchTrim extends Composite {
             return;
         
         SearchQuery searchQuery = new SearchQuery(originalInput);
-        searchQuery.setSearchFlag("Types", "on");
+        searchQuery.setSearchFlag(Dependencies.FIELD_TYPES_SEARCH, "on");
         performQuery(searchQuery, browserType);
     }
 
@@ -181,8 +182,8 @@ public class SearchTrim extends Composite {
             return;
 
         SearchQuery searchQuery = new SearchQuery(originalInput);
-        searchQuery.setSearchFlag("Name", "on");
-        searchQuery.setSearchFlag("Types", "on");
+        searchQuery.setSearchFlag(Dependencies.FIELD_NAME_SEARCH, "on");
+        searchQuery.setSearchFlag(Dependencies.FIELD_TYPES_SEARCH, "on");
         performQuery(searchQuery, browserType);
     }