Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2011-03-02 09:58:51 +0000
committervlorenzo2011-03-02 09:58:51 +0000
commit9ff6ac49f82704998a317f4048ee92b9a3f6b8e3 (patch)
treeb78a8e09ed7f334bdf1d50c18b7380bf08a66794 /incoming
parentf31469a74641cfeae0cd09acc6595080fa278b7e (diff)
downloadorg.eclipse.papyrus-9ff6ac49f82704998a317f4048ee92b9a3f6b8e3.tar.gz
org.eclipse.papyrus-9ff6ac49f82704998a317f4048ee92b9a3f6b8e3.tar.xz
org.eclipse.papyrus-9ff6ac49f82704998a317f4048ee92b9a3f6b8e3.zip
NEW - bug 336917: [Model Explorer] [TableEditor] Model explorer should support Tabular Editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=336917 Add the Drag possibility for the Model Explorer Remove the action : "Add to Table"
Diffstat (limited to 'incoming')
-rw-r--r--incoming/org.eclipse.papyrus.table.menu/plugin.xml3
-rw-r--r--incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/actions/AddToCurrentTableAction.java2
-rw-r--r--incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/handler/AddToCurrentTableHandler.java2
-rw-r--r--incoming/org.eclipse.papyrus.table.modelexplorer/plugin.xml8
-rw-r--r--incoming/org.eclipse.papyrus.table.modelexplorer/src/org/eclipse/papyrus/table/modelexplorer/dnd/CustomDragAdapterAssistant.java77
5 files changed, 90 insertions, 2 deletions
diff --git a/incoming/org.eclipse.papyrus.table.menu/plugin.xml b/incoming/org.eclipse.papyrus.table.menu/plugin.xml
index c166596af6e..ac2c5fd81c3 100644
--- a/incoming/org.eclipse.papyrus.table.menu/plugin.xml
+++ b/incoming/org.eclipse.papyrus.table.menu/plugin.xml
@@ -38,6 +38,8 @@
commandId="org.eclipse.papyrus.table.menu.add.in.table">
</handler>
</extension>
+ <!-- We remove this action, between, now we have the Drag&Drop -->
+ <!--
<extension
point="org.eclipse.ui.menus">
<menuContribution
@@ -61,6 +63,7 @@
</command>
</menuContribution>
</extension>
+ -->
<extension
point="org.eclipse.ui.menus">
<menuContribution
diff --git a/incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/actions/AddToCurrentTableAction.java b/incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/actions/AddToCurrentTableAction.java
index aa5720995fa..433e0e99972 100644
--- a/incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/actions/AddToCurrentTableAction.java
+++ b/incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/actions/AddToCurrentTableAction.java
@@ -40,7 +40,7 @@ import org.eclipse.ui.PlatformUI;
* This action allows to add selected elements in the model explorer in the last opened table
*
*
- * @deprecated : the drop action should be provided by the model explorer
+ * @deprecated : the drag&drop replaces this action
*/
@Deprecated
public class AddToCurrentTableAction {
diff --git a/incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/handler/AddToCurrentTableHandler.java b/incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/handler/AddToCurrentTableHandler.java
index b8ce39db1a2..d96be0441e0 100644
--- a/incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/handler/AddToCurrentTableHandler.java
+++ b/incoming/org.eclipse.papyrus.table.menu/src/org/eclipse/papyrus/table/menu/handler/AddToCurrentTableHandler.java
@@ -31,7 +31,7 @@ import org.eclipse.ui.PlatformUI;
*
* This handler is used to add element in a open table
*
- * @deprecated : a drop action provided by the Model Explorer should replace this action
+ * @deprecated : a drop action provided by the Model Explorer replaces this action
*/
@Deprecated
public class AddToCurrentTableHandler extends org.eclipse.papyrus.diagram.menu.actions.handlers.AbstractGraphicalCommandHandler {
diff --git a/incoming/org.eclipse.papyrus.table.modelexplorer/plugin.xml b/incoming/org.eclipse.papyrus.table.modelexplorer/plugin.xml
index 524035cf320..e77a7bb04f9 100644
--- a/incoming/org.eclipse.papyrus.table.modelexplorer/plugin.xml
+++ b/incoming/org.eclipse.papyrus.table.modelexplorer/plugin.xml
@@ -168,5 +168,13 @@
type="org.eclipse.jface.viewers.IStructuredSelection">
</propertyTester>
</extension>
+ <!--We add a drag assistant in order support drag and drop between Model Explorer and Table -->
+ <extension
+ point="org.eclipse.ui.navigator.viewer">
+ <dragAssistant
+ class="org.eclipse.papyrus.table.modelexplorer.dnd.CustomDragAdapterAssistant"
+ viewerId="org.eclipse.papyrus.modelexplorer.modelexplorer">
+ </dragAssistant>
+ </extension>
</plugin>
diff --git a/incoming/org.eclipse.papyrus.table.modelexplorer/src/org/eclipse/papyrus/table/modelexplorer/dnd/CustomDragAdapterAssistant.java b/incoming/org.eclipse.papyrus.table.modelexplorer/src/org/eclipse/papyrus/table/modelexplorer/dnd/CustomDragAdapterAssistant.java
new file mode 100644
index 00000000000..05877d59500
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.table.modelexplorer/src/org/eclipse/papyrus/table/modelexplorer/dnd/CustomDragAdapterAssistant.java
@@ -0,0 +1,77 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.table.modelexplorer.dnd;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
+
+/**
+ * This class allows to provides Drag&Drop between the Model Explorer and the Tables (or others View/Editors)
+ *
+ *
+ *
+ */
+public class CustomDragAdapterAssistant extends CommonDragAdapterAssistant {
+
+ /**
+ *
+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#getSupportedTransferTypes()
+ *
+ * @return
+ */
+ @Override
+ public Transfer[] getSupportedTransferTypes() {
+ return new Transfer[]{ LocalTransfer.getInstance() };
+ }
+
+ /**
+ *
+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ *
+ * @param anEvent
+ * @param aSelection
+ * @return
+ */
+ @Override
+ public boolean setDragData(DragSourceEvent anEvent, IStructuredSelection aSelection) {
+ Iterator<?> iter = aSelection.iterator();
+ List<Object> selectedElements = new ArrayList<Object>();
+
+ while(iter.hasNext()) {
+ Object current = iter.next();
+ if(current instanceof IAdaptable) {
+ EObject eobject = (EObject)((IAdaptable)current).getAdapter(EObject.class);
+ if(eobject != null) {
+ selectedElements.add(eobject);
+ }
+ }
+ }
+
+ if(!selectedElements.isEmpty()) {
+ anEvent.data = new StructuredSelection(selectedElements);
+ }
+ return anEvent.data != null;
+ }
+}

Back to the top