]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/internal/SearchResourceHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.debug.ui / src / org / simantics / debug / ui / internal / SearchResourceHandler.java
index 3fb4013d8f7690516481e43ab0e0c358f753b966..bf36166452ff9de727d8fa5fdb4b11f00cb1f68f 100644 (file)
@@ -1,84 +1,84 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2016 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *     Semantum Oy - refactoring (#6855)\r
- *******************************************************************************/\r
-package org.simantics.debug.ui.internal;\r
-\r
-import java.util.function.BiConsumer;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.jface.action.IAction;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.simantics.Simantics;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.common.request.ReadRequest;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.debug.ui.ResourceSearch;\r
-import org.simantics.debug.ui.SearchResourceDialog;\r
-import org.simantics.ui.workbench.action.ChooseActionRequest;\r
-import org.simantics.utils.Container;\r
-import org.simantics.utils.ui.SWTUtils;\r
-import org.simantics.utils.ui.action.IPriorityAction;\r
-import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
-\r
-public class SearchResourceHandler extends AbstractHandler {\r
-\r
-    @Override\r
-    public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        Shell shell = HandlerUtil.getActiveShellChecked(event);\r
-        Session session = Simantics.getSession();\r
-        SearchResourceDialog rld = new SearchResourceDialog(session, false, shell, "Open Resource");\r
-        rld.setResourceFilter(ResourceSearch.FILTER_ALL);\r
-        rld.setBlockOnOpen(true);\r
-        rld.open();\r
-        if (rld.getResult() == null)\r
-            return null;\r
-\r
-        String currentPerspectiveId = WorkbenchUtils.getCurrentPerspectiveId();\r
-\r
-        for (Object o : rld.getResult()) {\r
-            @SuppressWarnings("unchecked")\r
-            Container<Resource> rc = (Container<Resource>) o;\r
-            openPreferredEditor(shell, session, rc.get(), currentPerspectiveId);\r
-        }\r
-\r
-        return null;\r
-    }\r
-\r
-    private static void openPreferredEditor(Shell parent, Session s, Resource r, String defaultPerspective) {\r
-        findActions(s, r, defaultPerspective, (resourceName, actions) -> {\r
-            SWTUtils.asyncExec(parent, () -> {\r
-                IAction action = ChooseActionRequest.chooseAction(parent, actions, resourceName);\r
-                if (action != null)\r
-                    action.run();\r
-            });\r
-        });\r
-    }\r
-\r
-    private static void findActions(Session s, Resource r, String defaultPerspective, BiConsumer<String, IPriorityAction[]> consumer) {\r
-        s.asyncRequest(new ReadRequest() {\r
-            @Override\r
-            public void run(ReadGraph g) throws DatabaseException {\r
-                String resourceName = NameUtils.getSafeName(g, r);\r
-                IPriorityAction[] actions = ChooseActionRequest.findActions(g, r, defaultPerspective);\r
-                if (actions != null)\r
-                    consumer.accept(resourceName, actions);\r
-            }\r
-        });\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2016 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *     Semantum Oy - refactoring (#6855)
+ *******************************************************************************/
+package org.simantics.debug.ui.internal;
+
+import java.util.function.BiConsumer;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.simantics.Simantics;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.db.common.request.ReadRequest;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.debug.ui.ResourceSearch;
+import org.simantics.debug.ui.SearchResourceDialog;
+import org.simantics.ui.workbench.action.ChooseActionRequest;
+import org.simantics.utils.Container;
+import org.simantics.utils.ui.SWTUtils;
+import org.simantics.utils.ui.action.IPriorityAction;
+import org.simantics.utils.ui.workbench.WorkbenchUtils;
+
+public class SearchResourceHandler extends AbstractHandler {
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        Shell shell = HandlerUtil.getActiveShellChecked(event);
+        Session session = Simantics.getSession();
+        SearchResourceDialog rld = new SearchResourceDialog(session, false, shell, "Open Resource");
+        rld.setResourceFilter(ResourceSearch.FILTER_ALL);
+        rld.setBlockOnOpen(true);
+        rld.open();
+        if (rld.getResult() == null)
+            return null;
+
+        String currentPerspectiveId = WorkbenchUtils.getCurrentPerspectiveId();
+
+        for (Object o : rld.getResult()) {
+            @SuppressWarnings("unchecked")
+            Container<Resource> rc = (Container<Resource>) o;
+            openPreferredEditor(shell, session, rc.get(), currentPerspectiveId);
+        }
+
+        return null;
+    }
+
+    private static void openPreferredEditor(Shell parent, Session s, Resource r, String defaultPerspective) {
+        findActions(s, r, defaultPerspective, (resourceName, actions) -> {
+            SWTUtils.asyncExec(parent, () -> {
+                IAction action = ChooseActionRequest.chooseAction(parent, actions, resourceName);
+                if (action != null)
+                    action.run();
+            });
+        });
+    }
+
+    private static void findActions(Session s, Resource r, String defaultPerspective, BiConsumer<String, IPriorityAction[]> consumer) {
+        s.asyncRequest(new ReadRequest() {
+            @Override
+            public void run(ReadGraph g) throws DatabaseException {
+                String resourceName = NameUtils.getSafeName(g, r);
+                IPriorityAction[] actions = ChooseActionRequest.findActions(g, r, defaultPerspective);
+                if (actions != null)
+                    consumer.accept(resourceName, actions);
+            }
+        });
+    }
+
+}