Skip to content
Snippets Groups Projects
Commit b1f7620d authored by Florian Hölzl's avatar Florian Hölzl
Browse files

some cleanup and implementation

refs 265
parent 5777d1d5
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
* @ConQAT.Rating YELLOW Hash: 736E49D75B233CB065D623C1236DEE52
*/
public class CompositionServiceLocalTransfer extends SimpleObjectTransfer {
/** Singleton instance. */
......
......@@ -32,7 +32,7 @@ import org.eclipse.swt.dnd.DragSourceAdapter;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: F6A441B08B971BCE814614E2C95BF3AF
* @ConQAT.Rating YELLOW Hash: 95C337E875F3C6A557C6067C7B4D4C42
*/
public abstract class ConnectionCompositionDragSourceAdapter extends
ElementCompositionDragSourceAdapter {
......
......@@ -17,7 +17,12 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.dnd;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.widgets.Widget;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
/**
* {@link DropTargetAdapter} for completing an EObject connection via a drop
......@@ -30,5 +35,41 @@ import org.eclipse.swt.dnd.DropTargetAdapter;
*/
public abstract class ConnectionCompositionDropTargetAdapter extends
DropTargetAdapter {
// TODO: implement
/** {@inheritDoc} */
@Override
public void drop(DropTargetEvent event) {
ConnectionCompositionSource dragSource = getDragSourceFromTransfer();
EObject target = getTargetModel(event.item);
IConnectionCompositorService.INSTANCE.connect(
dragSource.getDesignatedElement(), target,
dragSource.getDesignatedParentElement(), null);
}
/** {@inheritDoc} */
@Override
public void dragOver(DropTargetEvent event) {
ConnectionCompositionSource dragSource = getDragSourceFromTransfer();
EObject target = getTargetModel(event.item);
if (target == null || dragSource.getDesignatedElement() == null) {
event.detail = DND.DROP_NONE;
return;
}
if (IConnectionCompositorService.INSTANCE.canConnect(
dragSource.getDesignatedElement(), target,
dragSource.getDesignatedParentElement(), null)) {
event.detail = DND.DROP_NONE;
return;
}
event.detail = DND.DROP_LINK;
}
/** Returns the current target element. */
protected abstract EObject getTargetModel(Widget dropTarget);
/** Returns the transfered object. */
private ConnectionCompositionSource getDragSourceFromTransfer() {
return (ConnectionCompositionSource) CompositionServiceLocalTransfer
.getInstance().getObject();
}
}
......@@ -18,14 +18,17 @@ $Id$
package org.fortiss.tooling.kernel.ui.dnd;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
/**
* DND transfer object for EObject linking.
* DND transfer object for EObject connection composition. If an object of this
* class is transfered via DND, the drop target usually uses the information
* contained herein to call the {@link IConnectionCompositorService}.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 8DA926A0F40041760D2A719D7D70F954
* @ConQAT.Rating YELLOW Hash: 7A9A3F2F21B95A7ABBC4CD6743224DD6
*/
public class ConnectionCompositionSource extends ElementCompositionSource {
/** Stores the designated parent element. */
......
......@@ -32,7 +32,7 @@ import org.eclipse.swt.dnd.Transfer;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 26A507800DA077F9F9F4593751639A74
* @ConQAT.Rating YELLOW Hash: 70273F4B405C5A2C55ACC3BFFC57D5C1
*/
public abstract class ElementCompositionDragSourceAdapter extends
DragSourceAdapter {
......
......@@ -18,14 +18,17 @@ $Id$
package org.fortiss.tooling.kernel.ui.dnd;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
/**
* DND transfer object for EObject element composition.
* DND transfer object for EObject element composition. If an object of this
* class is transfered via DND, the drop target usually uses the information
* contained herein to call the {@link IElementCompositorService}.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: A077E28503FF32EFBB402C70FC7A61C2
* @ConQAT.Rating YELLOW Hash: EAB27D084A09CC5D79CABEBF38DCD7F9
*/
public class ElementCompositionSource {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment