--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 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.widgets;\r
+\r
+import org.eclipse.jface.viewers.IPostSelectionProvider;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.simantics.browsing.ui.GraphExplorer;\r
+import org.simantics.browsing.ui.swt.widgets.impl.MouseListenerImpl;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+abstract public class ExplorerMouseListenerImpl<T> extends MouseListenerImpl<T> {\r
+\r
+ private GraphExplorer explorer = null;\r
+ private ISelection selection;\r
+ \r
+ public ExplorerMouseListenerImpl(ISessionContext context) {\r
+ super(context);\r
+ }\r
+ \r
+ void register(GraphExplorer explorer) {\r
+ this.explorer = explorer;\r
+ }\r
+ \r
+ public void doubleClick(WriteGraph graph, T input) throws DatabaseException {\r
+\r
+ if(explorer == null) return;\r
+ \r
+ doubleClick(graph, input, selection);\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public void beforeApply(T input) {\r
+ \r
+ if(explorer == null) return;\r
+ \r
+ IPostSelectionProvider selectionProvider = (IPostSelectionProvider)explorer.getAdapter(IPostSelectionProvider.class);\r
+ selection = selectionProvider.getSelection();\r
+ \r
+ }\r
+\r
+ abstract public void doubleClick(WriteGraph graph, T input, ISelection selection) throws DatabaseException;\r
+ \r
+}\r
+
\ No newline at end of file