Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » enablement in org.eclipse.ui.actionSets
enablement in org.eclipse.ui.actionSets [message #311524] Mon, 15 January 2007 07:52 Go to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

How can i set enablement for my (team-plugin) actions in
org.eclipse.ui.actionSets?
i tried to understand CVS plugin example, but unsuccessfully.
Re: enablement in org.eclipse.ui.actionSets [message #311531 is a reply to message #311524] Mon, 15 January 2007 09:38 Go to previous messageGo to next message
Eclipse UserFriend
Alexey,

Action sets don't have a visibility per se. Instead, they are associated
with a perspective. There are two ways to do this. This first is to
associate an action set with a perspective using a perspective
extension. Here's what the one for CVS looks like:

<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.team.cvs.ui.cvsPerspective">
<actionSet
id="org.eclipse.team.cvs.ui.CVSActionSet">
</actionSet>
</perspectiveExtension>
</extension>

The other way is for the user to customize a perspective by choosing
Window>Cusomize Perspective, clicking on the Command tab and checking
off the CVS action set (or any other action set they wish to add to the
current perspective)..

Michael

Alexey wrote:
>
> How can i set enablement for my (team-plugin) actions in
> org.eclipse.ui.actionSets?
> i tried to understand CVS plugin example, but unsuccessfully.
>
Re: enablement in org.eclipse.ui.actionSets [message #311533 is a reply to message #311531] Mon, 15 January 2007 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

thanks Michael!

i have already do it.. my question is not about visibility, i have it.. i
ask for enablement - where can i define action possibility to execute (and
represent this visuually, of course), depending by resource conditions,
for example.
Re: enablement in org.eclipse.ui.actionSets [message #311538 is a reply to message #311533] Mon, 15 January 2007 13:54 Go to previous messageGo to next message
Eclipse UserFriend
For enablement, you need to adjust the result you return from
IActionDelegate#isEnabled based on the selection that is provided to
your delegate through the selectionChanged method. The internal
TeamAction class is the class that manages this for the CVS plug-in.

Michael

Alexey wrote:
> thanks Michael!
>
> i have already do it.. my question is not about visibility, i have it..
> i ask for enablement - where can i define action possibility to execute
> (and represent this visuually, of course), depending by resource
> conditions, for example.
>
Re: enablement in org.eclipse.ui.actionSets [message #311553 is a reply to message #311538] Tue, 16 January 2007 01:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

Michael Valenta wrote:

> For enablement, you need to adjust the result you return from
> IActionDelegate#isEnabled based on the selection that is provided to
> your delegate through the selectionChanged method. The internal
> TeamAction class is the class that manages this for the CVS plug-in.

IActionDelegate and IWorkbenchWindowActionDelegate don't have isEnabled.
TeamAction is the best way, but it's cause "Discouraged access"-warning..
I tried to understand how TeamAction use isEnabled (where from it calling)
but can't. How it looks for me - CVS and VSS plugins have several level
wrapping actions delegate, but when isEnabled must been calling - i don't
see.
Re: enablement in org.eclipse.ui.actionSets [message #311572 is a reply to message #311553] Tue, 16 January 2007 12:28 Go to previous messageGo to next message
Eclipse UserFriend
Alexey,

Sorry. I made a bit of a mistake (and shouldn't have mentioned
TeamAction since it over complicates things). The selectionChange method
on IActionDelegate is passed an IAction and an ISelection. In this call,
you should determine the enablement based on the ISelection and call
IAction#setEnabled with the appropriate value.

Michael

Alexey wrote:
> Michael Valenta wrote:
>
>> For enablement, you need to adjust the result you return from
>> IActionDelegate#isEnabled based on the selection that is provided to
>> your delegate through the selectionChanged method. The internal
>> TeamAction class is the class that manages this for the CVS plug-in.
>
> IActionDelegate and IWorkbenchWindowActionDelegate don't have isEnabled.
> TeamAction is the best way, but it's cause "Discouraged
> access"-warning.. I tried to understand how TeamAction use isEnabled
> (where from it calling) but can't. How it looks for me - CVS and VSS
> plugins have several level wrapping actions delegate, but when isEnabled
> must been calling - i don't see.
>
Re: enablement in org.eclipse.ui.actionSets [message #311584 is a reply to message #311572] Wed, 17 January 2007 01:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

> The selectionChange method
> on IActionDelegate is passed an IAction and an ISelection. In this call,
> you should determine the enablement based on the ISelection and call
> IAction#setEnabled with the appropriate value.

thank you for help, Michael!

this is my action class :

public class AddAction implements IWorkbenchWindowActionDelegate {

public void dispose() {
}
public void init(IWorkbenchWindow window) {
}
public void run(IAction action) {
}
public void selectionChanged(IAction action, ISelection selection) {
}
}
suggest me please, how implement IAction#setEnabled here?
Re: enablement in org.eclipse.ui.actionSets [message #311617 is a reply to message #311584] Thu, 18 January 2007 06:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

so, i don't understand how eclipse applicatin will using my
IAction#isEnabled? i think this method never calls.. how to do it useful?
Re: enablement in org.eclipse.ui.actionSets [message #311621 is a reply to message #311584] Thu, 18 January 2007 08:09 Go to previous messageGo to next message
Eclipse UserFriend
Alexey wrote:
>> The selectionChange method on IActionDelegate is passed an IAction and
>> an ISelection. In this call, you should determine the enablement based
>> on the ISelection and call IAction#setEnabled with the appropriate value.
>
> thank you for help, Michael!
>
> this is my action class :
>
> public class AddAction implements IWorkbenchWindowActionDelegate {
>
> public void dispose() {
> }
> public void init(IWorkbenchWindow window) {
> }
> public void run(IAction action) {
> }
> public void selectionChanged(IAction action, ISelection selection) {
> }
> }


When you delegate is instatiated, your selectionChanged(*) method will
be called. In your selectionChanged(*) method, call
action.setEnabled(true/false).

Later,
PW
Re: enablement in org.eclipse.ui.actionSets [message #311623 is a reply to message #311621] Thu, 18 January 2007 08:32 Go to previous messageGo to next message
Eclipse UserFriend
Paul Webster schrieb:
> Alexey wrote:
>>> The selectionChange method on IActionDelegate is passed an IAction
>>> and an ISelection. In this call, you should determine the enablement
>>> based on the ISelection and call IAction#setEnabled with the
>>> appropriate value.
>>
>> thank you for help, Michael!
>>
>> this is my action class :
>>
>> public class AddAction implements IWorkbenchWindowActionDelegate {
>>
>> public void dispose() {
>> }
>> public void init(IWorkbenchWindow window) {
>> }
>> public void run(IAction action) {
>> }
>> public void selectionChanged(IAction action, ISelection selection) {
>> }
>> }
>
>
> When you delegate is instatiated, your selectionChanged(*) method will
> be called. In your selectionChanged(*) method, call
> action.setEnabled(true/false).
>
> Later,
> PW

or more explicit if you implement IWorkbenchWindowActionDelegate2 there
is a dedicated method called but I can't remember which it was :-(

Tom
Re: enablement in org.eclipse.ui.actionSets [message #311626 is a reply to message #311621] Thu, 18 January 2007 09:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

> When you delegate is instatiated, your selectionChanged(*) method will
> be called. In your selectionChanged(*) method, call
> action.setEnabled(true/false).

Ok,

>this is my action class :
>
> public class AddAction implements IWorkbenchWindowActionDelegate {
>
> public void dispose() {
> }
> public void init(IWorkbenchWindow window) {
> }
> public void run(IAction action) {
> }
> public void selectionChanged(IAction action, ISelection selection) {
> }
> }
I add "implements IAction"
and here
public boolean isEnabled() {
return false; !!!!!!!
}
but when application running - this action is enabled!

so, i repeat my question -
how make Eclipse to use this IAction#isEnabled method?

i need a way to provide enablement for my action, please..
Re: enablement in org.eclipse.ui.actionSets [message #311627 is a reply to message #311626] Thu, 18 January 2007 09:46 Go to previous messageGo to next message
Eclipse UserFriend
Alexey wrote:
>> When you delegate is instatiated, your selectionChanged(*) method will
>> be called. In your selectionChanged(*) method, call
>> action.setEnabled(true/false).
>
> Ok,

Show us your selectionChanged(*) method.

Put a breakpoint in it. What happens when it is called?

> I add "implements IAction"

Don't implement IAction anywhere... it will not help you.

Later,
PW
Re: enablement in org.eclipse.ui.actionSets [message #311629 is a reply to message #311627] Thu, 18 January 2007 09:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

Paul Webster wrote:

> Don't implement IAction anywhere... it will not help you.
i think so


> Put a breakpoint in it. What happens when it is called?
i think - never.. who will calling it??


> Show us your selectionChanged(*) method.
it doesn't metter

public void selectionChanged(IAction action, ISelection selection) {
if (selection instanceof IStructuredSelection) {
this._selection = (IStructuredSelection) selection;
}
}
Re: enablement in org.eclipse.ui.actionSets [message #311630 is a reply to message #311629] Thu, 18 January 2007 09:58 Go to previous messageGo to next message
Eclipse UserFriend
Alexey schrieb:
> Paul Webster wrote:
>
>> Don't implement IAction anywhere... it will not help you.
> i think so
>
>
>> Put a breakpoint in it. What happens when it is called?
> i think - never.. who will calling it??
>
>
>> Show us your selectionChanged(*) method.
> it doesn't metter
>
> public void selectionChanged(IAction action, ISelection selection) {
> if (selection instanceof IStructuredSelection) {
> this._selection = (IStructuredSelection) selection;
> }
> }
>

and why are you not callin

action.setEnabled(false)

there?

Tom
Re: enablement in org.eclipse.ui.actionSets [message #311636 is a reply to message #311629] Thu, 18 January 2007 10:20 Go to previous messageGo to next message
Eclipse UserFriend
Alexey wrote:
> Paul Webster wrote:
>
>> Don't implement IAction anywhere... it will not help you.
> i think so
>
>
>> Put a breakpoint in it. What happens when it is called?
> i think - never.. who will calling it??
>
>
>> Show us your selectionChanged(*) method.
> it doesn't metter

It doesn't matter? ... but that was where I told you to call
action.setEnabled(false) ... you know that asking questions works better
when you also read the answers, right :-)

Later,
PW
Re: enablement in org.eclipse.ui.actionSets [message #311678 is a reply to message #311630] Fri, 19 January 2007 01:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

Tom Schindl wrote:

> and why are you not callin

> action.setEnabled(false)

> there?

> Tom

what kind of class i have to use?
IWorkbenchWindowActionDelegate don't have methods to enablment
Re: enablement in org.eclipse.ui.actionSets [message #311679 is a reply to message #311636] Fri, 19 January 2007 01:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

Paul, i read and understand, what you mean, really.
I think you (& not only you) don't understanding what i iasking here..

let's start from beginning :

in plugin.xml i define some action in org.eclipse.ui.actionSets

generating class for action must implements
org.eclipse.ui.IWorkbenchWindowActionDelegate, which don't have enablement
features, look :

public class MyAction implements IWorkbenchWindowActionDelegate {
public void dispose() {
}
public void init(IWorkbenchWindow window) {
}
public void run(IAction action) {
}
public void selectionChanged(IAction action, ISelection selection) {
}
}

what i have to do here to define my action enablement?
Re: enablement in org.eclipse.ui.actionSets [message #311680 is a reply to message #311524] Fri, 19 January 2007 03:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

Ok

in
public void selectionChanged(IAction action, ISelection selection)
this action delegate my action and i can manage enablement to my action by
calling

public void selectionChanged(IAction action, ISelection selection) {
action.setEnabled(value);
}

that was what i want to know,
thanks to all!
Re: enablement in org.eclipse.ui.actionSets [message #311681 is a reply to message #311636] Fri, 19 January 2007 03:17 Go to previous message
Eclipse UserFriend
Originally posted by: Sferzah.yandex.ru

Paul Webster wrote:

> When you delegate is instatiated, your selectionChanged(*) method will
> be called. In your selectionChanged(*) method, call
> action.setEnabled(true/false).

this is what i want, my poor english play with me bad joke.. :)

sorry Paul, sorry! :)
Previous Topic:[DataBinding] Best practices on creating the DataBindingContext
Next Topic:sun.io.MalformedInputException in Chinese locale
Goto Forum:
  


Current Time: Sat May 10 03:38:53 EDT 2025

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

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

Back to the top