Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Papyrus/Papyrus Developer Guide/Papyrus Structure Behavior"

(New page: = Papyrus Struture <br> = will be done... = Model Explorer: Internal drag and drop<br> = This documentation explains the drag and drag from the model explorer to the model explorer.<...)
 
(No difference)

Revision as of 05:09, 26 January 2018

Papyrus Struture

will be done...

Model Explorer: Internal drag and drop

This documentation explains the drag and drag from the model explorer to the model explorer.


Architecture

The drag and drop is done thanks to the class org.eclipse.papyrus.modelexplorer.dnd.CommonDropAdapterAssistant.

This class is referenced into the eclipse framework by using the extension point org.eclipse.ui.navigator.navigatorContent

http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_navigator_navigatorContent.html

It contains an attribute drop assistant. See the following example:

<dropAssistant
               class="org.eclipse.papyrus.modelexplorer.dnd.CommonDropAdapterAssistant"
               id="org.eclipse.papyrus.modelexplorer.dnd.CommonDropAdapterAssistant">
            <possibleDropTargets>
               <or>
                  <instanceof
                        value="org.eclipse.gmf.runtime.notation.impl.DiagramImpl">
                  </instanceof>
                  <adapt
                        type="org.eclipse.emf.ecore.EObject">
                  </adapt>
               </or></possibleDropTargets>
         </dropAssistant>

To do the concrete drop, the following method has to be implemented:

public abstract IStatus handleDrop(CommonDropAdapter aDropAdapter,DropTargetEvent aDropTargetEvent, Object aTarget);


In the subclass, the handleDrop method asks and executes a command. I separate the problem of construction of the commands of its execution.

The creation of the command is done into the method getDrop()

There are several cases of the drop event:

  • LOCATION_BEFORE

     The mouse is placed just before an element

  • LOCATION_AFTER

    The mouse is placed just after an element

  • LOCATION_ON

   The mouse is placed on an element


The first two events are changments of order, we call the getChangeOrder in charge of building orders to rearrange the elements
For Location_on, this is a change of container, we call the method getDropIntoCommand in charge of creating the command to change container.


DropInto

The operation is quite simple: It is to create a query such as MoveRequest with child elements. If a child is a diagram, it requires a specific command to change the parent of the diagram.


getChangeOrder

This algorithm is more complicated. If we move the elements before or after another, there may be changes in container. It is therefore essential to create a MoveRequest in order to ensure semantics and graphic consistency thanks to the Edit Service.

For this we test the first selected item if the list that moves. We test if there is a change of parent. If it is, a MoveRequest with all the children will be built and a move command is executed.

Since then we specify the position of the (LOCATION_AFTER, LOCATION_BEFORE) you have to build a request such SetRequest. The collection of future collection is calculated (location of children in the future collection)
All command are inside a commpound command in order to ensure a atomic do, undo , redo.


Back to the top