about selectionChanged(IAction action, ISelection selection) [message #260051] |
Fri, 04 July 2008 08:29  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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?
>
|
|
|
Powered by
FUDForum. Page generated in 0.09302 seconds