Skip to main content



      Home
Home » Newcomers » Newcomers » about selectionChanged(IAction action, ISelection selection)
about selectionChanged(IAction action, ISelection selection) [message #260051] Fri, 04 July 2008 08:29 Go to next message
Eclipse UserFriend
Originally posted by: hjxaut.qq.com

i extend the "org.eclipse.ui.actionSets" point and "org.eclipse.ui.views"
point in plugin.xml. and there is a tree in the view.i want to make the
visible of action depend on the item which i select on the tree.
so i override the method "selectionChanged(IAction action, ISelection
selection)" as follow:
public void selectionChanged(IAction action, ISelection selection)
{

IStructuredSelection select = (IStructuredSelection) selection;
if (select.getFirstElement() instanceof TreeLeafEO)//if it's a leaf
{
action.setEnabled(true);
} else
{
action.setEnabled(false);
}

}

but i doesn't work until i press the label of action one time.i know the
reason that it owes to the lazy launch of plugin.so how can i deal with it?
Re: about selectionChanged(IAction action, ISelection selection) [message #260055 is a reply to message #260051] Fri, 04 July 2008 08:34 Go to previous message
Eclipse UserFriend
You can make your plugin be auto starting, but that's generally frowned
upon because if all plugins did that, startup would be grossly slow and
Eclipse would become needlessly bloated. Most people will advise you
that it's best to accept the behavior you see, because you'll see it in
many other cases as well.


snail_jie wrote:
> i extend the "org.eclipse.ui.actionSets" point and
> "org.eclipse.ui.views" point in plugin.xml. and there is a tree in the
> view.i want to make the visible of action depend on the item which i
> select on the tree.
> so i override the method "selectionChanged(IAction action, ISelection
> selection)" as follow:
> public void selectionChanged(IAction action, ISelection selection)
> {
>
> IStructuredSelection select = (IStructuredSelection) selection;
> if (select.getFirstElement() instanceof TreeLeafEO)//if it's a
> leaf
> {
> action.setEnabled(true);
> } else
> {
> action.setEnabled(false);
> }
>
> }
>
> but i doesn't work until i press the label of action one time.i know
> the reason that it owes to the lazy launch of plugin.so how can i deal
> with it?
>
Previous Topic:Miss the picture of editor contextmenu
Next Topic:Installation of both CDT and Modeling tools
Goto Forum:
  


Current Time: Tue Aug 05 19:58:54 EDT 2025

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

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

Back to the top