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;
14 import org.eclipse.jface.viewers.ISelectionProvider;
15 import org.eclipse.swt.widgets.Control;
16 import org.simantics.browsing.ui.GraphExplorer;
17 import org.simantics.browsing.ui.common.views.PropertyTableConstants;
18 import org.simantics.db.Session;
19 import org.simantics.db.management.ISessionContext;
20 import org.simantics.ui.dnd.BasicDragSource;
21 import org.simantics.ui.dnd.SessionContainer;
23 public class PropertyTableUtil {
27 * @return the object representing the drag source. If the object implements
28 * {@link SessionContainer}, its
29 * {@link SessionContainer#setSession(Session)} will be invoked
30 * every time the active database session changes.
32 public static Object createResourceDragSource(GraphExplorer explorer) {
33 ISelectionProvider selectionProvider = (ISelectionProvider)explorer.getAdapter(ISelectionProvider.class);
34 Control control = explorer.getControl();
35 return new BasicDragSource(selectionProvider, control, null, PropertyTableConstants.DND_PURPOSE_PROPERTY);
38 public static void setupDragSource(Object dragSource, ISessionContext sessionContext) {
39 if (dragSource instanceof SessionContainer) {
40 ((SessionContainer) dragSource).setSession(sessionContext != null ? sessionContext.getSession() : null);