From: luukkainen Date: Thu, 17 Oct 2013 09:09:06 +0000 (+0000) Subject: Hard-coded search options X-Git-Tag: 1.8.1~236 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=f6d3d423c16541367d96ae68ca73ef9a5cacc2d6;p=simantics%2Fsysdyn.git Hard-coded search options refs #4452 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27986 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/function/ModulesSearchFunction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/function/ModulesSearchFunction.java index c1cf02a4..5b294de2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/function/ModulesSearchFunction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/function/ModulesSearchFunction.java @@ -60,11 +60,10 @@ public class ModulesSearchFunction extends FunctionImpl5 apply(IProgressMonitor monitor, ReadGraph graph, Resource model, SearchQuery query, Integer maxResults) { try { // Check whether only currently open diagram is searched - String filteredQuery = query.getQuery().replace(FindSearchTrim.CURRENT_DIAGRAM_OPTION, ""); - Collection> results = Searching.performSearch(graph, - Layer0X.getInstance(graph).Dependencies, model, filteredQuery, MAX_RESULTS); + String filteredQuery = query.getQuery(); + Collection> results = Searching.performSearch(graph, Layer0X.getInstance(graph).Dependencies, model, filteredQuery, MAX_RESULTS); - if (filteredQuery.equals(query)) + if (!query.getSearchParams().contains(FindSearchTrim.CURRENT_DIAGRAM_OPTION)) return generateSearchResults(graph, results, Scope.ALL_MODELS); else return generateSearchResults(graph, results, Scope.CURRENT_DIAGRAM); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/FindSearchTrim.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/FindSearchTrim.java index c5d3523c..9aa886cf 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/FindSearchTrim.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/FindSearchTrim.java @@ -4,6 +4,7 @@ import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.simantics.workbench.internal.contributions.search.SearchTrim; +import org.simantics.workbench.search.SearchQuery; public class FindSearchTrim extends SearchTrim { @@ -28,13 +29,19 @@ public class FindSearchTrim extends SearchTrim { if (query.trim().isEmpty()) return; - query = filter(query); - query = "Name:" + query + " OR Types:" + query; +// query = filter(query); +// query = "Name:" + query + " OR Types:" + query; // Add option for showing only findings in currently open diagram +// if (scope == Scope.CURRENT_DIAGRAM) +// query += " " + CURRENT_DIAGRAM_OPTION; +// SearchQuery searchQuery = new SearchQuery(originalQuery,query); + SearchQuery searchQuery = new SearchQuery(originalQuery); + searchQuery.setSearchFlag("Name", "on"); + searchQuery.setSearchFlag("Types", "on"); if (scope == Scope.CURRENT_DIAGRAM) - query += " " + CURRENT_DIAGRAM_OPTION; - performQuery(originalQuery, query, ResultBrowser.VIEW); + searchQuery.setSearchParam(CURRENT_DIAGRAM_OPTION); + performQuery(searchQuery, ResultBrowser.VIEW); }