--- /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;\r
+\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.simantics.browsing.ui.GraphExplorer;\r
+import org.simantics.browsing.ui.common.views.PropertyTableConstants;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.ui.dnd.BasicDragSource;\r
+import org.simantics.ui.dnd.SessionContainer;\r
+\r
+public class PropertyTableUtil {\r
+\r
+ /**\r
+ * @param explorer\r
+ * @return the object representing the drag source. If the object implements\r
+ * {@link SessionContainer}, its\r
+ * {@link SessionContainer#setSession(Session)} will be invoked\r
+ * every time the active database session changes.\r
+ */\r
+ public static Object createResourceDragSource(GraphExplorer explorer) {\r
+ ISelectionProvider selectionProvider = (ISelectionProvider)explorer.getAdapter(ISelectionProvider.class);\r
+ Control control = explorer.getControl();\r
+ return new BasicDragSource(selectionProvider, control, null, PropertyTableConstants.DND_PURPOSE_PROPERTY);\r
+ }\r
+\r
+ public static void setupDragSource(Object dragSource, ISessionContext sessionContext) {\r
+ if (dragSource instanceof SessionContainer) {\r
+ ((SessionContainer) dragSource).setSession(sessionContext != null ? sessionContext.getSession() : null);\r
+ }\r
+ }\r
+\r
+}\r