X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fg2d%2Fevents%2FNodeEventHandler.java;h=1c1ac8a37a7b523ace66705188f148c1972ed763;hp=ec0a4fe5f1a35182901cdb311c9fe7186356b83f;hb=1ee8004c71eaa9818fe1a49e16d0463adbf559f6;hpb=cec265e1216a0a211e6e6dc4f91d5fda4c5747db diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/NodeEventHandler.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/NodeEventHandler.java index ec0a4fe5f..1c1ac8a37 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/NodeEventHandler.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/NodeEventHandler.java @@ -12,6 +12,7 @@ package org.simantics.scenegraph.g2d.events; import java.awt.Component; +import java.awt.GraphicsEnvironment; import java.awt.dnd.DnDConstants; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; @@ -35,6 +36,8 @@ import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonPressedEvent; import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDragBegin; import org.simantics.scenegraph.g2d.events.adapter.AWTMouseEventAdapter; import org.simantics.scenegraph.g2d.events.command.CommandEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Delivers events (mouse, key, focus, command, time) to scene graph nodes that @@ -44,6 +47,8 @@ import org.simantics.scenegraph.g2d.events.command.CommandEvent; */ public class NodeEventHandler implements IEventHandler { + private static final Logger LOGGER = LoggerFactory.getLogger(NodeEventHandler.class); + private static final boolean DEBUG_EVENTS = false; private static final boolean DEBUG_HANDLER_SORT = false; @@ -197,12 +202,6 @@ public class NodeEventHandler implements IEventHandler { */ protected G2DSceneGraph sg; - /** - * For proper initiation of native DnD operations within this AWT-based - * scenegraph system. - */ - protected DragSource ds = new DragSource(); - public NodeEventHandler(G2DSceneGraph sg) { this.sg = sg; } @@ -222,6 +221,11 @@ public class NodeEventHandler implements IEventHandler { } public void setRootPane(Component rootPane) { + if (GraphicsEnvironment.isHeadless()) { + LOGGER.info("Disabling DragSource in headless environments"); + return; + } + final DragSource ds = new DragSource(); final DragSourceListener dsl = new DragSourceListener() { @Override public void dropActionChanged(DragSourceDragEvent dsde) {