Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-12-13 17:17:14 +0000
committerGerrit Code Review @ Eclipse.org2016-12-14 09:27:08 +0000
commit196a8243261de00e321d5189c541550822e77e11 (patch)
tree156003a499bafcf1c84bf939bd7c725c8534b10d /plugins/infra
parent45f26f811c7a8b3eb7cf557eb076fc476c9e4654 (diff)
downloadorg.eclipse.papyrus-196a8243261de00e321d5189c541550822e77e11.tar.gz
org.eclipse.papyrus-196a8243261de00e321d5189c541550822e77e11.tar.xz
org.eclipse.papyrus-196a8243261de00e321d5189c541550822e77e11.zip
Bug 507293: [Table] Table popup menu are not yet available for empty area
https://bugs.eclipse.org/bugs/show_bug.cgi?id=507293 Add a default mouse event matcher for corner and no regions to fix the menu problem. Change-Id: I3e50484274b27fb8f0d543437f305a150e5ac2e1 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java5
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/matcher/DefaultMouseEventMatcher.java63
4 files changed, 76 insertions, 1 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
index 6a055962af2..5516bc6d1f7 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
@@ -30,6 +30,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable,
org.eclipse.papyrus.infra.nattable.manager.axis,
org.eclipse.papyrus.infra.nattable.manager.cell,
org.eclipse.papyrus.infra.nattable.manager.table,
+ org.eclipse.papyrus.infra.nattable.matcher,
org.eclipse.papyrus.infra.nattable.menu,
org.eclipse.papyrus.infra.nattable.messages,
org.eclipse.papyrus.infra.nattable.nattableconfiguration,
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java
index d2af0b1008b..28f59d12bfe 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java
@@ -18,6 +18,7 @@ import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.papyrus.infra.nattable.matcher.DefaultMouseEventMatcher;
import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
import org.eclipse.papyrus.infra.nattable.menu.PapyrusBodyPopupMenuAction;
import org.eclipse.papyrus.infra.nattable.menu.PapyrusHeaderPopupMenuAction;
@@ -80,6 +81,10 @@ public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration
protected void registerBodyPopupMenu(final UiBindingRegistry uiBindingRegistry) {
bodyPopupMenuAction = new PapyrusBodyPopupMenuAction(MenuConstants.BODY_POPUP_MENU_ID, this.natTable);
uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON), bodyPopupMenuAction);
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.CORNER, MouseEventMatcher.RIGHT_BUTTON), bodyPopupMenuAction);
+
+ // Manage the default menu (for no region selected)
+ uiBindingRegistry.registerMouseDownBinding(new DefaultMouseEventMatcher(SWT.NONE, MouseEventMatcher.RIGHT_BUTTON), bodyPopupMenuAction);
}
/**
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java
index 2116c74ce55..5bcb5d01a18 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java
@@ -17,6 +17,7 @@ import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.papyrus.infra.nattable.matcher.DefaultMouseEventMatcher;
import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
import org.eclipse.papyrus.infra.nattable.menu.TreePapyrusBodyPopupMenuAction;
import org.eclipse.papyrus.infra.nattable.menu.TreeRowPapyrusHeaderPopupMenuAction;
@@ -56,6 +57,11 @@ public class TreeTablePopupMenuConfiguration extends TablePopupMenuConfiguration
*/
@Override
protected void registerBodyPopupMenu(UiBindingRegistry uiBindingRegistry) {
- uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON), new TreePapyrusBodyPopupMenuAction(MenuConstants.BODY_POPUP_MENU_ID, this.natTable));
+ TreePapyrusBodyPopupMenuAction treeBodyPopupMenuAction = new TreePapyrusBodyPopupMenuAction(MenuConstants.BODY_POPUP_MENU_ID, this.natTable);
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON), treeBodyPopupMenuAction);
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.CORNER, MouseEventMatcher.RIGHT_BUTTON), treeBodyPopupMenuAction);
+
+ // Manage the default menu (for no region selected)
+ uiBindingRegistry.registerMouseDownBinding(new DefaultMouseEventMatcher(SWT.NONE, MouseEventMatcher.RIGHT_BUTTON), treeBodyPopupMenuAction);
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/matcher/DefaultMouseEventMatcher.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/matcher/DefaultMouseEventMatcher.java
new file mode 100644
index 00000000000..6ba440214d6
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/matcher/DefaultMouseEventMatcher.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.matcher;
+
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
+import org.eclipse.swt.events.MouseEvent;
+
+/**
+ * This allows to define a default mouse event matcher for menu in no region.
+ */
+public class DefaultMouseEventMatcher extends MouseEventMatcher {
+
+ /**
+ * Constructor
+ *
+ * @param stateMask
+ * @see "org.eclipse.swt.events.MouseEvent.stateMask"
+ * @param button
+ * The button event (right, left, ...)
+ * @see org.eclipse.swt.events.MouseEvent#button
+ * {@link MouseEventMatcher#LEFT_BUTTON},
+ * {@link MouseEventMatcher#RIGHT_BUTTON} can be used for convenience
+ */
+ public DefaultMouseEventMatcher(final int stateMask, final int button) {
+ super(stateMask, null, button);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher#matches(org.eclipse.nebula.widgets.nattable.NatTable, org.eclipse.swt.events.MouseEvent, org.eclipse.nebula.widgets.nattable.layer.LabelStack)
+ */
+ @Override
+ public boolean matches(final NatTable natTable, final MouseEvent event, final LabelStack regionLabels) {
+
+ boolean stateMaskMatches;
+ if (0 != getStateMask()) {
+ stateMaskMatches = (getStateMask() == event.stateMask) ? true : false;
+ } else {
+ stateMaskMatches = 0 == event.stateMask;
+ }
+
+ boolean eventRegionMatches = null == regionLabels && getEventRegion() == null;
+
+ boolean buttonMatches = getButton() != 0 ? (getButton() == event.button) : true;
+
+ return stateMaskMatches && eventRegionMatches && buttonMatches;
+ }
+
+}

Back to the top