How do you enable/disable Menu Items on the Workbench Window [message #122165] |
Wed, 03 September 2003 11:15  |
Eclipse User |
|
|
|
Originally posted by: shyjee.us.ibm.com
I have a simple barebones Workbench window in which I added a "main" menu
and menu item by extending "actionSets" as show below. However, I would
like to get a handle on the menu item Action object so that I could
programatically enable and disable the Action.
I have seen explanations on how you can control the "enablement" of the
(actionSet) menu item through the "enablesFor" and "enablement" xml
elements of the plugin.xml. But these mechanisms only control the
enablement with relation to "selection" of something else. This is not
what I am looking for.
I would like to be able to enable or disable a menu item at will when, for
example, a button in a view is pressed or because of some other
application specific event not necessarily related to a "Selection event".
Is anyone aware of a way to do this?
... .
<extension
point="org.eclipse.ui.actionSets">
<actionSet
label="%actionset.label"
visible="true"
id="com.ibm.commerce.telesales.actionSet">
<menu
label="%menu.order"
id="telesales.order">
<separator
name="TeleSalesOrderGroup">
</separator>
<separator
name="TeleSalesOrderFindGroup">
</separator>
</menu>
<action
label="%menu.order.find"
icon="icons/search.gif"
tooltip="%menu.order.find.tooltip"
class="com.ibm.commerce.telesales.ui.actions.FindOrderAction "
menubarPath="telesales.order/TeleSalesOrderFindGroup"
id="com.ibm.commerce.telesales.ui.action.order.find">
</action>... .
Another related question is, when I use the following code to get a handle
on my menu item, item turns out to be null. It seems like the Active
Workbench Window is not aware of the menu or menu item that I added
through extension. Can someone please tell me what is the right approach
to get a handle.
IMenuManager mm =
TeleSalesUIPlugin.getPlugin().getWorkbench().getActiveWorkbe nchWindow().getActionBars().getMenuManager();
IContributionItem item =
mm.findUsingPath(" telesales.order/com.ibm.commerce.telesales.ui.action.order.f ind ");
System.out.println("item = " + item);
any help will be appreciated.
thanks
|
|
|
|
Re: How do you enable/disable Menu Items on the Workbench Window [message #122287 is a reply to message #122230] |
Wed, 03 September 2003 13:18   |
Eclipse User |
|
|
|
Originally posted by: shyjee.us.ibm.com
Thanks Simon, that helped.
So now my action handler class not only implements
IWorkbenchWindowActionDelegate but also IActionDelegate2 interface.
shyjee
Simon Arsenault wrote:
> Until your plugin is loaded, there is not other way but thru XML to define
> the enablement of the menu item. Once your plugin is loaded, your action
> delegate will be notified. If your action delegate implements
> IActionDelegate2, then its init method will be called. You can hold onto the
> IAction passed in and then set the enablement as you wish.
> Simon :-)
> "Shyjee Mathai" <shyjee@us.ibm.com> wrote in message
> news:bj50j1$nrv$1@eclipse.org...
> > I have a simple barebones Workbench window in which I added a "main" menu
> > and menu item by extending "actionSets" as show below. However, I would
> > like to get a handle on the menu item Action object so that I could
> > programatically enable and disable the Action.
> >
> > I have seen explanations on how you can control the "enablement" of the
> > (actionSet) menu item through the "enablesFor" and "enablement" xml
> > elements of the plugin.xml. But these mechanisms only control the
> > enablement with relation to "selection" of something else. This is not
> > what I am looking for.
> >
> > I would like to be able to enable or disable a menu item at will when, for
> > example, a button in a view is pressed or because of some other
> > application specific event not necessarily related to a "Selection event".
> > Is anyone aware of a way to do this?
> >
> > .. .
> > <extension
> > point="org.eclipse.ui.actionSets">
> > <actionSet
> > label="%actionset.label"
> > visible="true"
> > id="com.ibm.commerce.telesales.actionSet">
> > <menu
> > label="%menu.order"
> > id="telesales.order">
> > <separator
> > name="TeleSalesOrderGroup">
> > </separator>
> > <separator
> > name="TeleSalesOrderFindGroup">
> > </separator>
> > </menu>
> > <action
> > label="%menu.order.find"
> > icon="icons/search.gif"
> > tooltip="%menu.order.find.tooltip"
> >
> > class="com.ibm.commerce.telesales.ui.actions.FindOrderAction "
> > menubarPath="telesales.order/TeleSalesOrderFindGroup"
> > id="com.ibm.commerce.telesales.ui.action.order.find">
> > </action>... .
> >
> >
> >
> >
> >
> > Another related question is, when I use the following code to get a handle
> > on my menu item, item turns out to be null. It seems like the Active
> > Workbench Window is not aware of the menu or menu item that I added
> > through extension. Can someone please tell me what is the right approach
> > to get a handle.
> >
> > IMenuManager mm =
> >
> TeleSalesUIPlugin.getPlugin().getWorkbench().getActiveWorkbe nchWindow().getA
> ctionBars().getMenuManager();
> >
> > IContributionItem item =
> >
> mm.findUsingPath("telesales.order/com.ibm.commerce.telesales.ui.action.order
> ..find");
> >
> > System.out.println("item = " + item);
> >
> >
> > any help will be appreciated.
> > thanks
> >
|
|
|
Re: How do you enable/disable Menu Items on the Workbench Window [message #122297 is a reply to message #122287] |
Wed, 03 September 2003 13:48  |
Eclipse User |
|
|
|
Originally posted by: simon.ibm.oti.lab
yes
Simon :-)
"Shyjee" <shyjee@us.ibm.com> wrote in message
news:bj57p8$kb$1@eclipse.org...
> Thanks Simon, that helped.
>
> So now my action handler class not only implements
> IWorkbenchWindowActionDelegate but also IActionDelegate2 interface.
>
> shyjee
>
> Simon Arsenault wrote:
>
> > Until your plugin is loaded, there is not other way but thru XML to
define
> > the enablement of the menu item. Once your plugin is loaded, your action
> > delegate will be notified. If your action delegate implements
> > IActionDelegate2, then its init method will be called. You can hold onto
the
> > IAction passed in and then set the enablement as you wish.
>
> > Simon :-)
>
> > "Shyjee Mathai" <shyjee@us.ibm.com> wrote in message
> > news:bj50j1$nrv$1@eclipse.org...
> > > I have a simple barebones Workbench window in which I added a "main"
menu
> > > and menu item by extending "actionSets" as show below. However, I
would
> > > like to get a handle on the menu item Action object so that I could
> > > programatically enable and disable the Action.
> > >
> > > I have seen explanations on how you can control the "enablement" of
the
> > > (actionSet) menu item through the "enablesFor" and "enablement" xml
> > > elements of the plugin.xml. But these mechanisms only control the
> > > enablement with relation to "selection" of something else. This is not
> > > what I am looking for.
> > >
> > > I would like to be able to enable or disable a menu item at will when,
for
> > > example, a button in a view is pressed or because of some other
> > > application specific event not necessarily related to a "Selection
event".
> > > Is anyone aware of a way to do this?
> > >
> > > .. .
> > > <extension
> > > point="org.eclipse.ui.actionSets">
> > > <actionSet
> > > label="%actionset.label"
> > > visible="true"
> > > id="com.ibm.commerce.telesales.actionSet">
> > > <menu
> > > label="%menu.order"
> > > id="telesales.order">
> > > <separator
> > > name="TeleSalesOrderGroup">
> > > </separator>
> > > <separator
> > > name="TeleSalesOrderFindGroup">
> > > </separator>
> > > </menu>
> > > <action
> > > label="%menu.order.find"
> > > icon="icons/search.gif"
> > > tooltip="%menu.order.find.tooltip"
> > >
> > > class="com.ibm.commerce.telesales.ui.actions.FindOrderAction "
> > > menubarPath="telesales.order/TeleSalesOrderFindGroup"
> > > id="com.ibm.commerce.telesales.ui.action.order.find">
> > > </action>... .
> > >
> > >
> > >
> > >
> > >
> > > Another related question is, when I use the following code to get a
handle
> > > on my menu item, item turns out to be null. It seems like the Active
> > > Workbench Window is not aware of the menu or menu item that I added
> > > through extension. Can someone please tell me what is the right
approach
> > > to get a handle.
> > >
> > > IMenuManager mm =
> > >
> >
TeleSalesUIPlugin.getPlugin().getWorkbench().getActiveWorkbe nchWindow().getA
> > ctionBars().getMenuManager();
> > >
> > > IContributionItem item =
> > >
> >
mm.findUsingPath("telesales.order/com.ibm.commerce.telesales.ui.action.order
> > ..find");
> > >
> > > System.out.println("item = " + item);
> > >
> > >
> > > any help will be appreciated.
> > > thanks
> > >
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.07484 seconds