Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365462 - Link#setEnabled(boolean) does not update color without a redraw()
Summary: Link#setEnabled(boolean) does not update color without a redraw()
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.8 M4   Edit
Assignee: Felipe Heidrich CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-02 12:36 EST by Markus Keller CLA
Modified: 2011-12-02 15:29 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-12-02 12:36:58 EST
master

Link#setEnabled(boolean) does not update the color of the text without a redraw() call from the client. The color of the link is correctly updated.


import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;

public class SnippetDisableLink {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		
		shell.setLayout(new GridLayout());
		
		final Link link = new Link(shell, SWT.NONE);
		link.setText("This a very simple <A>link widget</A>.");
		
		final Button button = new Button(shell, SWT.PUSH);
		button.setText("Enable/Disable");
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				boolean enable = !link.getEnabled();
				System.out.println("enabled: " + enable);
				link.setEnabled(enable);
			}
		});
		
		Button redraw = new Button(shell, SWT.PUSH);
		redraw.setText("Redraw");
		redraw.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				link.redraw();
			}
		});
		
		shell.pack ();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 1 Markus Keller CLA 2011-12-02 13:52:20 EST
In JDT, this can be seen on the Java Compiler properties page of a Java project: When you toggle 'Enable project specific settings', the link in the "Use compliance from ..." checkbox is not redrawn (unless you force it e.g. by resizing the dialog).
Comment 2 Felipe Heidrich CLA 2011-12-02 14:54:31 EST
Interesting (bug in win32 IMO), thanks for the snippet.

Fixed
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=64d29b632ce5e80bcbbf72b8860873b3b0700575
Comment 3 Markus Keller CLA 2011-12-02 15:29:15 EST
Thanks for the quick fix! I already considered releasing a workaround in a new piece of code, but I can omit that now.