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 @@ -34,7 +34,6 @@
import org.eclipse.gef.EditDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
Expand Down Expand Up @@ -204,10 +203,10 @@ private void setActiveEditorBounds() {
org.eclipse.swt.graphics.Rectangle bounds;
{
PropertyEditPart editPart = getEditPartForModel(m_activePropertyInfo);
Rectangle figureBounds = getAbsoluteBounds(editPart);
int x = getSplitter() + 1;
Rectangle figureBounds = getEditorBounds(editPart);
int x = figureBounds.left();
int y = figureBounds.top();
int width = getControl().getClientArea().width - x - MARGIN_RIGHT;
int width = figureBounds.width() - MARGIN_RIGHT;
int height = figureBounds.height() - MARGIN_BOTTOM;
bounds = new org.eclipse.swt.graphics.Rectangle(x, y, width, height);
}
Expand Down Expand Up @@ -246,11 +245,11 @@ public void handleException(Throwable e) {
////////////////////////////////////////////////////////////////////////////

/**
* @return the bounds of the given edit part relative to the top right corner of
* the viewport.
* @return the bounds of editor for the given edit part, relative to the top
* right corner of the viewport.
*/
private static Rectangle getAbsoluteBounds(GraphicalEditPart editPart) {
IFigure figure = editPart.getFigure();
private static Rectangle getEditorBounds(PropertyEditPart editPart) {
IFigure figure = editPart.getFigure().getChildren().get(1);
Rectangle bounds = figure.getBounds().getCopy();
figure.translateToAbsolute(bounds);
return bounds;
Expand Down Expand Up @@ -280,25 +279,6 @@ private boolean isLocationSplitter(int x) {
return Math.abs(getSplitter() - x) < 2;
}

/**
* @return <code>true</code> if given <code>x</code> is on value part of
* property.
*/
private boolean isLocationValue(int x) {
return x > getSplitter() + 2;
}

/**
* @param x the {@link PropertyTable} relative coordinate.
* @param y the {@link PropertyTable} relative coordinate.
*
* @return the location relative to the value part of property.
*/
private Point getValueRelativeLocation(int x, int y) {
GraphicalEditPart editPart = (GraphicalEditPart) findObjectAt(new Point(x, y));
return new Point(x - (getSplitter() + 2), getAbsoluteBounds(editPart).top());
}

/**
* The height for a row, based on the font height of the parent composite.
*/
Expand Down Expand Up @@ -532,19 +512,7 @@ public class PropertyEditDomain extends EditDomain {
@Override
public void mouseDown(MouseEvent event, EditPartViewer viewer) {
m_splitterResizing = event.button == 1 && m_properties != null && isLocationSplitter(event.x);
// click in property
if (!m_splitterResizing && findObjectAt(new Point(event.x, event.y)) instanceof PropertyEditPart editPart) {
// prepare property
select(editPart);
Property property = m_activePropertyInfo.getProperty();
// de-activate current editor
deactivateEditor(true);
getControl().redraw();
// activate editor
if (isLocationValue(event.x)) {
activateEditor(property, getValueRelativeLocation(event.x, event.y));
}
}
super.mouseDown(event, viewer);
}

@Override
Expand Down Expand Up @@ -573,6 +541,7 @@ public void mouseUp(MouseEvent event, EditPartViewer viewer) {
}
}
}
super.mouseUp(event, viewer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Patrick Ziegler and others.
* Copyright (c) 2025, 2026 Patrick Ziegler 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 @@ -17,6 +17,8 @@
import org.eclipse.wb.internal.core.utils.ui.DrawUtils;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.Request;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
Expand Down Expand Up @@ -72,4 +74,9 @@ protected void createEditPolicies() {
public PropertyTable getViewer() {
return (PropertyTable) super.getViewer();
}

@Override
public DragTracker getDragTracker(Request request) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2025 Patrick Ziegler and others.
* Copyright (c) 2025, 2026 Patrick Ziegler 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 @@ -37,7 +37,11 @@
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.requests.SelectionRequest;
import org.eclipse.jface.resource.FontDescriptor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -154,6 +158,30 @@ public PropertyInfo getModel() {
return (PropertyInfo) super.getModel();
}

@Override
public DragTracker getDragTracker(Request request) {
return new PropertyEditPartTracker(this);
}

@Override
public void performRequest(Request request) {
if (RequestConstants.REQ_SELECTION == request.getType()) {
performSelection((SelectionRequest) request);
}
}

private void performSelection(SelectionRequest request) {
// de-activate current editor
getViewer().deactivateEditor(true);
getViewer().getControl().redraw();
// activate editor
Point mouseLocation = request.getLocation().getCopy();
getFigure().translateToRelative(mouseLocation);
if (valueFigure.containsPoint(mouseLocation)) {
getViewer().activateEditor(getProperty(), mouseLocation);
}
}

@Override
protected IFigure createFigure() {
SeparatorBorder border = new SeparatorBorder(new Insets(0, 0, MARGIN_BOTTOM, 1), PositionConstants.BOTTOM);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*******************************************************************************
* Copyright (c) 2026 Patrick Ziegler 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
* https://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Patrick Ziegler - initial API and implementation
*******************************************************************************/
package org.eclipse.wb.internal.core.model.property.table.editparts;

import org.eclipse.wb.internal.core.model.property.table.PropertyTable;

import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.SelectionRequest;
import org.eclipse.gef.tools.TargetingTool;

/**
* DragTracker used to select, edit, and open {@link PropertyEditPart}s.
*/
public class PropertyEditPartTracker extends TargetingTool implements DragTracker {
private EditPart owner;

/**
* Constructs a new {@link PropertyEditPartTracker} with the given edit part as
* the source.
*
* @param owner the source edit part
*/
public PropertyEditPartTracker(EditPart owner) {
this.owner = owner;
}

/**
* Returns {@code true} if cursor is on splitter.
*/
private boolean isLocationSplitter() {
if (getCurrentViewer() instanceof PropertyTable propertyTable) {
return Math.abs(propertyTable.getSplitter() - getLocation().x) < 2;
}
return false;
}

@Override
protected boolean handleButtonDown(int button) {
if (isLocationSplitter() || button != 1) {
return false;
}

getCurrentViewer().select(owner);

SelectionRequest request = new SelectionRequest();
request.setType(REQ_SELECTION);
request.setLocation(getLocation());
owner.performRequest(request);

return true;
}

@Override
protected String getCommandName() {
return "Property Tracker";//$NON-NLS-1$
}
}
Loading