Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2018-05-25 10:11:11 -0400
committervincent lorenzo2018-05-28 04:34:30 -0400
commit236fc9c30f38888fcae5078970f60ec7ebb5e9f5 (patch)
treec0bab6447a9fceb6360c512c8b2e9034d9f235ae
parentd33fe868fd267f3b3805859c1f4fd42c9f4da0e3 (diff)
downloadorg.eclipse.papyrus-236fc9c30f38888fcae5078970f60ec7ebb5e9f5.tar.gz
org.eclipse.papyrus-236fc9c30f38888fcae5078970f60ec7ebb5e9f5.tar.xz
org.eclipse.papyrus-236fc9c30f38888fcae5078970f60ec7ebb5e9f5.zip
Bug 535120: [Table] NPE coming from NatTableDragSourceListener
Change-Id: I64ce374362fde6d3b572d117d648ade030a955ff Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDragSourceListener.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDragSourceListener.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDragSourceListener.java
index cd9008ff221..7b98bdca4c3 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDragSourceListener.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/listener/NatTableDragSourceListener.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2016 CEA LIST, ALL4TEC and others.
+ * Copyright (c) 2016, 2018 CEA LIST, ALL4TEC and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
+ * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 535120
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.listener;
@@ -77,9 +78,9 @@ public class NatTableDragSourceListener implements DragSourceListener {
@Override
public void dragStart(final DragSourceEvent event) {
event.doit = false;
-
for (int i = 0; i < getGridRegions().size() && !event.doit; i++) {
- if (!isResizing(event) && this.nattable.getRegionLabelsByXY(event.x, event.y).hasLabel(getGridRegions().get(i))) {
+
+ if (!isResizing(event) && isInsideTheTable(event) && this.nattable.getRegionLabelsByXY(event.x, event.y).hasLabel(getGridRegions().get(i))) {
event.doit = true;
}
}
@@ -91,6 +92,20 @@ public class NatTableDragSourceListener implements DragSourceListener {
}
}
+ /**
+ *
+ * @param event
+ * the event
+ * @return
+ * <code>true</code> if we are in the table
+ */
+ private boolean isInsideTheTable(final DragSourceEvent event) {
+ //see bug 535120
+ return this.nattable.getRegionLabelsByXY(event.x, event.y) != null;
+ // alternative method:
+ // INattableModelManager manager = this.nattable.getConfigRegistry().getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ // LocationValue location = manager.getLocationInTheTable(new Point(event.x, event.y));
+ }
/**
* @return The grid region where drag is enabled.

Back to the top