Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Custom Drag Source for container drop tool
Custom Drag Source for container drop tool [message #1406879] Mon, 11 August 2014 10:45 Go to next message
Benoit Ries is currently offline Benoit RiesFriend
Messages: 86
Registered: May 2013
Member
Hi,

I have a custom view containing a TreeViewer composed of EObjects. I would like to drag these items from my treeviewer and drop them into my Sirius Editor.

Could someone give me a hint to get started ? which class should I customize, any extension points available, etc. ?


regards,
Benoit
Re: Custom Drag Source for container drop tool [message #1406927 is a reply to message #1406879] Mon, 11 August 2014 13:04 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi

You can read this article
https://www.eclipse.org/articles/Article-Workbench-DND/drag_drop.html to
know how to do drag'n drop.

Best Regards.

Le 11/08/2014 12:45, Benoit Ries a écrit :
> Hi,
>
> I have a custom view containing a TreeViewer composed of EObjects. I
> would like to drag these items from my treeviewer and drop them into my
> Sirius Editor.
>
> Could someone give me a hint to get started ? which class should I
> customize, any extension points available, etc. ?
>
>
> regards,
> Benoit


--
Esteban Dugueperoux - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom Drag Source for container drop tool [message #1746924 is a reply to message #1406879] Mon, 07 November 2016 17:57 Go to previous messageGo to next message
Chris Mamorella is currently offline Chris MamorellaFriend
Messages: 34
Registered: June 2013
Member
Benoit,

Did you ever figure out how to do this? That DnD tutorial does not seem to explain which extension points need to be used to provide this support in the Sirius editor. It explains how to implement using custom views but the Sirius editor seems like it is pretty encapsulated.

I have a navigator view containing EObjects. I can drag the object into the Sirius editor and over the appropriate container. As a consequence of the drop, I create a new EObject which sets a non-containment reference to the element that was dropped in. Before any refresh occurs, the parent semantic container DOES show the newly created EObject and its non-containment reference. However, there is no corresponding visual container representation of the new EObject... AND any subsequent refresh shows that the created EObject no longer exists as a child of the semantic container.

Any help or suggestions would be great.

Re: Custom Drag Source for container drop tool [message #1747070 is a reply to message #1746924] Wed, 09 November 2016 08:30 Go to previous messageGo to next message
Laurent Redor is currently offline Laurent RedorFriend
Messages: 300
Registered: July 2009
Senior Member
Hi,

You can have a look to Capella project [1], and clone the corresponding repo to have access to source [2]. This project has its own Project Explorer which support drag'n'drop into Sirius diagram.

The extension point used is org.eclipse.ui.navigator.viewer:
<dragAssistant class="org.polarsys.capella.core.platform.sirius.ui.navigator.drag.CapellaCommonDragAdapterAssistant"
         viewerId="capella.project.explorer">
</dragAssistant>

in plug-in org.polarsys.capella.core.platform.sirius.ui.navigator.

In Model Expkorer view of Sirius [3], the drop support is directly handled by super class through org.eclipse.ui.navigator.CommonViewer.initDragAndDrop().

[1] http://www.polarsys.org/capella/index.html
[2] https://wiki.polarsys.org/Capella/Technical_Information#Capella_Git
[3] org.eclipse.sirius.ui.tools.internal.views.modelexplorer.ModelExplorerView

--
Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius


Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom Drag Source for container drop tool [message #1747123 is a reply to message #1747070] Wed, 09 November 2016 17:47 Go to previous messageGo to next message
Chris Mamorella is currently offline Chris MamorellaFriend
Messages: 34
Registered: June 2013
Member
EDIT: I was able to clone from the https:// site. Thank you for that.

Upon further investigation, the issue I'm having seems like it may not be related to the drag-and-drop part at all. The Sirius editor currently recognizes the object that I'm trying to drop in, and in fact updates the EMF semantic model after the drop. But something is immediately forcing the model change to be rolled back... which is why it looks like the drag-and-drop is not working.

It would be greatly appreciated if you can point me to the Capella Sirius design description so I can compare and see if there is something in the Container Drop description that will shed some light.

[Updated on: Wed, 09 November 2016 18:16]

Report message to a moderator

Re: Custom Drag Source for container drop tool [message #1747147 is a reply to message #1747123] Thu, 10 November 2016 08:32 Go to previous messageGo to next message
Laurent Redor is currently offline Laurent RedorFriend
Messages: 300
Registered: July 2009
Senior Member
OK, so for an example of a "Container Drop" tool from a project explorer view, you can have a look to EcoreTools [1]. Here is an example of such tool in the VSM file [2].

[1] http://www.eclipse.org/ecoretools/
[2] http://git.eclipse.org/c/ecoretools/org.eclipse.ecoretools.git/tree/org.eclipse.emf.ecoretools.design/description/ecore.odesign#n272


Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom Drag Source for container drop tool [message #1747222 is a reply to message #1747147] Thu, 10 November 2016 23:06 Go to previous messageGo to next message
Chris Mamorella is currently offline Chris MamorellaFriend
Messages: 34
Registered: June 2013
Member
Laurent,

Thank you for your quick replies.

I tried integrating the CapellaCommonDragAdapterAssistant but #setDragData is never called. Looking at the transfer types declared, I'm not sure that class is extending anything. My view extends CommonNavigator, so DnD support should already exist for transfers within the same eclipse instance, right?

I am getting mixed signals on whether the Sirius editor can handle DnD from ONLY a model explorer-based view or if it can handle other EMF-based tree viewers. I was hoping that the Sirius editor would recognize any drag source that contained an EMF object as long as the Container Drop specified the "model" as the source. My Tree Viewer takes an EMF data structure as input and the nodes that I am dragging are the same EMF objects that are referenced in the diagram. Pretty much all the DnD examples online require both drag and drop listeners, but it seems our drop support is limited to what we specify in the Container Drop. It feels like we're troubleshooting a black box on the drop side because there's no error or log explaining why the drop fails silently... and we have no means to supply a custom drop listener for the Sirius editor.

I looked at: http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/tree/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/DDiagramEditorImpl.java

It seems that Sirius Diagram DnD does support LocalTransfer types and expects a tree selection for the drag source (which is a given when a tree view extends the Common Navigator Framework). Because everything fails silently it's impossible to know exactly why the editor is not recognizing the drag.

I am really hoping we can figure this out because DnD from the palette is a requirement by the customer.

[Updated on: Fri, 11 November 2016 18:20]

Report message to a moderator

Re: Custom Drag Source for container drop tool [message #1747381 is a reply to message #1747222] Mon, 14 November 2016 08:46 Go to previous messageGo to next message
Laurent Redor is currently offline Laurent RedorFriend
Messages: 300
Registered: July 2009
Senior Member
Hi,

Do you have a look at Entities diagram of EcoreTools (probably more simple example as Capella)?
As said in documentation [1], there is the capability to use the drag'n'drop from the Model Explorer view. I think it's closer to what you want to do.

[1] http://www.eclipse.org/ecoretools/doc/#EntitiesDiagramEditor

Regards,

--
Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius


Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Custom Drag Source for container drop tool [message #1748403 is a reply to message #1747381] Tue, 22 November 2016 19:31 Go to previous message
Chris Mamorella is currently offline Chris MamorellaFriend
Messages: 34
Registered: June 2013
Member
Is the Sirius editor only listening to drag events from model explorer-based views? It's critical to know the type of drag source listener or view that Sirius is expecting. For example, does my CNF-based tree view need to somehow extend the model explorer view or a related extension point to be recognized?

My customer only wants access to specific elements in the semantic model and does not care about any of the modeling project, design and session overhead - which is why I have a simplified tree view. This view is initialized to a semantic resource from the Sirius session. My content provider abstracts which EMF elements we want the user to see. The leaf nodes in the tree are EObjects.

When I select and drag an EObject "leaf" from this tree view into the Sirius editor, I get a visual indication that a drag is in progress (e.g. the (+) appears with the drag). The drop doesn't get recognized, however, and there's no indication that the drag target is recognized as a valid element type. There's no log or error - the drop just fails silently. I successfully used a drag-and-drop from within the Sirius editor, so we're familiar with the design syntax for this operation.

The Sirius content providers (e.g. SessionWrappedContentProvider) accept EMF objects as valid elements to be returned from its model explorer, so I don't see anything fundamentally "wrong" about my tree view's content. Do I have to extend the Sirius model explorer view for my view's drag events to be registered?









Previous Topic:The object is not contained in a resource
Next Topic:Open custom editor when double click on the Problems View
Goto Forum:
  


Current Time: Fri Apr 26 00:34:58 GMT 2024

Powered by FUDForum. Page generated in 0.03785 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top