Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make refresh rate of DeferredUpdateManager & TargetingTool configurable #550

Merged
merged 1 commit into from
Oct 22, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}

/**
Expand Down Expand Up @@ -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:
*
* <pre>
* setRefreshRate(500); // Paints every 500ms
* </pre>
*
* @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.
Expand Down
26 changes: 24 additions & 2 deletions org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
*
* <pre>
* setRefreshRate(500); // Update every 500ms
* </pre>
*
* @param refreshRate The rate with which the thumbnail is updated.
* @since 3.18
*/
public void setRefreshRate(int refreshRate) {
this.refreshRate = refreshRate;
}
}
26 changes: 24 additions & 2 deletions org.eclipse.gef/src/org/eclipse/gef/tools/TargetingTool.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, 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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:
*
* <pre>
* setRefreshRate(500); // Validate every 500ms
* </pre>
*
* @param refreshRate The rate with which the auto-expose helper is validated.
* @since 3.20
*/
public void setRefreshRate(int refreshRate) {
this.refreshRate = refreshRate;
}
}
Loading