Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-07-07 09:13:44 +0000
committervincent lorenzo2016-08-09 15:49:31 +0000
commit017b145bfc273a853e01d6ed086d0b49b4d83d4f (patch)
tree29c36ee1dca73a6c62759e1b29c7678d7b47d3bb /plugins/infra/nattable
parente9c7f9aaba08f17583ea58d26ea666eb67e00016 (diff)
downloadorg.eclipse.papyrus-017b145bfc273a853e01d6ed086d0b49b4d83d4f.tar.gz
org.eclipse.papyrus-017b145bfc273a853e01d6ed086d0b49b4d83d4f.tar.xz
org.eclipse.papyrus-017b145bfc273a853e01d6ed086d0b49b4d83d4f.zip
Bug 497328: [Table] Popup menu have some disabled items when first click
outside of the table https://bugs.eclipse.org/bugs/show_bug.cgi?id=497328 Manage the abstract table handler to get NatEventData even if we're not clicking on the table (we got NatTable from the active editor for the sub menu items). Change-Id: Id44fdc582533476f17f8f9ef3ccbf188f2ead642 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins/infra/nattable')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java56
2 files changed, 43 insertions, 16 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 dff21d98416..6e5e64b4939 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
@@ -63,7 +63,8 @@ Require-Bundle: org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0
org.eclipse.papyrus.infra.ui.emf;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.viewpoints.configuration;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)"
+ org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.editor;bundle-version="[1.4.0,2.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
Bundle-Version: 2.1.0.qualifier
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
index 961f214d207..8851c004904 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
@@ -20,12 +20,14 @@ import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.nebula.widgets.nattable.ui.menu.MenuItemProviders;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IMultiPageEditorPart;
import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
@@ -33,7 +35,14 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper;
+import org.eclipse.papyrus.infra.ui.util.EditorHelper;
import org.eclipse.papyrus.infra.ui.util.WorkbenchPartHelper;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
/**
@@ -154,24 +163,41 @@ public abstract class AbstractTableHandler extends AbstractHandler {
}
}
- // Commented since Papyrus 1.2 (Neon Mars 2016)
// that's why we can't add the variable NAT_EVENT_DATA_PARAMETER_ID and we need to create a NatEventData instead of to get it in evaluationContext
- // if (eventData == null) {
- // Point cursorLocation = Display.getDefault().getCursorLocation();
- // Control control = Display.getDefault().getCursorControl();// doesn't work when we are selecting a command in a sub menu!
- // if (control instanceof NatTable) {// : not nice, but required
- // cursorLocation = control.toControl(cursorLocation);
- // Event e = new Event();
- // e.x = cursorLocation.x;
- // e.y = cursorLocation.y;
- // e.display = Display.getDefault();
- // e.widget = control;
- // MouseEvent event = new MouseEvent(e);
- // eventData = NatEventData.createInstanceFromEvent(event);
- // }
- // }
+ if (eventData == null) {
+ Point cursorLocation = Display.getDefault().getCursorLocation();
+ Control control = null;
+
+ // Try to get the nattable from the multi diagram
+ // We need to manage it from active editor for the sub menu items
+ final IEditorPart activeEditor = EditorHelper.getCurrentEditor();
+ if (null != activeEditor) {
+ INattableModelManager nattableModelManager = null;
+ if(activeEditor instanceof IMultiPageEditorPart && null != ((IMultiPageEditorPart)activeEditor).getActiveEditor()){
+ nattableModelManager = ((IMultiPageEditorPart)activeEditor).getActiveEditor().getAdapter(INattableModelManager.class);
+ }else if(activeEditor instanceof IAdaptable){
+ nattableModelManager = ((IAdaptable)activeEditor).getAdapter(INattableModelManager.class);
+ }
+
+ if(null != nattableModelManager){
+ control = nattableModelManager.getAdapter(NatTable.class);
+ }
+ }
+
+ if (control instanceof NatTable) {// : not nice, but required
+ cursorLocation = control.toControl(cursorLocation);
+ Event e = new Event();
+ e.x = cursorLocation.x;
+ e.y = cursorLocation.y;
+ e.display = Display.getDefault();
+ e.widget = control;
+ MouseEvent event = new MouseEvent(e);
+ eventData = NatEventData.createInstanceFromEvent(event);
+ }
+ }
return eventData;
}
+
/**
*
* @param evaluationContext

Back to the top