diff --git a/CHANGELOG.md b/CHANGELOG.md index 793081650..4fd6ed33c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ # GEF Classic 3.22.0 +## Draw2D + - The refresh rate of the [Thumbnail](https://github.com/eclipse/gef-classic/blob/master/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java) and [DeferredUpdateManager](https://github.com/eclipse/gef-classic/blob/master/org.eclipse.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java) classes can be configured via the `setRefreshRate(int)` method. Events are then updated only once every given number of milliseconds, to reduce the CPU load when processing large amounts of update requests. + ## GEF - _Linux Only_ The overlay scrolling of the palette can be configured via the _PaletteViewerPreferences.PREFERENCE_SCROLLBARS_MODE_ preference. Supported values are _SWT.NONE_ and _SWT.SCROLLBAR_OVERLAY_. + - The refresh rate of the [TargetingTool](https://github.com/eclipse/gef-classic/blob/master/org.eclipse.gef/src/org/eclipse/gef/tools/TargetingTool.java) class can be configured via the `setRefreshRate(int)` method. Events are then updated only once every given number of milliseconds, to reduce the CPU load when processing large amounts of update requests. ## Zest - Integration of Zest 2.0 development branch. See the [wiki](https://github.com/eclipse/gef-classic/wiki/Zest#zest-2x) for more details. In case only default layout algorithms are used, the initial migration should be seamless. Otherwise the algorithms can be adapted to run in legacy mode by extending `AbstractLayoutAlgorithm.Zest1` or have to be re-implemented using the new API by extending `AbstractLayoutAlgorithm`. Note that this legacy mode will be removed in a future release. The following list contains the most significant, deprecated features: diff --git a/org.eclipse.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java b/org.eclipse.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java index 3575ef0ae..e0fdaf7bc 100644 --- a/org.eclipse.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java +++ b/org.eclipse.draw2d/src/org/eclipse/draw2d/DeferredUpdateManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2024 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 @@ -58,6 +58,7 @@ public void run() { private boolean updating; private boolean validating; private RunnableChain afterUpdate; + private int refreshRate = -1; private static class RunnableChain { RunnableChain next; @@ -263,7 +264,11 @@ protected void sendUpdateRequest() { if (display == null) { throw new SWTException(SWT.ERROR_THREAD_INVALID_ACCESS); } - display.asyncExec(new UpdateRequest()); + if (refreshRate <= 0) { + display.asyncExec(new UpdateRequest()); + } else { + display.timerExec(refreshRate, new UpdateRequest()); + } } /** @@ -348,6 +353,24 @@ public void setRoot(IFigure figure) { root = figure; } + /** + * Sets the rate with paint requests are executed. If set to either {@code 0} or + * a negative value, requests are executed as fast as possible (default + * behavior), otherwise every {@code refreshRate}ms. + * + * Example: + * + *
+	 * setRefreshRate(500); // Paints every 500ms
+	 * 
+ * + * @param refreshRate The rate with which paint requests are executed. + * @since 3.18 + */ + public void setRefreshRate(int refreshRate) { + this.refreshRate = refreshRate; + } + /** * Validates all invalid figures on the update queue and calls * {@link UpdateManager#fireValidating()} unless there are no invalid figures. diff --git a/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java b/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java index f60abc2dc..2014ddaff 100644 --- a/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java +++ b/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2024 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 @@ -283,7 +283,11 @@ public void start() { setScales(targetSize.width / (float) sourceSize.width, targetSize.height / (float) sourceSize.height); - Display.getCurrent().asyncExec(this); + if (refreshRate <= 0) { + Display.getCurrent().asyncExec(this); + } else { + Display.getCurrent().timerExec(refreshRate, this); + } } /** Create new GC, SWTGraphics, and ScaledGraphics instances */ @@ -379,6 +383,7 @@ public void stop() { private Dimension thumbnailImageSize; private final ThumbnailUpdater updater = new ThumbnailUpdater(); + private int refreshRate = -1; /** * Creates a new Thumbnail. The source Figure must be set separately if you use @@ -609,4 +614,21 @@ protected Dimension getTargetSize() { return targetSize; } + /** + * Sets the rate with which the thumbnail is updated. If set to either {@code 0} + * or a negative value, the update is done as fast as possible (default + * behavior), otherwise every {@code refreshRate}ms. + * + * Example: + * + *
+	 * setRefreshRate(500); // Update every 500ms
+	 * 
+ * + * @param refreshRate The rate with which the thumbnail is updated. + * @since 3.18 + */ + public void setRefreshRate(int refreshRate) { + this.refreshRate = refreshRate; + } } diff --git a/org.eclipse.gef/src/org/eclipse/gef/tools/TargetingTool.java b/org.eclipse.gef/src/org/eclipse/gef/tools/TargetingTool.java index 12d582b5f..2cc15507b 100644 --- a/org.eclipse.gef/src/org/eclipse/gef/tools/TargetingTool.java +++ b/org.eclipse.gef/src/org/eclipse/gef/tools/TargetingTool.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2024 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 @@ -59,6 +59,7 @@ public abstract class TargetingTool extends AbstractTool { private Request targetRequest; private EditPart targetEditPart; private AutoexposeHelper exposeHelper; + private int refreshRate = -1; /** * Creates the target request that will be used with the target editpart. This @@ -101,7 +102,11 @@ protected void doAutoexpose() { } if (exposeHelper.step(getLocation())) { handleAutoexpose(); - Display.getCurrent().asyncExec(new QueuedAutoexpose()); + if (refreshRate <= 0) { + Display.getCurrent().asyncExec(new QueuedAutoexpose()); + } else { + Display.getCurrent().timerExec(refreshRate, new QueuedAutoexpose()); + } } else { setAutoexposeHelper(null); } @@ -476,4 +481,21 @@ protected AutoexposeHelper getAutoexposeHelper() { return exposeHelper; } + /** + * Sets the rate with which the auto-expose helper is evaluated. If set to + * either {@code 0} or a negative value, the evaluation is done as fast as + * possible (default behavior), otherwise every {@code refreshRate}ms. + * + * Example: + * + *
+	 * setRefreshRate(500); // Validate every 500ms
+	 * 
+ * + * @param refreshRate The rate with which the auto-expose helper is validated. + * @since 3.20 + */ + public void setRefreshRate(int refreshRate) { + this.refreshRate = refreshRate; + } }