From 896d75d67750f8cda9c34d1f283d6957fd2a65e5 Mon Sep 17 00:00:00 2001 From: miettinen Date: Thu, 22 Aug 2013 11:36:08 +0000 Subject: [PATCH] Filtering Sysdyn search results (refs #3966). 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 --- .../ui/editor/OpenDiagramFromComponentAdapter.java | 2 +- .../sysdyn/ui/function/ModulesSearchFunction.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java index fa3d397b..4842bc32 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/OpenDiagramFromComponentAdapter.java @@ -116,7 +116,7 @@ public class OpenDiagramFromComponentAdapter extends AbstractResourceEditorAdapt Layer0 l0 = Layer0.getInstance(g); SysdynResource SYSDYN = SysdynResource.getInstance(g); - if (g.isInstanceOf(module, SYSDYN.IndependentVariable) || g.isInstanceOf(module, SYSDYN.Input)) { + if (g.isInstanceOf(module, SYSDYN.IndependentVariable) || g.isInstanceOf(module, SYSDYN.Input) || g.isInstanceOf(module, SYSDYN.Module)) { Collection result = new ArrayList(1); Resource composite = g.getSingleObject(module, l0.PartOf); 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 68d716c5..e1c422e5 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 @@ -29,6 +29,7 @@ import org.simantics.diagram.stubs.DiagramResource; import org.simantics.layer0.Layer0; import org.simantics.operation.Layer0X; import org.simantics.scl.runtime.function.FunctionImpl5; +import org.simantics.sysdyn.SysdynResource; import org.simantics.workbench.search.NamedResource; import org.simantics.workbench.search.SearchResult; import org.simantics.workbench.search.Searching; @@ -41,11 +42,13 @@ import org.simantics.workbench.search.Searching; */ public class ModulesSearchFunction extends FunctionImpl5> { + private final int MAX_RESULTS = 50000; + @Override public Collection apply(IProgressMonitor monitor, ReadGraph graph, Resource model, String query, Integer maxResults) { try { Collection> results = Searching.performSearch(graph, - Layer0X.getInstance(graph).Dependencies, model, query, maxResults); + Layer0X.getInstance(graph).Dependencies, model, query, MAX_RESULTS); return generateSearchResults(graph, results); } catch (DatabaseException e) { @@ -58,6 +61,7 @@ public class ModulesSearchFunction extends FunctionImpl5> results) throws DatabaseException { Layer0 L0 = Layer0.getInstance(graph); DiagramResource DIA = DiagramResource.getInstance(graph); + SysdynResource SYSDYN = SysdynResource.getInstance(graph); Collection result = new ArrayList(results.size()); Set processed = new HashSet(); @@ -65,6 +69,12 @@ public class ModulesSearchFunction extends FunctionImpl5 r : results) { Resource resource = (Resource) r.get(Dependencies.FIELD_RESOURCE); + // Only Auxiliary, Stock, Valve, Input, and Module + if (!(graph.isInstanceOf(resource, SYSDYN.IndependentVariable) + || graph.isInstanceOf(resource, SYSDYN.Input) + || graph.isInstanceOf(resource, SYSDYN.Module))) + continue; + // Prevent index corruption from producing duplicate results. if (!processed.add(resource)) continue; -- 2.47.1