Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Add control to status bar
Add control to status bar [message #333931] Wed, 14 January 2009 11:03 Go to next message
David CHAUTARD is currently offline David CHAUTARDFriend
Messages: 102
Registered: July 2009
Senior Member
Hello,
I added a control in my status bar. And I would like to manage the display
of this control with preferencePage, as the "Heap status" in Preferences >
General. But my problem is to modify the visibility of my control when I
modify my preference, because I don't know how I link my extended
"WorkbenchWindowControlContribution" class and my preferencePage, in order
to refresh/reload the status bar.

Thanks.
David.
Re: Add control to status bar [message #333933 is a reply to message #333931] Wed, 14 January 2009 12:59 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Visibility of a menuContribution is controlled by its visibleWhen
contribution. If you were to create a property tester for your
preference you could listen for preference changes and re-evaluate it
with org.eclipse.ui.services.IEvaluationService.requestEvaluation (String)

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Add control to status bar [message #333941 is a reply to message #333933] Wed, 14 January 2009 14:56 Go to previous messageGo to next message
David CHAUTARD is currently offline David CHAUTARDFriend
Messages: 102
Registered: July 2009
Senior Member
I have added :
<control
class=control.ConnexionControl"
id="control.ConnexionControl">
<visibleWhen
checkEnabled="false">
<with
variable="displayState">
<equals
value="true">
</equals>
</with>
</visibleWhen>
</control>

to my control, and I call :
IEvaluationService service =
(IEvaluationService)PlatformUI.getWorkbench().getService(IEv aluationService.class);
service.requestEvaluation(displayState);
in the PreferencePage performOk() method., but it doesn't work.

What can be the problem?

Thx,
David.
Re: Add control to status bar [message #333974 is a reply to message #333941] Wed, 14 January 2009 20:01 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

David wrote:
> I have added :
> <control
> class=control.ConnexionControl"
> id="control.ConnexionControl">
> <visibleWhen
> checkEnabled="false">
> <with
> variable="displayState">
> <equals
> value="true">
> </equals>
> </with>
> </visibleWhen>
> </control>

Variables are provided by a subclass of AbstractSourceProvider ... if
you are going to use variables you would need to use the
org.eclipse.ui.services extension point to provide one

>
> to my control, and I call :
> IEvaluationService service =
> (IEvaluationService)PlatformUI.getWorkbench().getService(IEv aluationService.class);
> service.requestEvaluation(displayState);
> in the PreferencePage performOk() method., but it doesn't work.

1) you probably want to listen for changes to the preference to request
a re-evaluation not simply OK on the pref page.

2) you need to create a PropertyTester (see
http://wiki.eclipse.org/Command_Core_Expressions) to test your property.
requestEvaluation(*) is for properties, ISourceProviders are for
variables.

There should be an example of this in
org.eclipse.ui.examples.contributions, in CVS
:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: Add control to status bar [message #334153 is a reply to message #333974] Thu, 22 January 2009 09:13 Go to previous messageGo to next message
David CHAUTARD is currently offline David CHAUTARDFriend
Messages: 102
Registered: July 2009
Senior Member
Hello,
thanks for your help, but I have found an other solution which is :
ITrimManager trimManager =
((WorkbenchWindow)MyPlugin.getInstance().getWorkbench().getA ctiveWorkbenchWindow()).getTrimManager(); trimManager.getTrim("MyControl.toolbar" ).getControl().setVisible(plugin.getPreferenceStore().getBoo lean(STATE_ENABLED));
trimManager.forceLayout();

in my performOk() method of my preferencePage.

David.
Re: Add control to status bar [message #334163 is a reply to message #334153] Thu, 22 January 2009 19:05 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

David wrote:
> Hello,
> thanks for your help, but I have found an other solution which is :
> ITrimManager trimManager =
> ((WorkbenchWindow)MyPlugin.getInstance().getWorkbench().getA ctiveWorkbenchWindow()).getTrimManager();
> trimManager.getTrim("MyControl.toolbar" ).getControl().setVisible(plugin.getPreferenceStore().getBoo lean(STATE_ENABLED));
>
> trimManager.forceLayout();

that's all internal code, so if it changes at any time you'll run into
problems, especially between releases.

Other than that (and if something like a resize causes changes to be
re-evaluated) you have to be careful of the cost of forcing a trim
re-layout.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:JFACE wizard next button implementation
Next Topic:Adding jars from file system to runtime classpath
Goto Forum:
  


Current Time: Fri Sep 06 03:54:42 GMT 2024

Powered by FUDForum. Page generated in 0.05993 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top