Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Question concerning actionSets
Question concerning actionSets [message #455404] Mon, 25 September 2006 11:21 Go to next message
Eclipse UserFriend
Hi,

I have two questions concerning actionSets. I'm developing a RCP
application and have several actions to integrate. Is it possible to add
an action via an actionSet where the enablement depends on the existence
of some specific part. When I add an action programmatically I can extend
the class PartEventAction and listen to open/close events for example. I
need the same for an action added via an actionSet. Is this possible? My
second question refer to the enablement of actions, too. The enablement of
my actions differ in the number of selected elements in my editor. After
studying the possibilities of enablement I'm wondering why it is not
possible to say that the action should be enabled when three or more
elements are selected. I think this is only possible for one (+) or two
(multiple, 2+) selected elements. I tried 3+, but the action enables
never. Is this correct or is there a possibility to say this?

Thanks in advance,

Ingo
Re: Question concerning actionSets [message #455431 is a reply to message #455404] Mon, 25 September 2006 15:01 Go to previous messageGo to next message
Eclipse UserFriend
Ingo Kroh wrote:
> Hi,
>
> I have two questions concerning actionSets. I'm developing a RCP
> application and have several actions to integrate. Is it possible to add
> an action via an actionSet where the enablement depends on the existence
> of some specific part. When I add an action programmatically I can
> extend the class PartEventAction and listen to open/close events for
> example. I need the same for an action added via an actionSet. Is this
> possible?


You can use an org.eclipse.ui.actionSetPartAssociations to tie actionSet
visibility to any part (view or editor).

Later,
PW
Re: Question concerning actionSets [message #455444 is a reply to message #455431] Tue, 26 September 2006 03:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi Paul,

I use this extension point already, but the user can change the visibility
via the Edit Actionsets Action, which I want to use in my application. And
when the user sets the visibility always true, the action is enabled
although no editor is open.

Ingo
Re: Question concerning actionSets [message #455496 is a reply to message #455444] Tue, 26 September 2006 21:18 Go to previous messageGo to next message
Eclipse UserFriend
Ingo Kroh wrote:
> Hi Paul,
>
> I use this extension point already, but the user can change the
> visibility via the Edit Actionsets Action, which I want to use in my
> application. And when the user sets the visibility always true, the
> action is enabled although no editor is open.


In your init(*) method, you can add your action as an IPartListener2 to
the workbench page and check for the part you are interested in.

Save your enablement state, and then when you get a selectionChanged(*)
call you can update the IAction state, and on a run(*) you can update
the IAction state and return immediately.

If you mean is there a way to do enablement declaratively for actionSet
actions, not in 3.2.

In 3.3 there we hope to change the way enablement works for actions so
that they have the same application context to draw on as handlers.
Then you could check for a specific part id.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=154130

Later,
PW
Re: Question concerning actionSets [message #455503 is a reply to message #455496] Wed, 27 September 2006 04:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi Paul,

first of all thanks a lot. I'm indeed looking for a solution to control
the enablement declaratively, but it's not bad if I have to do this
programmatically. Anyway I'm not really happy with that solution. To
change the enablement of the action I need a reference to it in my class
in order to enable/disable the action in one of the PartListener methods.
The only possibilities I see are in the run() and selectionChanged()
methods. I found out that the selectionChanged() method is called once
when the workbench starts up, so I initialize the variable there. It
looks sth. like this:

public class MyAction implements IWorkbenchWindowActionDelegate,
IPartListener2 {

private IWorkbenchWindow workbenchWindow = null;

private IAction action = null;

...

public void init(IWorkbenchWindow window) {

workbenchWindow = window;
workbenchWindow.getPartService().addPartListener(this);

}

public void selectionChanged(IAction action, ISelection selection) {

if(this.action == null)
{
this.action = action;
this.action.setEnabled(false);
}

}

public void partClosed(IWorkbenchPartReference partRef) {

//code for checking whether there are open editors

}

public void partOpened(IWorkbenchPartReference partRef) {

//code for checking which type of part was opened

}

...
}

Is this approach what you meant or am I misunderstanding what you said? It
works but I think it's not really a good solution.

Ingo
Re: Question concerning actionSets [message #455514 is a reply to message #455503] Wed, 27 September 2006 21:19 Go to previous messageGo to next message
Eclipse UserFriend
Ingo Kroh wrote:
> Is this approach what you meant or am I misunderstanding what you said?
> It works but I think it's not really a good solution.

Yes, that's close to what I had in mind. But I wouldn't cache the IAction.

Use the partActivated(*) and partDeactivated(*) to update your own
delegateActive boolean.

Them every time selectionChanged(*) or run(*) is called, check if you
can update the action that's passed in.

if (delegateActive!=action.isEnabled()) {
action.setEnabled(delegateActive);
}


Same kind of thing in run, but also check delegateActive and just return
if it's false.

Later,
PW
Re: Question concerning actionSets [message #455528 is a reply to message #455514] Thu, 28 September 2006 10:24 Go to previous message
Eclipse UserFriend
Hi Paul,

I try your solution. Anyway I think it's circumstantial if you want add an
action via an ActionSet and make it dependent whether a particular part is
open or not. I know I could do this programmatically, but then I lose the
possibility to let the user decide whether the ActionSet is visible or
not. I hope this is better in Eclipse 3.3.

So long,
Ingo
Previous Topic:Eclipse Update Manager Problem
Next Topic:embedded JRE
Goto Forum:
  


Current Time: Sun Aug 31 15:35:26 EDT 2025

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

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

Back to the top