Skip to content

Converting Support tray to use Image with constructor that utilizes imageGCDrawer instead of imageData #3013

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arunjose696
Copy link

@arunjose696 arunjose696 commented May 28, 2025

The SupportTray class previously used the Image(Device, ImageData) constructor to draw the close button on the ToolBar positioned alongside the support tray.

image

This PR modifies SupportTray to use the Image constructor that utilizes ImageGCDrawer instead of ImageData, since scaling ImageData is a destructive operation.

Triggering a supporttray is not so straight forward in runtime workspace. To test this implementation, the following example can be used. It simply opens a support tray with a toolbar and waits for it to be closed.

package org.eclipse.swt.snippets;


import java.util.*;

import org.eclipse.core.runtime.*;
import org.eclipse.jface.dialogs.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.internal.statushandlers.*;
import org.eclipse.ui.statushandlers.*;

public class SupportTrayExample {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);

		final TrayDialog[] td = new TrayDialog[1];
		try {
			td[0] = new TrayDialog(shell) {
				
			};

			Map<Object, Object> dialogState = new HashMap<>();
			dialogState.put(IStatusDialogConstants.CURRENT_STATUS_ADAPTER, new StatusAdapter(Status.OK_STATUS));

			SupportTray supportTray = new SupportTray(dialogState, event -> td[0].closeTray());

			td[0].setBlockOnOpen(false);
			td[0].open();
			td[0].openTray(supportTray);

			
			while (!shell.isDisposed()) {
				if (!display.readAndDispatch()) {
					display.sleep();
				}
			}
		} finally {
			display.dispose();
		}
	}
}

Note To run this example, you may need to temporarily add the following to the MANIFEST.MF file in the org.eclipse.swt.snippets project:

Require-Bundle: org.eclipse.swt,
 org.eclipse.core.runtime,
 org.eclipse.jface,
 org.eclipse.ui.workbench

Alternatively, you can fix the project setup by following the error prompts in the IDE for this example.

data.transparentPixel = 0;

normal = new Image(display, data);
normal.setBackground(transparent);
Copy link
Author

Choose a reason for hiding this comment

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

The setBackground call on the image has been omitted because it has no visible impact; the GC sets the image background to transparent.

Copy link
Contributor

github-actions bot commented May 28, 2025

Test Results

 2 778 files  ±0   2 778 suites  ±0   1h 39m 50s ⏱️ +31s
 7 925 tests ±0   7 697 ✅ +1  228 💤 ±0  0 ❌  - 1 
23 328 runs  +4  22 582 ✅ +5  746 💤 ±0  0 ❌  - 1 

Results for commit 8f317be. ± Comparison against base commit ef9a336.

♻️ This comment has been updated with latest results.

@fedejeanne fedejeanne force-pushed the bug/arun/199/SupportTray branch from dc8b9d4 to 9b3b3a6 Compare May 28, 2025 11:17
@fedejeanne fedejeanne marked this pull request as draft May 28, 2025 11:19
@fedejeanne
Copy link
Contributor

I drafted this PR because it contains a commit that shall not be merged. I use that commit to start the checks in our organization: vi-eclipse.

@arunjose696 once your PR is ready to be reviewed and merged, please rebase on origin/master (the official repository) and push. This will get rid of the extra commit.

@arunjose696 arunjose696 force-pushed the bug/arun/199/SupportTray branch from 9b3b3a6 to dc8b9d4 Compare May 28, 2025 11:54
@arunjose696
Copy link
Author

@arunjose696 once your PR is ready to be reviewed and merged, please rebase on origin/master (the official repository) and push. This will get rid of the extra commit.

Done

@arunjose696 arunjose696 marked this pull request as ready for review May 28, 2025 12:15
@fedejeanne
Copy link
Contributor

fedejeanne commented May 28, 2025

Workflows approved

@arunjose696 arunjose696 force-pushed the bug/arun/199/SupportTray branch from dc8b9d4 to d71bf53 Compare June 5, 2025 13:56
Copy link
Contributor

@amartya4256 amartya4256 left a comment

Choose a reason for hiding this comment

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

The code in itself looks good and I have also tested the behaviour and it seems to not change anything visually but it rather has a functional impact over SupportTray by using GcDrawer instead of ImageData to create the close button which provides a better scaling as compared to while using ImageData. I have a nit-picky suggestion to add on tops.

I think the commit title can be re-phrased: Use GcDrawer instead of ImageData for SupportTray images

This PR modifies SupportTray to use the Image constructor that utilizes
ImageGCDrawer  instead of ImageData, since scaling ImageData is a
destructive operation.
@arunjose696 arunjose696 force-pushed the bug/arun/199/SupportTray branch from d71bf53 to 8f317be Compare June 10, 2025 12:57
@arunjose696
Copy link
Author

I think the commit title can be re-phrased: Use GcDrawer instead of ImageData for SupportTray images

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Evaluate calling places of Image constructors with ImageData
3 participants