-package org.simantics.document.linking.actions;\r
-\r
-import org.eclipse.ui.PlatformUI;\r
-import org.simantics.Simantics;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.document.linking.ontology.DocumentLink;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.utils.ui.ExceptionUtils;\r
-import org.simantics.workbench.search.ISearchService;\r
-import org.simantics.workbench.search.SearchQuery;\r
-\r
-public class SearchLinksAction implements ActionFactory {\r
- \r
- \r
- \r
- @Override\r
- public Runnable create(Object target) {\r
- if(!(target instanceof Resource))\r
- return null;\r
- final Resource resource = (Resource)target;\r
- return new Runnable() {\r
- \r
- @Override\r
- public void run() {\r
- try {\r
- String name = Simantics.getSession().syncRequest(new Read<String>() {\r
- @Override\r
- public String perform(ReadGraph graph)\r
- throws DatabaseException {\r
- Layer0 l0 = Layer0.getInstance(graph);\r
- String s = graph.getPossibleRelatedValue(resource, l0.HasLabel, Bindings.STRING);\r
- if (s == null)\r
- s = graph.getRelatedValue(resource, l0.HasName, Bindings.STRING); \r
- return s;\r
- }\r
- });\r
- ISearchService searchService = (ISearchService)PlatformUI.getWorkbench().getService(ISearchService.class);\r
- SearchQuery query = new SearchQuery(name);\r
- query.setSearchFlag("Name", "on");\r
- query.setSearchFlag(DocumentLink.URIs.SearchFunction, "on");\r
- searchService.performQuery(query, ISearchService.ResultBrowser.VIEW, true);\r
- } catch (DatabaseException e) {\r
- ExceptionUtils.logAndShowError("Cannot perform search",e);\r
- }\r
- \r
- \r
- }\r
- };\r
- }\r
-\r
-}\r
+package org.simantics.document.linking.actions;
+
+import org.eclipse.ui.PlatformUI;
+import org.simantics.Simantics;
+import org.simantics.databoard.Bindings;
+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.request.Read;
+import org.simantics.document.linking.ontology.DocumentLink;
+import org.simantics.layer0.Layer0;
+import org.simantics.utils.ui.ExceptionUtils;
+import org.simantics.workbench.search.ISearchService;
+import org.simantics.workbench.search.SearchQuery;
+
+public class SearchLinksAction implements ActionFactory {
+
+
+
+ @Override
+ public Runnable create(Object target) {
+ if(!(target instanceof Resource))
+ return null;
+ final Resource resource = (Resource)target;
+ return new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ String name = Simantics.getSession().syncRequest(new Read<String>() {
+ @Override
+ public String perform(ReadGraph graph)
+ throws DatabaseException {
+ Layer0 l0 = Layer0.getInstance(graph);
+ String s = graph.getPossibleRelatedValue(resource, l0.HasLabel, Bindings.STRING);
+ if (s == null)
+ s = graph.getRelatedValue(resource, l0.HasName, Bindings.STRING);
+ return s;
+ }
+ });
+ ISearchService searchService = (ISearchService)PlatformUI.getWorkbench().getService(ISearchService.class);
+ SearchQuery query = new SearchQuery(name);
+ query.setSearchFlag("Name", "on");
+ query.setSearchFlag(DocumentLink.URIs.SearchFunction, "on");
+ searchService.performQuery(query, ISearchService.ResultBrowser.VIEW, true);
+ } catch (DatabaseException e) {
+ ExceptionUtils.logAndShowError("Cannot perform search",e);
+ }
+
+
+ }
+ };
+ }
+
+}