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

Kernel: LWFXEF is accepting DND from model elements view.

parent 4286d713
No related branches found
No related tags found
1 merge request!923921
Showing
with 81 additions and 31 deletions
ContextMenuUtil.java 405387151d45b09dffb3b6ba44f980313c8edcaf GREEN
CurvedLinkLayoutedContentAnchorangeController.java 67c20e31ddb82fe2fd499117193353b0545839a0 GREEN
EObjectDiagramController.java a34479522e68cd5f6dc64ca322eab3a56a95602a YELLOW
EObjectDiagramController.java 2b253941592ee25ead95223470f983f23ef9776f YELLOW
EObjectEllipticResizableContentControllerBase.java 3494d4f0dcdff5eb35f22f0e21d04df81b32e494 GREEN
EObjectModelChangeProvider.java f4b60cebb088a5c81ca92a41614e1a5d40030502 GREEN
EObjectRectangularResizableContentControllerBase.java f4a967591a60fadb20550ec3eaabccf240c9ec0d GREEN
......
......@@ -91,12 +91,14 @@ public class EObjectDiagramController<T extends EObject> extends ControllerBase
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDragOver(Dragboard db, DiagramCoordinate diagramLocation) {
return canCompose(db, diagramLocation, getModelElement());
double zoom = getViewer().getFeatures().getCurrentZoomFactor();
return canCompose(db, diagramLocation, getModelElement(), true, zoom);
}
/** {@inheritDoc} */
@Override
public boolean handleExternalDNDDrop(Dragboard db, DiagramCoordinate diagramLocation) {
return compose(db, diagramLocation, getModelElement());
double zoom = getViewer().getFeatures().getCurrentZoomFactor();
return compose(db, diagramLocation, getModelElement(), true, zoom);
}
}
......@@ -2,7 +2,7 @@ AbstractNameEditingSupport.java c57336a0e0da18711a1610ca667dfea76728807f GREEN
ActionUtils.java 322f43d4f92f992daef8ac88eb0f9197c840c89b GREEN
DragAndDropBaseUtils.java d375377f9124f6113b2a295e6b0e09ac8966e564 GREEN
EllipseLayoutUIUtils.java 4dd9dbd96a45e8c455c019caa19e4a50f18336af GREEN
FXDNDUtils.java 5572358a950e932a65dfa053ca02e2fbbef5568e RED
FXDNDUtils.java 6ce94e239e68f9e2b3cc0524b072606f4a120076 YELLOW
FontUtils.java a167a05bdaa8da9853705cc5134f30f6d81bc9f2 GREEN
GCStateManager.java 983973a92376b5c757c1253b32e33d0666ccdf7b GREEN
LWFXEditorUtils.java c624d3f0f6487b6d426b168dad048b2c39e71114 GREEN
......
......@@ -15,9 +15,12 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.utils;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint;
import static org.fortiss.tooling.kernel.service.IPrototypeService.PROTOTYPE_DATA_FORMAT;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.base.dnd.ElementDropContext;
import org.fortiss.tooling.base.model.layout.Point;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.service.ICommandStackService;
......@@ -33,42 +36,85 @@ import javafx.scene.input.Dragboard;
*/
public final class FXDNDUtils {
/** Returns whether element composition can be done via {@link IElementCompositorService}. */
public static boolean canCompose(Dragboard db, DiagramCoordinate location, EObject container) {
public static boolean canCompose(Dragboard db, EObject container) {
Prototype proto = extractPrototype(db);
if(proto != null) {
// FIXME: location
return IElementCompositorService.getInstance().canCompose(container,
proto.getPrototypeCopy(), null);
}
return false;
}
/** Extracts the prototype from the dragboard. */
private static Prototype extractPrototype(Dragboard db) {
Object data = db.getContent(PROTOTYPE_DATA_FORMAT);
if(data instanceof String) {
return IPrototypeService.getInstance().getPrototypeByUniqueID((String)data);
/** Returns whether element composition can be done via {@link IElementCompositorService}. */
public static boolean canCompose(Dragboard db, DiagramCoordinate location, EObject container,
boolean isRootContainer, double zoom) {
Prototype proto = extractPrototype(db);
if(proto != null) {
ElementDropContext ctx =
createElementDropContext(location, container, isRootContainer, zoom);
return IElementCompositorService.getInstance().canCompose(container,
proto.getPrototypeCopy(), ctx);
}
return null;
return false;
}
/** Composes the elements using {@link IElementCompositorService}. */
public static boolean compose(Dragboard db, DiagramCoordinate location, EObject container) {
public static boolean compose(Dragboard db, EObject container) {
Prototype proto = extractPrototype(db);
if(proto != null) {
IElementCompositorService ecs = IElementCompositorService.getInstance();
EObject copy = proto.getPrototypeCopy();
if(ecs.canCompose(container, copy, null)) {
// FIXME: location
ICommandStackService.getInstance().runAsCommand(container, () -> {
ecs.compose(container, copy, null);
});
return true;
}
return doElementComposition(container, copy, null);
}
return false;
}
/**
* Composes the elements using {@link IElementCompositorService} creating an
* {@link ElementDropContext} for the given location, root element, and zoom factor.
*/
public static boolean compose(Dragboard db, DiagramCoordinate location, EObject container,
boolean isRootContainer, double zoom) {
Prototype proto = extractPrototype(db);
if(proto != null) {
EObject copy = proto.getPrototypeCopy();
ElementDropContext ctx =
createElementDropContext(location, container, isRootContainer, zoom);
return doElementComposition(container, copy, ctx);
}
return false;
}
/** Delegates to {@link IElementCompositorService} in order to compose the elements. */
private static boolean doElementComposition(EObject container, EObject contained,
ElementDropContext context) {
IElementCompositorService ecs = IElementCompositorService.getInstance();
if(ecs.canCompose(container, contained, context)) {
ICommandStackService.getInstance().runAsCommand(container, () -> {
ecs.compose(container, contained, context);
});
return true;
}
return false;
}
/** Creates the {@link ElementDropContext} containing the drop location. */
private static ElementDropContext createElementDropContext(DiagramCoordinate location,
EObject container, boolean isRootContainer, double zoom) {
Point dcLocation = createPoint((int)location.getX(), (int)location.getY(), "");
ElementDropContext ctx =
new ElementDropContext(container, dcLocation, isRootContainer, zoom);
return ctx;
}
/** Extracts the prototype from the dragboard. */
private static Prototype extractPrototype(Dragboard db) {
Object data = db.getContent(PROTOTYPE_DATA_FORMAT);
if(data instanceof String) {
return IPrototypeService.getInstance().getPrototypeByUniqueID((String)data);
}
return null;
}
/** Constructor. */
private FXDNDUtils() {
// prevent instantiation
......
......@@ -3,6 +3,6 @@ DynamicTreeItem.java 75dc5534b119ffdb3c10a65810c2a0f330b7955e GREEN
DynamicTreeTableUIProviderBase.java 75ddf3e91c08fd6a5853ab261593040d1039d774 YELLOW
DynamicTreeTableViewer.java 7d35586715715a2b2b29bac37913480b18ca00d2 YELLOW
DynamicTreeUIProviderBase.java e9b68607683de279d0cb8712a28dc131c5c33ece YELLOW
DynamicTreeViewer.java ff43fff033e81c7eded44baab16e5a5a05b26213 YELLOW
DynamicTreeViewer.java 4f17aa4279b6403d3a90ac8547fa86de780fc0ac YELLOW
DynamicTreeViewerBase.java 47124c847de322a0ae26eb7a114f85ce4bd02d7e GREEN
IDoubleClickHandler.java 447f7769dead9a106b3ea3139ef0da51eb0b9a89 GREEN
......@@ -146,15 +146,11 @@ public final class DynamicTreeViewer<T> extends DynamicTreeViewerBase<T> {
dragDetected(evt, this, item);
});
this.setOnDragOver(evt -> {
System.out.println("Over " + item.toString());
dragOver(evt, item);
});
this.setOnDragDropped(evt -> {
dragDropped(evt, item);
});
this.setOnDragExited(evt -> {
System.out.println("Exited " + item.toString());
});
} else {
this.setText(null);
this.setGraphic(null);
......
......@@ -8,5 +8,5 @@ EDragGesture.java 5cfa098d3877db11981c2750e5e103156d62fc5e GREEN
FeedbackChange.java b088fa89af648f1674f2f9c1f7f99d585ce801ca GREEN
GridCanvasVisual.java 734027d56af342cd01ff445ba9347b8dbb6c83c2 GREEN
MVCBundleManager.java 2b4ab114c55b30a3d98d7135458f8f3ddd244d58 GREEN
MouseState.java 793fbc9628bb96c3359a3c496d3cc94f5ec2585d YELLOW
MouseState.java 3d9993f799d5d74bc74ac03b46e4a1857c4d267e YELLOW
SVGExporter.java 2211f06d81c7b0523ae52dc832410a76875a9e07 GREEN
......@@ -35,6 +35,7 @@ import javafx.scene.input.DragEvent;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.input.TransferMode;
/**
* Class for monitoring mouse operations including clicking, dragging and linking
......@@ -339,7 +340,10 @@ public final class MouseState {
lastMouseLocation =
viewer.convertEventToDiagramCoordinates(event.getX(), event.getY(), source);
if(ctrl != null) {
ctrl.handleExternalDNDDragOver(event.getDragboard(), lastMouseLocation);
if(ctrl.handleExternalDNDDragOver(event.getDragboard(), lastMouseLocation)) {
event.acceptTransferModes(TransferMode.ANY);
event.consume();
}
}
}
};
......@@ -358,7 +362,10 @@ public final class MouseState {
lastMouseLocation =
viewer.convertEventToDiagramCoordinates(event.getX(), event.getY(), source);
if(ctrl != null) {
ctrl.handleExternalDNDDrop(event.getDragboard(), lastMouseLocation);
if(ctrl.handleExternalDNDDrop(event.getDragboard(), lastMouseLocation)) {
event.setDropCompleted(true);
event.consume();
}
}
}
};
......
......@@ -4,7 +4,7 @@ EObjectActionBase.java 4ef9f8be59e64d4838acc9e268d418ba5d94fa1a GREEN
EReferenceListPropertySectionBase.java 7390dd7bfdc979e8ff0c5c30c67ab7b6c9d70c92 GREEN
EReferencePropertySectionBase.java 0548da6778516003257f59d0b4c2b60d458be3b6 GREEN
EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN
FXEditorBase.java 545085c3270f09d69b609f328792e904ebda23ff GREEN
FXEditorBase.java 40caf638c7b4c02da5aece0d9d58883bce630e76 YELLOW
IListPropertySection.java 8bb00fe7959583e794ff9437b7a77404c9a9e70f GREEN
LWFXEFEditorBase.java f6b160b700a0287021402b5702beb2bfdce3dc2e GREEN
ModelEditorBindingBase.java b9b1a1c5a48a6e677d1f57ad55a6126d9703c4b5 GREEN
......
......@@ -47,7 +47,6 @@ public abstract class FXEditorBase<T extends EObject> extends EditorBase<T>
FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
Scene scene = new Scene(createSceneRoot());
canvas.setScene(scene);
getSite().setSelectionProvider(this);
}
......
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