tags:

views:

159

answers:

2

Hi

I disable org.eclipse.ui.forms.widgets.Hyperlink control just calling hyperLink.setEnabled(false). However after that the link doesn't looks like disabled control. The link is not grayed out (but I can't click it of course).

The question is: why the link is not grayed out and what should I do to gray out disabled links?

Thanks

A: 

did you try setting gray foreground explicitly ?

you can use following helper method:

public static void setEnabled(Link link, boolean enable){
    if(link.isEnabled()!=enable){
        if(enable)
          link.setForeground(null); // resets to system's default color
        else
          link.setForeground(link.getDisplay().getSystemColor(SWT.COLOR_GRAY));
        link.setEnabled(enable);
    }
}
Santhosh Kumar T
just tried. this works. but now I need to set color back, and how can I obtain the default color for hyperlinks? :) I don't want to ask control to return it's foregraound color and store it - it would be to complicated solution for such a thing that we supposed to have for free.Probably I can say Eclipse somehow to use "gray" as foreground for disabled hyperlinks?
javapowered
this looks good, but doesn't work for me. In my eclipse the default color for enabled links is "dark blue", and "light blue" when you hover over. But if I set foreground to "null" then links become black and "light blue" when you hover over.
javapowered
A: 

Just extend Hyperlink and set the default colors. Alternatively you could create a composite delegate and forward the interface if it isn't too big - that's probably preferable.

arcticpenguin