Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [GEF5] Show places where user can drop components
[GEF5] Show places where user can drop components [message #1771059] Mon, 21 August 2017 14:18 Go to next message
Maxim Martynov is currently offline Maxim MartynovFriend
Messages: 22
Registered: February 2017
Junior Member
1) I have ItemCreationModel like in tuturial. This model has 2 modes, ADD and SELECT.
2) I have Pane (JavaFx Hbox) with another children panes.
3) I create InsertIntoPanelHandlePart which show green GeometryNode<RoundedRectangle> when mouse onHover and ItemCreationModel mode=ADD. When user click on this green Rectangle a new Panel creates and add as children to parent Pane. All panes has order in parent.

Now i'm need ability to change position of children by drag and drop. The places where user can drop Panes must show like InsertIntoPanelHandlePart (green rectangle) on hover mouse but InsertIntoPanelHandlePart not show when the DragGesture is started. Is it possible to show HandlePart while DragGesture and handle the drop on this HandlePart?
Re: [GEF5] Show places where user can drop components [message #1771651 is a reply to message #1771059] Tue, 29 August 2017 07:23 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Sorry, but I cannot help you with the given information. Could you show some code, please?
Re: [GEF5] Show places where user can drop components [message #1773719 is a reply to message #1771651] Tue, 03 October 2017 13:38 Go to previous message
Maxim Martynov is currently offline Maxim MartynovFriend
Messages: 22
Registered: February 2017
Junior Member
I'm extends HoverGesture.
1) First i'm add Event filter for event type MouseEvent.DRAG_DETECTED which start scene.startFullDrag()
2) Second i override method org.eclipse.gef.mvc.fx.gestures.HoverGesture.isHoverEvent(MouseEvent) to support mouse event MouseDragEvent.MOUSE_DRAG_OVER

import java.util.IdentityHashMap;
import java.util.Map;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.input.MouseDragEvent;
import javafx.scene.input.MouseEvent;
import org.eclipse.gef.mvc.fx.gestures.HoverGesture;
import org.eclipse.gef.mvc.fx.viewer.IViewer;

public class HoverGestureWithDraggedSupport extends HoverGesture {
	private final Map<Scene, EventHandler<MouseEvent>> fullDragFilters = new IdentityHashMap<>();

	@Override
	protected void doActivate() {
		super.doActivate();

		for (IViewer viewer : getDomain().getViewers().values()) {
			Scene scene = viewer.getCanvas().getScene();
			if (!fullDragFilters.containsKey(scene)) {
				EventHandler<MouseEvent> filter = new EventHandler<MouseEvent>() {
					@Override
					public void handle(MouseEvent event) {
						scene.startFullDrag();
					}
				};
				scene.addEventFilter(MouseEvent.DRAG_DETECTED, filter);
				fullDragFilters.put(scene, filter);
			}
		}
	}

	@Override
	protected void doDeactivate() {
		for (Scene scene : fullDragFilters.keySet()) {
			scene.removeEventFilter(MouseEvent.DRAG_DETECTED, fullDragFilters.remove(scene));
		}
		super.doDeactivate();
	}

	protected boolean isHoverEvent(MouseEvent event) {
		//@formatter:off
		return event.getEventType().equals(MouseEvent.MOUSE_MOVED)
				|| event.getEventType().equals(MouseEvent.MOUSE_ENTERED_TARGET)
				|| event.getEventType().equals(MouseEvent.MOUSE_EXITED_TARGET)
				|| event.getEventType().equals(MouseDragEvent.MOUSE_DRAG_OVER);
		//@formatter:on
	}
}


I think this ability to handle MOUSE_DRAG_OVER events must be in default implementation of GEF.

Best regards!
Previous Topic:Depth-first Traversal problem in large-scale model.
Next Topic:GEF 5 (MVC) + e4 RCP Application Tutorial
Goto Forum:
  


Current Time: Thu Apr 25 21:41:24 GMT 2024

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

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

Back to the top