1 /*******************************************************************************
2 * Copyright (c) 2007, 2012 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.browsing.ui.swt.widgets;
14 import org.eclipse.jface.viewers.IPostSelectionProvider;
15 import org.eclipse.jface.viewers.ISelection;
16 import org.simantics.browsing.ui.GraphExplorer;
17 import org.simantics.browsing.ui.swt.widgets.impl.MouseListenerImpl;
18 import org.simantics.db.WriteGraph;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.db.management.ISessionContext;
22 abstract public class ExplorerMouseListenerImpl<T> extends MouseListenerImpl<T> {
24 private GraphExplorer explorer = null;
25 private ISelection selection;
27 public ExplorerMouseListenerImpl(ISessionContext context) {
31 void register(GraphExplorer explorer) {
32 this.explorer = explorer;
35 public void doubleClick(WriteGraph graph, T input) throws DatabaseException {
37 if(explorer == null) return;
39 doubleClick(graph, input, selection);
44 public void beforeApply(T input) {
46 if(explorer == null) return;
48 IPostSelectionProvider selectionProvider = (IPostSelectionProvider)explorer.getAdapter(IPostSelectionProvider.class);
49 selection = selectionProvider.getSelection();
53 abstract public void doubleClick(WriteGraph graph, T input, ISelection selection) throws DatabaseException;