Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -68,7 +68,7 @@ protected List<Handle> createSelectionHandles() {

private Handle createResizeHandle(int direction) {
ResizeHandle handle = new ResizeHandle(getHost(), direction);
handle.setDragTrackerTool(new ResizeTracker(direction, REQ_RESIZE));
handle.setDragTracker(new ResizeTracker(direction, REQ_RESIZE));
return handle;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.eclipse.wb.gef.graphical.handles.Handle;
import org.eclipse.wb.internal.gef.core.EditDomain;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.jface.viewers.ISelectionProvider;

import java.util.Collection;
Expand Down Expand Up @@ -149,15 +148,4 @@ EditPart findTargetEditPart(int x,
final Collection<? extends org.eclipse.gef.EditPart> exclude,
final Conditional conditional,
String layer);

/**
* @return the <code>{@link Handle}</code> at the specified location.
*/
Handle findTargetHandle(Point location);

/**
* Returns the <code>{@link Handle}</code> at the specified location <code>(x, y)</code>. Returns
* <code>null</code> if no handle exists at the given location <code>(x, y)</code>.
*/
Handle findTargetHandle(int x, int y);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -19,6 +19,7 @@
import org.eclipse.draw2d.AncestorListener;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Locator;
import org.eclipse.draw2d.geometry.Point;

/**
* {@link Handle} will add an {@link IAncestorListener} to the owner's figure, and will
Expand All @@ -27,7 +28,7 @@
* @author lobas_av
* @coverage gef.graphical
*/
public abstract class Handle extends Figure implements AncestorListener {
public abstract class Handle extends Figure implements AncestorListener, org.eclipse.gef.Handle {
private final GraphicalEditPart m_owner;
private final Locator m_locator;

Expand Down Expand Up @@ -130,7 +131,8 @@ protected final Locator getLocator() {
* Returns the drag tracker {@link Tool} to use when the user clicks on this handle. If the drag
* tracker has not been set, it will be lazily created by calling {@link #createDragTracker()}.
*/
public Tool getDragTrackerTool() {
@Override
public Tool getDragTracker() {
if (m_dragTracker == null) {
m_dragTracker = createDragTrackerTool();
}
Expand All @@ -140,7 +142,7 @@ public Tool getDragTrackerTool() {
/**
* Sets the drag tracker {@link Tool} for this handle.
*/
public void setDragTrackerTool(Tool dragTracker) {
public void setDragTracker(Tool dragTracker) {
m_dragTracker = dragTracker;
}

Expand All @@ -150,4 +152,16 @@ public void setDragTrackerTool(Tool dragTracker) {
protected final Tool createDragTrackerTool() {
return null;
}

/**
* By default, the center of the handle is returned.
*
* @see org.eclipse.gef.Handle#getAccessibleLocation()
*/
@Override
public Point getAccessibleLocation() {
Point p = getBounds().getCenter();
translateToAbsolute(p);
return p;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -53,7 +53,7 @@ public MoveHandle(GraphicalEditPart owner, Locator locator) {
{
Tool tracker = new DragEditPartTracker(owner);
tracker.setDefaultCursor(getCursor());
setDragTrackerTool(tracker);
setDragTracker(tracker);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 Google, Inc. and others.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -18,6 +18,7 @@
import org.eclipse.wb.gef.core.tools.Tool;
import org.eclipse.wb.gef.graphical.handles.Handle;
import org.eclipse.wb.internal.gef.core.EditDomain;
import org.eclipse.wb.internal.gef.graphical.GraphicalViewer;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.DragTracker;
Expand Down Expand Up @@ -57,7 +58,7 @@ public class SelectionTool extends TargetingTool {
* <code>null</code>, this method will activate it and set the {@link EditDomain} and
* {@link IEditPartViewer}.
*/
public void setDragTrackerTool(DragTracker dragTracker) {
public void setDragTracker(DragTracker dragTracker) {
if (m_dragTracker != dragTracker) {
if (m_dragTracker != null) {
m_dragTracker.deactivate();
Expand Down Expand Up @@ -125,15 +126,17 @@ protected boolean handleButtonDown(int button) {
}
//
if ((m_stateMask & SWT.ALT) != 0) {
setDragTrackerTool(new MarqueeDragTracker());
setDragTracker(new MarqueeDragTracker());
return true;
}
//
Point current = getCurrentInput().getMouseLocation();
Handle handle = getCurrentViewer().findTargetHandle(current.x, current.y);
if (handle != null) {
setDragTrackerTool(handle.getDragTrackerTool());
return true;
if (getCurrentViewer() instanceof GraphicalViewer gv) {
Handle handle = (Handle) gv.findHandleAt(current);
if (handle != null) {
setDragTracker(handle.getDragTracker());
return true;
}
}
//
updateTargetRequest();
Expand All @@ -142,10 +145,10 @@ protected boolean handleButtonDown(int button) {
//
EditPart editPart = getTargetEditPart();
if (editPart == null) {
setDragTrackerTool(null);
setDragTracker(null);
getCurrentViewer().deselectAll();
} else {
setDragTrackerTool(editPart.getDragTracker(getTargetRequest()));
setDragTracker(editPart.getDragTracker(getTargetRequest()));
lockTargetEditPart(editPart);
}
}
Expand All @@ -155,7 +158,7 @@ protected boolean handleButtonDown(int button) {
@Override
protected boolean handleButtonUp(int button) {
((SelectionRequest) getTargetRequest()).setLastButtonPressed(0);
setDragTrackerTool(null);
setDragTracker(null);
m_state = STATE_INITIAL;
unlockTargetEditPart();
return true;
Expand All @@ -165,7 +168,7 @@ protected boolean handleButtonUp(int button) {
protected boolean handleMove() {
if (m_state == STATE_DRAG) {
m_state = STATE_INITIAL;
setDragTrackerTool(null);
setDragTracker(null);
}
if (m_state == STATE_INITIAL) {
updateTargetRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.eclipse.wb.draw2d.Layer;
import org.eclipse.wb.gef.core.EditPart;
import org.eclipse.wb.gef.graphical.GraphicalEditPart;
import org.eclipse.wb.gef.graphical.handles.Handle;
import org.eclipse.wb.internal.draw2d.FigureCanvas;
import org.eclipse.wb.internal.draw2d.IRootFigure;
import org.eclipse.wb.internal.draw2d.RootFigure;
Expand All @@ -26,6 +25,7 @@
import org.eclipse.wb.internal.gef.core.TargetEditPartFindVisitor;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.Handle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Composite;
Expand All @@ -37,7 +37,7 @@
* @author lobas_av
* @coverage gef.graphical
*/
public class GraphicalViewer extends AbstractEditPartViewer {
public class GraphicalViewer extends AbstractEditPartViewer implements org.eclipse.gef.GraphicalViewer {
protected final FigureCanvas m_canvas;
private final RootEditPart m_rootEditPart;
private EditEventManager m_eventManager;
Expand Down Expand Up @@ -194,31 +194,23 @@ protected boolean acceptResult(Figure figure) {
return visitor.getTargetEditPart();
}

/**
* @return the <code>{@link Handle}</code> at the specified location.
*/
@Override
public Handle findTargetHandle(Point location) {
return findTargetHandle(location.x, location.y);
}

/**
* Returns the <code>{@link Handle}</code> at the specified location <code>(x, y)</code>. Returns
* <code>null</code> if no handle exists at the given location <code>(x, y)</code>.
*/
@Override
public Handle findTargetHandle(int x, int y) {
public Handle findHandleAt(Point p) {
Handle target;
if ((target = findTargetHandle(MENU_HANDLE_LAYER_STATIC, x, y)) != null) {
if ((target = findTargetHandle(MENU_HANDLE_LAYER_STATIC, p)) != null) {
return target;
}
if ((target = findTargetHandle(MENU_HANDLE_LAYER, x, y)) != null) {
if ((target = findTargetHandle(MENU_HANDLE_LAYER, p)) != null) {
return target;
}
if ((target = findTargetHandle(HANDLE_LAYER_STATIC, x, y)) != null) {
if ((target = findTargetHandle(HANDLE_LAYER_STATIC, p)) != null) {
return target;
}
if ((target = findTargetHandle(HANDLE_LAYER, x, y)) != null) {
if ((target = findTargetHandle(HANDLE_LAYER, p)) != null) {
return target;
}
return null;
Expand All @@ -229,8 +221,8 @@ public Handle findTargetHandle(int x, int y) {
* location in given <code>layer</code>. Returns <code>null</code> if no handle exists at the
* given location <code>(x, y)</code>.
*/
private Handle findTargetHandle(String layer, int x, int y) {
TargetFigureFindVisitor visitor = new TargetFigureFindVisitor(m_canvas, x, y);
private Handle findTargetHandle(String layer, Point p) {
TargetFigureFindVisitor visitor = new TargetFigureFindVisitor(m_canvas, p.x, p.y);
((Layer) m_rootEditPart.getLayer(layer)).accept(visitor, false);
Figure targetFigure = visitor.getTargetFigure();
return targetFigure instanceof Handle ? (Handle) targetFigure : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
*******************************************************************************/
package org.eclipse.wb.internal.gef.tree;

import org.eclipse.wb.gef.graphical.handles.Handle;
import org.eclipse.wb.gef.tree.TreeEditPart;
import org.eclipse.wb.internal.core.utils.ui.UiUtils;
import org.eclipse.wb.internal.gef.core.AbstractEditPartViewer;
import org.eclipse.wb.internal.gef.core.EditDomain;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.EditPart;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
Expand Down Expand Up @@ -256,14 +254,4 @@ public org.eclipse.wb.gef.core.EditPart findTargetEditPart(int x,
String layer) {
return null;
}

@Override
public Handle findTargetHandle(Point location) {
return null;
}

@Override
public Handle findTargetHandle(int x, int y) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -75,7 +75,7 @@ protected List<Handle> createStaticHandles() {
// create resize column handle
SideResizeHandle resizeHandle =
new SideResizeHandle(getHost(), PositionConstants.RIGHT, 10, true);
resizeHandle.setDragTrackerTool(new ResizeTracker(getHost(),
resizeHandle.setDragTracker(new ResizeTracker(getHost(),
PositionConstants.EAST,
REQ_RESIZE));
handles.add(resizeHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ private class SizeHandle extends SquareHandle {
public SizeHandle(int direction, Locator locator) {
super(getHost(), locator);
setCursor(Cursors.getDirectionalCursor(direction));
setDragTrackerTool(new ResizeTracker(direction, REQ_RESIZE_SIZE));
setDragTracker(new ResizeTracker(direction, REQ_RESIZE_SIZE));
}

@Override
Expand Down Expand Up @@ -576,7 +576,7 @@ private class SpanHandle extends SquareHandle {
public SpanHandle(int direction, Locator locator) {
super(getHost(), locator);
setCursor(Cursors.getDirectionalCursor(direction));
setDragTrackerTool(new ResizeTracker(direction, REQ_RESIZE_SPAN));
setDragTracker(new ResizeTracker(direction, REQ_RESIZE_SPAN));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -53,7 +53,7 @@ protected List<Handle> createSelectionHandles() {
*/
private Handle createHandle(int direction) {
ResizeHandle handle = new ResizeHandle(getHost(), direction);
handle.setDragTrackerTool(new ResizeTracker(direction, null));
handle.setDragTracker(new ResizeTracker(direction, null));
return handle;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -66,7 +66,7 @@ protected List<Handle> createSelectionHandles() {
*/
private Handle createResizeHandle(int direction) {
ResizeHandle handle = new ResizeHandle(getHost(), direction);
handle.setDragTrackerTool(new ResizeTracker(direction, REQ_RESIZE) {
handle.setDragTracker(new ResizeTracker(direction, REQ_RESIZE) {
@Override
protected Command getCommand() {
return getLayoutEditPolicy().getResizeCommandImpl(getRequest());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected List<Handle> createSelectionHandles() {
*/
private Handle createResizeHandle(int direction) {
ResizeHandle handle = new ResizeHandle(getHost(), direction);
handle.setDragTrackerTool(new ResizeTracker(direction, REQ_RESIZE));
handle.setDragTracker(new ResizeTracker(direction, REQ_RESIZE));
return handle;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Google, Inc.
* Copyright (c) 2011, 2025 Google, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -79,7 +79,7 @@ protected List<Handle> createSelectionHandles() {
*/
private Handle createHandle(int direction) {
ResizeHandle handle = new ResizeHandle(getHost(), direction);
handle.setDragTrackerTool(new ResizeTracker(direction, REQ_RESIZE));
handle.setDragTracker(new ResizeTracker(direction, REQ_RESIZE));
return handle;
}

Expand Down
Loading
Loading