]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerMouseAdapter.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / GraphExplorerMouseAdapter.java
index 77b1b1a5355294f4007c69a6b71ffb4995724f05..f3e27f1be70dcffa8d9613d9ae49a05819bb407c 100644 (file)
@@ -1,93 +1,93 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 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
- *******************************************************************************/\r
-package org.simantics.browsing.ui.swt;\r
-\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionProvider;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.swt.events.MouseAdapter;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.simantics.browsing.ui.GraphExplorer;\r
-import org.simantics.browsing.ui.NodeContext;\r
-import org.simantics.utils.ui.AdaptionUtils;\r
-import org.simantics.utils.ui.action.IPriorityAction;\r
-\r
-/**\r
- * An abstract base class for implementing SWT mouse event handlers for\r
- * SWT-based {@link GraphExplorer}.\r
- * \r
- * <p>\r
- * Use {@link #getClickedContext(MouseEvent)} to find the possible NodeContext\r
- * the user clicked. You may also reimplement\r
- * {@link #handleContextDoubleClick(NodeContext)} for the easiest way to\r
- * redefine double click handling.\r
- * \r
- * @author Tuukka Lehtonen\r
- * \r
- * @see IPriorityAction\r
- */\r
-public class GraphExplorerMouseAdapter extends MouseAdapter {\r
-\r
-    protected GraphExplorer ge;\r
-\r
-    public GraphExplorerMouseAdapter(GraphExplorer ge) {\r
-        this.ge = ge;\r
-    }\r
-\r
-    protected ISelection getClickedContext(MouseEvent e) {\r
-//        final Tree tree = (Tree) e.getSource();\r
-//        Point point = new Point(e.x, e.y);\r
-//        TreeItem item = tree.getItem(point);\r
-//\r
-//        // No selectable item at point?\r
-//        if (item == null)\r
-//            return null;\r
-//\r
-//        Object data = item.getData();\r
-       Object data = ge.getClicked(e);\r
-       if (data == null)\r
-               return null;\r
-       \r
-        NodeContext context = AdaptionUtils.adaptToSingle(data, NodeContext.class);\r
-        if (context == null)\r
-            return null;\r
-        //System.out.println("double clicked tree item data: " + data);\r
-\r
-        ISelectionProvider sp = (ISelectionProvider) ge.getAdapter(ISelectionProvider.class);\r
-        ISelection selection = sp.getSelection();\r
-        //System.out.println("double clicked tree selection: " + selection);\r
-\r
-        // Validate that the selection matches the clicked data.\r
-        NodeContext selectionContext = AdaptionUtils.adaptToSingle(selection, NodeContext.class);\r
-        if (!context.equals(selectionContext)) {\r
-            //ErrorLogger.defaultLogWarning("GraphExplorer selection does not match clicked tree item's NodeContext", new Exception("stacktrace"));\r
-            return new StructuredSelection(context);\r
-        }\r
-\r
-        return selection;\r
-    }\r
-\r
-    @Override\r
-    public void mouseDoubleClick(MouseEvent e) {\r
-        ISelection context = getClickedContext(e);\r
-        if (context == null)\r
-            return;\r
-\r
-        Control tree = (Control)e.getSource();\r
-        handleContextDoubleClick(tree, context);\r
-    }\r
-\r
-    protected void handleContextDoubleClick(Control tree, ISelection selection) {\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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
+ *******************************************************************************/
+package org.simantics.browsing.ui.swt;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.widgets.Control;
+import org.simantics.browsing.ui.GraphExplorer;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.utils.ui.AdaptionUtils;
+import org.simantics.utils.ui.action.IPriorityAction;
+
+/**
+ * An abstract base class for implementing SWT mouse event handlers for
+ * SWT-based {@link GraphExplorer}.
+ * 
+ * <p>
+ * Use {@link #getClickedContext(MouseEvent)} to find the possible NodeContext
+ * the user clicked. You may also reimplement
+ * {@link #handleContextDoubleClick(NodeContext)} for the easiest way to
+ * redefine double click handling.
+ * 
+ * @author Tuukka Lehtonen
+ * 
+ * @see IPriorityAction
+ */
+public class GraphExplorerMouseAdapter extends MouseAdapter {
+
+    protected GraphExplorer ge;
+
+    public GraphExplorerMouseAdapter(GraphExplorer ge) {
+        this.ge = ge;
+    }
+
+    protected ISelection getClickedContext(MouseEvent e) {
+//        final Tree tree = (Tree) e.getSource();
+//        Point point = new Point(e.x, e.y);
+//        TreeItem item = tree.getItem(point);
+//
+//        // No selectable item at point?
+//        if (item == null)
+//            return null;
+//
+//        Object data = item.getData();
+       Object data = ge.getClicked(e);
+       if (data == null)
+               return null;
+       
+        NodeContext context = AdaptionUtils.adaptToSingle(data, NodeContext.class);
+        if (context == null)
+            return null;
+        //System.out.println("double clicked tree item data: " + data);
+
+        ISelectionProvider sp = (ISelectionProvider) ge.getAdapter(ISelectionProvider.class);
+        ISelection selection = sp.getSelection();
+        //System.out.println("double clicked tree selection: " + selection);
+
+        // Validate that the selection matches the clicked data.
+        NodeContext selectionContext = AdaptionUtils.adaptToSingle(selection, NodeContext.class);
+        if (!context.equals(selectionContext)) {
+            //ErrorLogger.defaultLogWarning("GraphExplorer selection does not match clicked tree item's NodeContext", new Exception("stacktrace"));
+            return new StructuredSelection(context);
+        }
+
+        return selection;
+    }
+
+    @Override
+    public void mouseDoubleClick(MouseEvent e) {
+        ISelection context = getClickedContext(e);
+        if (context == null)
+            return;
+
+        Control tree = (Control)e.getSource();
+        handleContextDoubleClick(tree, context);
+    }
+
+    protected void handleContextDoubleClick(Control tree, ISelection selection) {
+    }
+
+}