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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

## Draw2D

- The `getTextUtilities()` method has been moved from the `Label` and `TextFlow` class to the `IFigure` interface. By
default, this method returns a `DrawableFigureCanvas` rather than `TextUtilities.INSTANCE`, which is an object created
for the `FigureCanvas` containing the given figure.

## GEF

## Zest
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.draw2d/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.draw2d;singleton:=true
Bundle-Version: 3.20.200.qualifier
Bundle-Version: 3.21.0.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.draw2d,
Expand Down
11 changes: 11 additions & 0 deletions org.eclipse.draw2d/src/org/eclipse/draw2d/Figure.java
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,17 @@ public final Dimension getSize() {
return getBounds().getSize();
}

/**
* @see IFigure#getTextUtilities()
*/
@Override
public TextUtilities getTextUtilities() {
if (getParent() != null) {
return getParent().getTextUtilities();
}
return TextUtilities.INSTANCE;
}

/**
* @see IFigure#getToolTip()
*/
Expand Down
9 changes: 9 additions & 0 deletions org.eclipse.draw2d/src/org/eclipse/draw2d/IFigure.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,15 @@ default Point getLocation() {
*/
Dimension getSize();

/**
* Gets the {@link TextUtilities} instance to be used in measurement
* calculations.
*
* @return a {@link TextUtilities} instance
* @since 3.21
*/
TextUtilities getTextUtilities();

/**
* Returns a IFigure that is the tooltip for this IFigure.
*
Expand Down
14 changes: 1 addition & 13 deletions org.eclipse.draw2d/src/org/eclipse/draw2d/Label.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2010 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation 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 @@ -682,18 +682,6 @@ public void setTextPlacement(int where) {
repaint();
}

/**
* Gets the <code>TextUtilities</code> instance to be used in measurement
* calculations.
*
* @return a <code>TextUtilities</code> instance
* @since 3.4
*/
@SuppressWarnings("static-method")
public TextUtilities getTextUtilities() {
return TextUtilities.INSTANCE;
}

/**
* Gets the string that will be appended to the text when the label is
* truncated. By default, this returns an ellipsis.
Expand Down
14 changes: 13 additions & 1 deletion org.eclipse.draw2d/src/org/eclipse/draw2d/LightweightSystem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2024 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation 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 @@ -39,6 +39,7 @@
import org.eclipse.swt.widgets.Listener;

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.draw2d.internal.DrawableTextUtilities;

/**
* The LightweightSystem is the link between SWT and Draw2d. It is the component
Expand All @@ -61,6 +62,7 @@ public class LightweightSystem {
private EventDispatcher dispatcher;
private UpdateManager manager = new DeferredUpdateManager();
private int ignoreResize;
private TextUtilities textUtilities;

/**
* Constructs a LightweightSystem on Canvas <i>c</i>.
Expand Down Expand Up @@ -228,6 +230,7 @@ public void setControl(Canvas c) {
return;
}
canvas = c;
textUtilities = new DrawableTextUtilities(canvas);
if ((c.getStyle() & SWT.DOUBLE_BUFFERED) != 0) {
getUpdateManager().setGraphicsSource(new NativeGraphicsSource(canvas));
} else {
Expand Down Expand Up @@ -326,6 +329,15 @@ public Color getForegroundColor() {
return null;
}

/** @see IFigure#getTextUtilities() */
@Override
public TextUtilities getTextUtilities() {
if (textUtilities != null) {
return textUtilities;
}
return TextUtilities.INSTANCE;
}

/** @see IFigure#getUpdateManager() */
@Override
public UpdateManager getUpdateManager() {
Expand Down
15 changes: 1 addition & 14 deletions org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextFlow.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2010 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation 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 @@ -20,7 +20,6 @@

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.TextUtilities;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
Expand Down Expand Up @@ -726,16 +725,4 @@ protected FlowUtilities getFlowUtilities() {
return FlowUtilities.INSTANCE;
}

/**
* Gets the <code>TextUtilities</code> instance to be used in measurement
* calculations.
*
* @return a <code>TextUtilities</code> instance
* @since 3.4
*/
@SuppressWarnings("static-method")
protected TextUtilities getTextUtilities() {
return TextUtilities.INSTANCE;
}

}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weirdly enough, increasing the visibility doesn't break binary compatibility, but may cause source-incompatibilities if overridden by subclasses.

https://github.com/eclipse-platform/eclipse.platform/blob/master/docs/Evolving-Java-based-APIs-2.md#evolving-api-classes---api-methods-and-constructors

Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.TextUtilities;
import org.eclipse.draw2d.Triangle;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.internal.DrawableTextUtilities;

import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.dnd.TemplateTransfer;
Expand Down Expand Up @@ -1116,7 +1114,6 @@ protected void updateState() {
private class TitleLabel extends Label {
protected static final Border BORDER = new MarginBorder(4, 3, 4, 3);
protected static final Border TOOL_TIP_BORDER = new MarginBorder(0, 2, 0, 2);
private TextUtilities textUtilities;

public TitleLabel(boolean isHorizontal) {
super(GEFMessages.Palette_Label, InternalImages.get(InternalImages.IMG_PALETTE));
Expand All @@ -1128,14 +1125,6 @@ public TitleLabel(boolean isHorizontal) {
setForegroundColor(ColorConstants.listForeground);
}

@Override
public TextUtilities getTextUtilities() {
if (textUtilities == null) {
textUtilities = new DrawableTextUtilities(paletteContainer);
}
return textUtilities;
}

@Override
public IFigure getToolTip() {
if (isTextTruncated()) {
Expand Down
Loading