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
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.wb.gef.graphical.handles.Handle;
import org.eclipse.wb.internal.gef.core.EditDomain;

import org.eclipse.draw2d.IFigure;
import org.eclipse.jface.viewers.ISelectionProvider;

import java.util.Collection;
Expand Down Expand Up @@ -136,7 +137,7 @@ public interface IEditPartViewer extends ISelectionProvider, org.eclipse.gef.Edi
*/
EditPart findTargetEditPart(int x,
int y,
final Collection<? extends org.eclipse.gef.EditPart> exclude,
final Collection<IFigure> exclude,
final Conditional conditional);

/**
Expand All @@ -145,7 +146,7 @@ EditPart findTargetEditPart(int x,
*/
EditPart findTargetEditPart(int x,
int y,
final Collection<? extends org.eclipse.gef.EditPart> exclude,
final Collection<IFigure> exclude,
final Conditional conditional,
String layer);
}
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 @@ -15,9 +15,11 @@
import org.eclipse.wb.gef.core.IEditPartViewer;
import org.eclipse.wb.gef.core.requests.ChangeBoundsRequest;
import org.eclipse.wb.gef.core.requests.DragPermissionRequest;
import org.eclipse.wb.gef.graphical.GraphicalEditPart;
import org.eclipse.wb.internal.gef.core.IObjectInfoEditPart;
import org.eclipse.wb.internal.gef.core.SharedCursors;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer.Conditional;
Expand Down Expand Up @@ -111,15 +113,20 @@ protected boolean handleDragInProgress() {
// Handling operations
//
////////////////////////////////////////////////////////////////////////////
private Collection<EditPart> m_exclusionSet;
private Collection<IFigure> m_exclusionSet;

/**
* Returns a list of all the edit parts in the {@link Tool#getOperationSet() operation set}.
*/
@Override
protected Collection<EditPart> getExclusionSet() {
protected Collection<IFigure> getExclusionSet() {
if (m_exclusionSet == null) {
m_exclusionSet = new ArrayList<>(getOperationSet());
List<? extends EditPart> set = getOperationSet();
m_exclusionSet = new ArrayList<>(set.size());
for (EditPart element : set) {
GraphicalEditPart editpart = (GraphicalEditPart) element;
m_exclusionSet.add(editpart.getFigure());
}
}
return m_exclusionSet;
}
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 @@ -14,6 +14,7 @@

import org.eclipse.wb.gef.core.IEditPartViewer;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer.Conditional;
import org.eclipse.gef.Request;
Expand Down Expand Up @@ -143,7 +144,7 @@ protected void unlockTargetEditPart() {
/**
* Returns a List of objects that should be excluded as potential targets for the operation.
*/
protected Collection<? extends EditPart> getExclusionSet() {
protected Collection<IFigure> getExclusionSet() {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.eclipse.wb.draw2d.Figure;
import org.eclipse.wb.draw2d.Layer;
import org.eclipse.wb.gef.core.EditPart;
import org.eclipse.wb.gef.graphical.GraphicalEditPart;
import org.eclipse.wb.internal.draw2d.FigureCanvas;
import org.eclipse.wb.internal.draw2d.IRootFigure;
import org.eclipse.wb.internal.draw2d.RootFigure;
Expand All @@ -24,6 +23,7 @@
import org.eclipse.wb.internal.gef.core.EditDomain;
import org.eclipse.wb.internal.gef.core.TargetEditPartFindVisitor;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.Handle;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -153,7 +153,7 @@ public void setCursor(Cursor cursor) {
@Override
public EditPart findTargetEditPart(int x,
int y,
final Collection<? extends org.eclipse.gef.EditPart> exclude,
final Collection<IFigure> exclude,
final Conditional conditional) {
EditPart editPart = findTargetEditPart(x, y, exclude, conditional, MENU_PRIMARY_LAYER);
if (editPart == null) {
Expand All @@ -169,15 +169,14 @@ public EditPart findTargetEditPart(int x,
@Override
public EditPart findTargetEditPart(int x,
int y,
final Collection<? extends org.eclipse.gef.EditPart> exclude,
final Collection<IFigure> exclude,
final Conditional conditional,
String layer) {
TargetEditPartFindVisitor visitor = new TargetEditPartFindVisitor(m_canvas, x, y, this) {
@Override
protected boolean acceptVisit(Figure figure) {
for (org.eclipse.gef.EditPart editPart : exclude) {
GraphicalEditPart graphicalPart = (GraphicalEditPart) editPart;
if (Objects.equals(figure, graphicalPart.getFigure())) {
for (IFigure exclusionFigure : exclude) {
if (Objects.equals(figure, exclusionFigure)) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.wb.internal.gef.core.AbstractEditPartViewer;
import org.eclipse.wb.internal.gef.core.EditDomain;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPart;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
Expand Down Expand Up @@ -221,7 +222,7 @@ public void setSelectionToTreeWidget() {
@Override
public org.eclipse.wb.gef.core.EditPart findTargetEditPart(int x,
int y,
Collection<? extends EditPart> exclude,
Collection<IFigure> exclude,
Conditional conditional) {
// simple check location
Rectangle clientArea = m_tree.getClientArea();
Expand All @@ -238,7 +239,7 @@ public org.eclipse.wb.gef.core.EditPart findTargetEditPart(int x,
}
// apply conditional
while (result != null) {
if (!exclude.contains(result) && (conditional == null || conditional.evaluate(result))) {
if (conditional == null || conditional.evaluate(result)) {
return result;
}
result = result.getParent();
Expand All @@ -249,7 +250,7 @@ public org.eclipse.wb.gef.core.EditPart findTargetEditPart(int x,
@Override
public org.eclipse.wb.gef.core.EditPart findTargetEditPart(int x,
int y,
Collection<? extends EditPart> exclude,
Collection<IFigure> exclude,
Conditional conditional,
String layer) {
return null;
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 Down Expand Up @@ -29,7 +29,11 @@
import org.eclipse.swt.dnd.Transfer;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* @author lobas_av
Expand Down Expand Up @@ -212,12 +216,13 @@ private void setTargetEditPart(EditPart target) {
*/
private void updateTargetEditPart() {
Point location = getDropLocation();
Collection<? extends EditPart> editParts = includeChildren(getDragSource());
EditPart editPart =
m_viewer.findTargetEditPart(
location.x,
location.y,
includeChildren(getDragSource()),
getTargetingConditional());
Collections.emptyList(),
getTargetingConditional(editParts));
if (editPart != null) {
editPart = editPart.getTargetEditPart(getTargetRequest());
}
Expand All @@ -241,12 +246,12 @@ private Point getDropLocation() {
* {@link EditPart#getTargetEditPart(Request)}. If <code>null</code> is returned, then the
* conditional fails, and the search continues.
*/
private Conditional getTargetingConditional() {
return editPart -> editPart.getTargetEditPart(getTargetRequest()) != null;
private Conditional getTargetingConditional(Collection<? extends EditPart> exclude) {
return editPart -> !exclude.contains(editPart) && editPart.getTargetEditPart(getTargetRequest()) != null;
}

private static List<? extends EditPart> includeChildren(List<? extends EditPart> parts) {
List<EditPart> result = new ArrayList<>();
private static Set<? extends EditPart> includeChildren(List<? extends EditPart> parts) {
Set<EditPart> result = new HashSet<>();
for (EditPart editPart : parts) {
result.add(editPart);
result.addAll(includeChildren(editPart.getChildren()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.wb.internal.gef.core.AbstractEditPartViewer;
import org.eclipse.wb.internal.gef.core.EditDomain;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.RootEditPart;
import org.eclipse.jface.action.MenuManager;
Expand Down Expand Up @@ -54,15 +55,15 @@ public void deselectAll() {
@Override
public org.eclipse.wb.gef.core.EditPart findTargetEditPart(int x,
int y,
Collection<? extends EditPart> exclude,
Collection<IFigure> exclude,
Conditional conditional) {
return null;
}

@Override
public org.eclipse.wb.gef.core.EditPart findTargetEditPart(int x,
int y,
Collection<? extends EditPart> exclude,
Collection<IFigure> exclude,
Conditional conditional,
String layer) {
return null;
Expand Down
Loading