Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Action - is this possible in Eclipse?
Action - is this possible in Eclipse? [message #219024] Wed, 31 March 2004 04:49 Go to next message
Eclipse UserFriend
Originally posted by: sreejaak.yahoo.com

Hi,
I have an action - it should appear in the Toolbar for my views and
editors. For the views, the action should be enabled based on the
selection of a node in the treeViewer of the view. For the editors, the
action should be enabled if the active editor "is dirty".

I tried to implement the above Action using IWorkbenchWindowActionDelegate
since that provides a common set of actions for editors and views. But
then I cannot set the enablement condition there separately for the editor
and views..

Should I use ActionBarContributors for the purpose? If I do that, how can
I ensure that the action appears in the same position in the workbench
toolbar for the editor and view?

Thanks in advance,
Sree
Re: Action - is this possible in Eclipse? [message #221701 is a reply to message #219024] Sun, 04 April 2004 20:51 Go to previous message
Eclipse UserFriend
Originally posted by: sreejaak.yahoo.com

Hi,
Managed to find a solution with a little tweaking around. Thought it might
be useful for somebody else who might get stuck similarly.

Used IWorkbenchWindowActionDelegate, and for the views, I set my
enablement condition in the Plugin.xml based on treeViewer's selected
object and its value. On the "selectionChanged" event, trapped the
editor's selection(where I was getting an AbstractGraphicalEditPart of the
GEFEditor). From the init() of the IWorkbenchWindowActionDelegate, I could
store the "workbench" handle too as class member. Then used the
"workbench" member to get the currently active editor inside the
"selectionChanged" event together with the ISelection(if it contained the
EditPart) to identify that our editor was selected. Enabled the action
button programatically by checking the isDirty of the currently active
editor, after the previously mentioned check..Now the same menubar and
toolbar actions support the enablement conditions from both our views and
editors!!

:)
Sree

Sree wrote:

> Hi,
> I have an action - it should appear in the Toolbar for my views and
> editors. For the views, the action should be enabled based on the
> selection of a node in the treeViewer of the view. For the editors, the
> action should be enabled if the active editor "is dirty".

> I tried to implement the above Action using IWorkbenchWindowActionDelegate
> since that provides a common set of actions for editors and views. But
> then I cannot set the enablement condition there separately for the editor
> and views..

> Should I use ActionBarContributors for the purpose? If I do that, how can
> I ensure that the action appears in the same position in the workbench
> toolbar for the editor and view?

> Thanks in advance,
> Sree
Previous Topic:Can I setup the position of an open fast view?
Next Topic:Enabling an Action when selecting an Editor
Goto Forum:
  


Current Time: Sat May 10 05:48:13 EDT 2025

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

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

Back to the top