]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Hard-coded search options
authorluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 17 Oct 2013 09:09:06 +0000 (09:09 +0000)
committerluukkainen <luukkainen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 17 Oct 2013 09:09:06 +0000 (09:09 +0000)
refs #4452

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27986 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/function/ModulesSearchFunction.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/FindSearchTrim.java

index c1cf02a45991adfaf97f697abf7c8f1860352b97..5b294de29366499e567f5a4012717f1ba0334957 100644 (file)
@@ -60,11 +60,10 @@ public class ModulesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadG
     public Collection<SearchResult> apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) {\r
         try {\r
                // Check whether only currently open diagram is searched\r
-               String filteredQuery = query.getQuery().replace(FindSearchTrim.CURRENT_DIAGRAM_OPTION, "");\r
-               Collection<Map<String, Object>> results = Searching.performSearch(graph,\r
-                    Layer0X.getInstance(graph).Dependencies, model, filteredQuery, MAX_RESULTS);\r
+               String filteredQuery = query.getQuery();\r
+               Collection<Map<String, Object>> results = Searching.performSearch(graph, Layer0X.getInstance(graph).Dependencies, model, filteredQuery, MAX_RESULTS);\r
 \r
-               if (filteredQuery.equals(query))\r
+               if (!query.getSearchParams().contains(FindSearchTrim.CURRENT_DIAGRAM_OPTION))\r
                return generateSearchResults(graph, results, Scope.ALL_MODELS);\r
                else\r
                        return generateSearchResults(graph, results, Scope.CURRENT_DIAGRAM);\r
index c5d3523ccca91b94b70d580b7e321e06cbd81a3e..9aa886cfa27817cfdfc0158c2a571d921c1e5340 100644 (file)
@@ -4,6 +4,7 @@ import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.simantics.workbench.internal.contributions.search.SearchTrim;\r
+import org.simantics.workbench.search.SearchQuery;\r
 \r
 public class FindSearchTrim extends SearchTrim {\r
        \r
@@ -28,13 +29,19 @@ public class FindSearchTrim extends SearchTrim {
         if (query.trim().isEmpty())\r
             return;\r
 \r
-        query = filter(query);\r
-        query = "Name:" + query + " OR Types:" + query;\r
+//        query = filter(query);\r
+//        query = "Name:" + query + " OR Types:" + query;\r
         \r
         // Add option for showing only findings in currently open diagram\r
+//        if (scope == Scope.CURRENT_DIAGRAM)\r
+//             query += " " + CURRENT_DIAGRAM_OPTION;\r
+//        SearchQuery searchQuery = new SearchQuery(originalQuery,query);\r
+        SearchQuery searchQuery = new SearchQuery(originalQuery);\r
+        searchQuery.setSearchFlag("Name", "on");\r
+        searchQuery.setSearchFlag("Types", "on");\r
         if (scope == Scope.CURRENT_DIAGRAM)\r
-               query += " " + CURRENT_DIAGRAM_OPTION;\r
-        performQuery(originalQuery, query, ResultBrowser.VIEW);\r
+               searchQuery.setSearchParam(CURRENT_DIAGRAM_OPTION);\r
+        performQuery(searchQuery, ResultBrowser.VIEW);\r
         \r
        }       \r
 \r