]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Filtering Sysdyn search results (refs #3966).
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 22 Aug 2013 11:36:08 +0000 (11:36 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 22 Aug 2013 11:36:08 +0000 (11:36 +0000)
Increased the max number of search results to 50000 (refs #4400).

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

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/function/ModulesSearchFunction.java

index fa3d397ba9947a732fc6c3663eeff03687629c01..4842bc32340828d102a8a68b3aed3dfbf919f288 100644 (file)
@@ -116,7 +116,7 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt
         Layer0 l0 = Layer0.getInstance(g);\r
         SysdynResource SYSDYN = SysdynResource.getInstance(g);\r
 \r
-        if (g.isInstanceOf(module, SYSDYN.IndependentVariable) || g.isInstanceOf(module, SYSDYN.Input)) {\r
+        if (g.isInstanceOf(module, SYSDYN.IndependentVariable) || g.isInstanceOf(module, SYSDYN.Input) || g.isInstanceOf(module, SYSDYN.Module)) {\r
             Collection<Runnable> result = new ArrayList<Runnable>(1);\r
 \r
             Resource composite = g.getSingleObject(module, l0.PartOf);\r
index 68d716c5ea277301c2e304414757b8cce7c46353..e1c422e5d902ac7bce4c71d48d05d25648de9995 100644 (file)
@@ -29,6 +29,7 @@ import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.layer0.Layer0;\r
 import org.simantics.operation.Layer0X;\r
 import org.simantics.scl.runtime.function.FunctionImpl5;\r
+import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.workbench.search.NamedResource;\r
 import org.simantics.workbench.search.SearchResult;\r
 import org.simantics.workbench.search.Searching;\r
@@ -41,11 +42,13 @@ import org.simantics.workbench.search.Searching;
  */\r
 public class ModulesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadGraph, Resource, String, Integer, Collection<SearchResult>> {\r
 \r
+       private final int MAX_RESULTS = 50000;\r
+       \r
     @Override\r
     public Collection<SearchResult> apply(IProgressMonitor monitor, ReadGraph graph, Resource model, String query, Integer maxResults) {\r
         try {\r
             Collection<Map<String, Object>> results = Searching.performSearch(graph,\r
-                    Layer0X.getInstance(graph).Dependencies, model, query, maxResults);\r
+                    Layer0X.getInstance(graph).Dependencies, model, query, MAX_RESULTS);\r
 \r
             return generateSearchResults(graph, results);\r
         } catch (DatabaseException e) {\r
@@ -58,6 +61,7 @@ public class ModulesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadG
             Collection<Map<String, Object>> results) throws DatabaseException {\r
         Layer0 L0 = Layer0.getInstance(graph);\r
         DiagramResource DIA = DiagramResource.getInstance(graph);\r
+        SysdynResource SYSDYN = SysdynResource.getInstance(graph);\r
 \r
         Collection<SearchResult> result = new ArrayList<SearchResult>(results.size());\r
         Set<Resource> processed = new HashSet<Resource>();\r
@@ -65,6 +69,12 @@ public class ModulesSearchFunction extends FunctionImpl5<IProgressMonitor, ReadG
         for (Map<String, Object> r : results) {\r
             Resource resource = (Resource) r.get(Dependencies.FIELD_RESOURCE);\r
 \r
+            // Only Auxiliary, Stock, Valve, Input, and Module \r
+            if (!(graph.isInstanceOf(resource, SYSDYN.IndependentVariable)\r
+                       || graph.isInstanceOf(resource, SYSDYN.Input)\r
+                       || graph.isInstanceOf(resource, SYSDYN.Module)))\r
+                continue;\r
+\r
             // Prevent index corruption from producing duplicate results.\r
             if (!processed.add(resource))\r
                 continue;\r