Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » menu/toolbar items based on open editor
menu/toolbar items based on open editor [message #326767] Tue, 01 April 2008 04:23 Go to next message
Jason Hocker is currently offline Jason HockerFriend
Messages: 43
Registered: July 2009
Member
I've tried using org.eclipse.ui.menus extension point, but struggling since
this is newer than any books I have.

First issue - I have a menu and toolbar buttons that I only want to be
displayed when certain editors are chosen. How would I control that?

Once those options conditionally appear, I want them disabled until focus is
on certain widgets. How would I control that?

My actions will change the data in the widget with focus. How do I get to
the widget to contol it?
Re: menu/toolbar items based on open editor [message #326798 is a reply to message #326767] Tue, 01 April 2008 14:14 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Jay Simpson wrote:
> First issue - I have a menu and toolbar buttons that I only want to be
> displayed when certain editors are chosen. How would I control that?

You want a visibleWhen element, similar in content to this example:
http://wiki.eclipse.org/Command_Core_Expressions#Active_edit or_type


>
> Once those options conditionally appear, I want them disabled until focus is
> on certain widgets. How would I control that?

You can declaratively work through the enabledWhen core expression
(although it seems to me you would have to use a property tester).

The other alternative is to activate you handler in your
createPartControl(*). That way it would have access to all of your
editors widgets and you could update your enabled State (and fire the
appropriate HandlerChangeEvent) to make it enabled/disabled.

>
> My actions will change the data in the widget with focus. How do I get to
> the widget to contol it?

With code? You created the widget, didn't you? What are you asking to
control what, exactly?

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: menu/toolbar items based on open editor [message #326810 is a reply to message #326798] Tue, 01 April 2008 15:20 Go to previous messageGo to next message
Jason Hocker is currently offline Jason HockerFriend
Messages: 43
Registered: July 2009
Member
One problem I had was I had the enabledWhen on the command and not the
handler...

Is there a way to know what page of a multi-page editor is active, and not
which editor is active? I want to make visible the toolbar only when a
certain page is selected, and that page might belong to several editors.

"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:fstfmd$fh2$1@build.eclipse.org...
> Jay Simpson wrote:
>> First issue - I have a menu and toolbar buttons that I only want to be
>> displayed when certain editors are chosen. How would I control that?
>
> You want a visibleWhen element, similar in content to this example:
> http://wiki.eclipse.org/Command_Core_Expressions#Active_edit or_type
>
>
>>
>> Once those options conditionally appear, I want them disabled until focus
>> is on certain widgets. How would I control that?
>
> You can declaratively work through the enabledWhen core expression
> (although it seems to me you would have to use a property tester).
>
> The other alternative is to activate you handler in your
> createPartControl(*). That way it would have access to all of your
> editors widgets and you could update your enabled State (and fire the
> appropriate HandlerChangeEvent) to make it enabled/disabled.
>
>>
>> My actions will change the data in the widget with focus. How do I get
>> to the widget to contol it?
>
> With code? You created the widget, didn't you? What are you asking to
> control what, exactly?
>
> 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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
>
Re: menu/toolbar items based on open editor [message #326828 is a reply to message #326810] Tue, 01 April 2008 18:16 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Jay Simpson wrote:
> One problem I had was I had the enabledWhen on the command and not the
> handler...
>
> Is there a way to know what page of a multi-page editor is active, and not
> which editor is active? I want to make visible the toolbar only when a
> certain page is selected, and that page might belong to several editors.

You could write your own property tester for activeEditor (IEditorPart)
.... if you find your multi-page editor part, you can check your information.

But you need to request the IEvaluationService update that property
tester property when your MPEP changes pages (re-evaluation available in
3.4M6)

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:executing org.eclipse.ant.core.antRunner with or without shell
Next Topic:Plugin.start(final BundleContext context) is not called from UI thread
Goto Forum:
  


Current Time: Tue Aug 20 22:21:53 GMT 2024

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

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

Back to the top