Skip to content
Open
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 @@ -40,7 +40,6 @@
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.requests.SelectionRequest;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Control;

Expand Down Expand Up @@ -166,10 +165,8 @@ protected void refreshEditPolicies() {
@Override
public EditPart getTargetEditPart(Request request) {
// sometimes we want to redirect selection to parent
if (request instanceof SelectionRequest) {
if (JavaInfoUtils.hasTrueParameter(m_component, "GEF.clickToParent")) {
return getParent().getTargetEditPart(request);
}
if (REQ_SELECTION.equals(request.getType()) && JavaInfoUtils.hasTrueParameter(m_component, "GEF.clickToParent")) {
return getParent().getTargetEditPart(request);
}
return super.getTargetEditPart(request);
}
Expand Down
20 changes: 0 additions & 20 deletions org.eclipse.wb.core/src-gef/org/eclipse/wb/gef/core/EditPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,26 +223,6 @@ private List<EditPolicy> getUnderstandingPolicies(Request request) {
//
////////////////////////////////////////////////////////////////////////////

/**
* Return the <code>{@link EditPart}</code> that should be used as the <i>target</i> for the
* specified <code>{@link Request}</code>. Tools will generally call this method with the mouse
* location so that the receiver can implement drop targeting. Typically, if this {@link EditPart}
* is not the requested target (for example, this EditPart is not a composite), it will forward
* the call to its parent.
*/
public org.eclipse.gef.EditPart getTargetEditPart(Request request) {
org.eclipse.gef.EditPart target = null;
// update target using any understanding EditPolicy
for (EditPolicy editPolicy : getUnderstandingPolicies(request)) {
org.eclipse.gef.EditPart newTarget = editPolicy.getTargetEditPart(request);
if (newTarget != null) {
target = newTarget;
}
}
// OK, we (probably) have target
return target;
}

/**
* Performs the specified Request. This method can be used to send a generic message to an
* EditPart. Subclasses should extend this method to handle Requests. For now, the default
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, 2026 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 @@ -111,11 +111,11 @@ public boolean understandsRequest(Request request) {
}

@Override
public org.eclipse.wb.gef.core.EditPart getTargetEditPart(Request request) {
public EditPart getTargetEditPart(Request request) {
for (SelectionEditPolicy policy : m_policies) {
EditPart targetEditPart = policy.getTargetEditPart(request);
if (targetEditPart != null) {
return (org.eclipse.wb.gef.core.EditPart) targetEditPart;
return targetEditPart;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ public boolean understandsRequest(Request request) {
* {@link Request#REQ_PASTE}, {@link Request#REQ_MOVE} or {@link Request#REQ_ADD}.
*/
@Override
public org.eclipse.wb.gef.core.EditPart getTargetEditPart(Request request) {
return isRequestCondition(request) ? getHost() : null;
public EditPart getTargetEditPart(Request request) {
if (!understandsRequest(request)) {
return null;
}
return getHost();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ public boolean understandsRequest(Request request) {

@Override
public EditPart getTargetEditPart(Request request) {
// Also support non-selection requests (e.g. resize)
// TODO ptziegler - move this check to sub-classes
if (!understandsRequest(request)) {
return null;
}
return getHost();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,22 @@ public boolean understandsRequest(Request request) {
* {@link Request#REQ_PASTE}, {@link Request#REQ_MOVE} or {@link Request#REQ_ADD}.
*/
@Override
public org.eclipse.wb.gef.core.EditPart getTargetEditPart(Request request) {
if (isRequestCondition(request)) {
// if target item is host, then check for before/after locations
{
DropRequest dropRequest = (DropRequest) request;
Point location = dropRequest.getLocation();
TreeItem targetItem = getTree().getItem(location.getSWTPoint());
if (targetItem == getHostWidget()
&& (isBeforeLocation(targetItem, location) || isAfterLocation(targetItem, location))) {
return null;
}
public EditPart getTargetEditPart(Request request) {
if (!understandsRequest(request)) {
return null;
}
// if target item is host, then check for before/after locations
{
DropRequest dropRequest = (DropRequest) request;
Point location = dropRequest.getLocation();
TreeItem targetItem = getTree().getItem(location.getSWTPoint());
if (targetItem == getHostWidget()
&& (isBeforeLocation(targetItem, location) || isAfterLocation(targetItem, location))) {
return null;
}
// OK drop on host
return getHost();
}
return null;
// OK drop on host
return getHost();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public boolean understandsRequest(Request request) {

@Override
public EditPart getTargetEditPart(Request request) {
if (!understandsRequest(request)) {
return null;
}
// prepare host widget
final TreeEditPart host = (TreeEditPart) getHost();
final TreeItem hostWidget = host.getWidget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public boolean understandsRequest(Request request) {

@Override
public EditPart getTargetEditPart(Request request) {
return getHost();
if (REQ_SELECTION.equals(request.getType())) {
return getHost();
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void deleting(Object toolkitModel) {
//
////////////////////////////////////////////////////////////////////////////
@Override
public EditPart getTargetEditPart(org.eclipse.gef.Request request) {
public EditPart getTargetEditPart(Request request) {
request = processRequestProcessors(request);
EditPart target = super.getTargetEditPart(request);
boolean isOperationRequest =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 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 @@ -80,9 +80,9 @@ public void eraseTargetFeedback(Request request) {
//
////////////////////////////////////////////////////////////////////////////
@Override
public org.eclipse.wb.gef.core.EditPart getTargetEditPart(Request request) {
public EditPart getTargetEditPart(Request request) {
// check that we understand this request
if (!isRequestCondition(request)) {
if (!understandsRequest(request)) {
return null;
}
// "popup" always shows sub-menu
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 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 @@ -42,7 +42,7 @@ public ComponentEditPart(ComponentInfo component) {
////////////////////////////////////////////////////////////////////////////
@Override
public EditPart getTargetEditPart(Request request) {
if (TabOrderContainerEditPolicy.TAB_ORDER_REQUEST == request) {
if (TabOrderContainerEditPolicy.TAB_ORDER_REQUEST.getType().equals(request)) {
return this;
}
return super.getTargetEditPart(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -148,7 +147,7 @@ public void showNextComponent() {
////////////////////////////////////////////////////////////////////////////
@Override
public EditPart getTargetEditPart(Request request) {
if (RequestConstants.REQ_SELECTION.equals(request.getType())) {
if (REQ_SELECTION.equals(request.getType())) {
ComponentInfo component = m_layout.getCurrentComponent();
return getHost().getViewer().getEditPartRegistry().get(component);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 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 @@ -43,7 +43,7 @@ public ControlEditPart(ControlInfo control) {
////////////////////////////////////////////////////////////////////////////
@Override
public EditPart getTargetEditPart(Request request) {
if (TabOrderContainerEditPolicy.TAB_ORDER_REQUEST == request) {
if (TabOrderContainerEditPolicy.TAB_ORDER_REQUEST.getType().equals(request.getType())) {
return this;
}
return super.getTargetEditPart(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ public void eraseTargetFeedback(Request request) {
RequestsLogger expectedLogger = new RequestsLogger();
expectedLogger.log(testEditPart, new String[]{
"getCommand",
"understandsRequest",
"getTargetEditPart"}, request);
actualLogger.assertEquals(expectedLogger);
actualLogger.clear();
Expand All @@ -348,8 +347,6 @@ public void eraseTargetFeedback(Request request) {
//
"getCommand",
//
"understandsRequest",
//
"getTargetEditPart",
//
"understandsRequest",
Expand Down
Loading