Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » SetInitiallyVisible(boolean) for ActionSet not working
SetInitiallyVisible(boolean) for ActionSet not working [message #326546] Mon, 24 March 2008 15:36 Go to next message
Rahul Kamdar is currently offline Rahul KamdarFriend
Messages: 63
Registered: July 2009
Member
Hi,

I have added an action using actionSets. I believe for it to get constructed
I need to set its visibility as true in plugin.xml

However, I don't want this action to be visible or available until a certain
type of file is selected in workspace. (I tried objectClass filters too)..

So in order to make its visibility false when Eclipse with my plug-in loads,
I accessed the constructor method for this action and there tried to set the
setInitiallyVisible(false) for the actionSet under which this action falls
(WorkbenchPlugin.getDefault().getActionSetRegistry().findAct ionSet(id).setInitiallyVisible(false))
I also did the IWorkbenchWindow.getActivePage().hideActionSet(id).

But neither seems to work, since the action still comes up as an item in the
File Menu.

Am I doing something wrong here or do I need to do something else?

Thanks,
Rahul
Re: SetInitiallyVisible(boolean) for ActionSet not working [message #326569 is a reply to message #326546] Tue, 25 March 2008 13:06 Go to previous messageGo to next message
Rahul Kamdar is currently offline Rahul KamdarFriend
Messages: 63
Registered: July 2009
Member
I have also tried out using actionSetPartAssociation and made my actionSet
the targetID against views that are available in case my files are being
edited. However, I still face the same issue.

Could someone assist me with what I am doing wrong here?

Thanks,
Rahul

"Rahul Kamdar" <rtkamdar@kamdars-india.com> wrote in message
news:fs8hps$vfp$1@build.eclipse.org...
> Hi,
>
> I have added an action using actionSets. I believe for it to get
> constructed I need to set its visibility as true in plugin.xml
>
> However, I don't want this action to be visible or available until a
> certain type of file is selected in workspace. (I tried objectClass
> filters too)..
>
> So in order to make its visibility false when Eclipse with my plug-in
> loads, I accessed the constructor method for this action and there tried
> to set the setInitiallyVisible(false) for the actionSet under which this
> action falls
> (WorkbenchPlugin.getDefault().getActionSetRegistry().findAct ionSet(id).setInitiallyVisible(false))
> I also did the IWorkbenchWindow.getActivePage().hideActionSet(id).
>
> But neither seems to work, since the action still comes up as an item in
> the File Menu.
>
> Am I doing something wrong here or do I need to do something else?
>
> Thanks,
> Rahul
>
Re: SetInitiallyVisible(boolean) for ActionSet not working [message #326618 is a reply to message #326546] Wed, 26 March 2008 14:57 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Rahul Kamdar wrote:
> Hi,
>
> I have added an action using actionSets. I believe for it to get constructed
> I need to set its visibility as true in plugin.xml
>
> However, I don't want this action to be visible or available until a certain
> type of file is selected in workspace. (I tried objectClass filters too)..

You can use selection or enablement to enable/disable the actions, or an
actionSetPartAssociation to make them appear/disappear when a given view
is active. You would only set the actionSet itself to visible true if
you always want it visible in every perspective.

If one of the above is not working for you, please post the XML and
describe how it is not working.

Hacking the internal code is not likely to work.

--
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: SetInitiallyVisible(boolean) for ActionSet not working [message #326651 is a reply to message #326618] Thu, 27 March 2008 13:23 Go to previous messageGo to next message
Rahul Kamdar is currently offline Rahul KamdarFriend
Messages: 63
Registered: July 2009
Member
Hi Paul,

Thanks for your help again! I was just about to drop in here to post that
its working now. I used perspectiveExtensions extension point and tied the
views and actionSet to my perspective. For some reason in case of
ationSetPartAssociation, I felt it was not working since my action set
became visible only when one of the associated views "was in focus" and not
just activated and visible. In case of perspectiveExtensions I do not need
to wait for the "in focus" aspect and the actionSet is visible exactly when
I want!! :-) So its moving on track as of now!

Thanks a lot Paul! However, there is one more issue related to the
enablement/disablement of actionSet. The actionSet that I have defined
defines an action similar to "Save" and I want this action to be initially
disabled (I managed to do that by action.setDisabled(true) in the
selectionChanged method of the action which is called after constructor).
And when certain conditions are true, I want to enable this "save" like
button. As of now I am doing it by accessing the action via
ActiveWorkbenchWindow >> CoolbarManager >> myActionSetContribution
(ToolBarContributionItem) >> ToolbarManager >> ActionContribution >>
getAction >> setEnabled (true);

This is pretty much a hack through the internal code and doesn't look neat.
Could you suggest me something better or a cleaner simpler way to do things?

Thanks,
Rahul

"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:fsdnvd$n9u$1@build.eclipse.org...
> Rahul Kamdar wrote:
>> Hi,
>>
>> I have added an action using actionSets. I believe for it to get
>> constructed I need to set its visibility as true in plugin.xml
>>
>> However, I don't want this action to be visible or available until a
>> certain type of file is selected in workspace. (I tried objectClass
>> filters too)..
>
> You can use selection or enablement to enable/disable the actions, or an
> actionSetPartAssociation to make them appear/disappear when a given view
> is active. You would only set the actionSet itself to visible true if you
> always want it visible in every perspective.
>
> If one of the above is not working for you, please post the XML and
> describe how it is not working.
>
> Hacking the internal code is not likely to work.
>
> --
> 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: SetInitiallyVisible(boolean) for ActionSet not working [message #326683 is a reply to message #326651] Fri, 28 March 2008 13:20 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

ActionSet IActionDelegates expect to update their enabled state when the
selection changes. That's when they have the opportunity to update
their IAction.

Commands+handler+menu contributions have a little more flexibility in
that the IHandler can fire a HandlerEvent when it wants to update
enabled/disabled on any menu contributions that are currently showing.

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: SetInitiallyVisible(boolean) for ActionSet not working [message #326857 is a reply to message #326683] Wed, 02 April 2008 08:52 Go to previous message
Rahul Kamdar is currently offline Rahul KamdarFriend
Messages: 63
Registered: July 2009
Member
Hi Paul.

Thanks for the reply and pointing at the basics I am missing. I'll try the
commands+handlers+menu contributions and check it out as well.

Thanks a lot!
Rahul

"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:fsir1v$pm7$1@build.eclipse.org...
> ActionSet IActionDelegates expect to update their enabled state when the
> selection changes. That's when they have the opportunity to update their
> IAction.
>
> Commands+handler+menu contributions have a little more flexibility in that
> the IHandler can fire a HandlerEvent when it wants to update
> enabled/disabled on any menu contributions that are currently showing.
>
> 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:quick fix popups classes
Next Topic:create plugin eclipse based on antlr
Goto Forum:
  


Current Time: Sat Jul 27 18:30:56 GMT 2024

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

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

Back to the top