]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Index tokenized lowercase versions of name and types for UI searches 66/2866/3
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 19:43:39 +0000 (22:43 +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

Change-Id: I141569877abc910387eca8633a1c4462153b034e

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 21a25d7d63a79caba3742c5457005222d3845e3b..21b32fa1ecd14d1ae0a5238095365d4dbd56f6ff 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 60ccf99cbda65860e24c9504379a85f92dc20479..3ca66ce773aa9fe433fb5fe2ab36d27794f56e0a 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 fc32222084c0f7e08509c152a882b893e7bd5b61..989639ef846b17b8a78c794e650b3fdd0503e399 100644 (file)
@@ -78,7 +78,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) {
-                                       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);
        }
@@ -412,7 +414,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 {
                                                    //System.err.println("resource " + entry.component + ": no parent for entry " + name + " " + types);
                                            }
@@ -433,7 +435,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});
                                                }
                                            }
                                        }
@@ -617,7 +619,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 4eca4e550638513f0d65d00ecf45ab57540a32a4..24f7f5bd8c4aa1cd40684875e34cc9e0fb42b213 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+");
+                            if (terms.length == 0) return;
+
                             Resource project = Simantics.peekProjectResource();
                             if (project != null) {
                                 IResourceFilter rf = resourceFilter;
                                 String filter = getFilterForResourceFilter(rf);
                                 if (!filter.isEmpty())
                                     filter += " AND ";
-                                filter += "Name:" + pattern + "*";
+                                
+                                filter += Dependencies.FIELD_NAME_SEARCH + ":(";
+                                filter += Arrays.stream(terms).map(term -> "+" + IndexQueries.escape(term.toLowerCase(), false) + "*").collect(Collectors.joining(" "));
+                                filter +=")";
 
                                 Layer0 L0 = Layer0.getInstance(graph);
 
index ff7a3e14e014d30b03b38703d79ec4979c3918e0..cfa02bcd69ad2d5556a897a12006d8648202107c 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");
+                                       query.setSearchFlag(Dependencies.FIELD_NAME_SEARCH, "on");
                                        query.setSearchFlag(DocumentLink.URIs.SearchFunction, "on");
                                        searchService.performQuery(query, ISearchService.ResultBrowser.VIEW, true);
                                } catch (DatabaseException e) {
index eb4b02591a62a9c584cac5cbce9f1842b9539dbe..9f14e3629db0193389000df3d8baef4852d4f661 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,7 +105,7 @@ 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"));
+       NameComparator c = new NameComparator(query.getQuery(Dependencies.FIELD_NAME_SEARCH));
         
         for (Resource source : results) {
                  // Prevent index corruption from producing duplicate results.
index 3fc15364dab39f937dddca1b9f10ad7c7241564e..32d84eb9acc1ce2e3b40b6d343b127bfae1e341f 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);
+                           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 89ae231bb5b41849073eec66c31576645ef7b3cc..a32ef1edcaf09e9665e41f9b026be3e07cb86aef 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 8a040223b1bf2d5ac264101908026826146a36c1..ffbfc5f62cc22308cb4ad2916f48777635be5c06 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 37f7d63a719b1e226e261b2690d8023fead0e8cc..f3783f0a01c9079bf8a400f3a6917a8e91ba920b 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 0c0c92c22d22fedd1e589bc6a8306a2c168b96a0..93fdf105c18788facc59034f5b9d3b7d79b0e588 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 d90a90ee9c8118921ea3e1a6d036140875d70063..1852316b979444f0c216eff0b611194a25040ed8 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 aa96ed13bc6daabd535c908dfa94f1dab07ce379..01d015de564eabb935302ac98b5c3af6a1e86097 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 e0a96ed12c39d62c880743b945bd6a1fecea2738..733bebddf2fc6460723309bfef5a9837fc251395 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 069e31a07a5f64c3c0a0d716e107ce96c6f759fe..25aa1d2926943fb619832dcac65ade1abf6f1faf 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);
     }