Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » implementing global action in ApplicationWorkbench
implementing global action in ApplicationWorkbench [message #484309] Sat, 05 September 2009 23:43 Go to next message
Eclipse UserFriend
hello
I have implemented the global actions in the controls of the Editors in the following way
final Action cutSelected = new Action() {
			public void run() {
				styledText.cut();
			}
		};
		//
		getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.CUT.getId(), cutSelected);



Now the problem is there is a control in ApplicationWorkbench. how can I implement the global actions in that control?

Thanks
Re: implementing global action in ApplicationWorkbench [message #484685 is a reply to message #484309] Tue, 08 September 2009 14:07 Go to previous messageGo to next message
Eclipse UserFriend
The IFocusService allows you to specify handlers for commands like cut, copy, paste where you only need to specify the control that has focus.

See the javadoc for IFocusService for details.

PW
Re: implementing global action in ApplicationWorkbench [message #484978 is a reply to message #484685] Thu, 10 September 2009 01:50 Go to previous messageGo to next message
Eclipse UserFriend
IFocusService service = (IFocusService) Application.APP_WINDOW.getService(IFocusService.class);


how can I activate the cut, copy, paste of the edit menu for the given control?
Re: implementing global action in ApplicationWorkbench [message #485085 is a reply to message #484978] Thu, 10 September 2009 09:57 Go to previous messageGo to next message
Eclipse UserFriend
So you've used the IFocusService to tag the control you care about and the IHandlerService to activate some handlers for it, right?

In 3.4 Edit>Copy did not correctly follow the CTRL+C copy. That was fixed in 3.5. In an RCP app you can fix it yourself if you want.

PW
Re: implementing global action in ApplicationWorkbench [message #485110 is a reply to message #485085] Thu, 10 September 2009 10:34 Go to previous messageGo to next message
Eclipse UserFriend
Paul Webster wrote:
> So you've used the IFocusService to tag the control you care about and
> the IHandlerService to activate some handlers for it, right?
>
> In 3.4 Edit>Copy did not correctly follow the CTRL+C copy. That was
> fixed in 3.5. In an RCP app you can fix it yourself if you want.

Interesting - what do I need to do to fix that?

Thanks,

Daniel
Re: implementing global action in ApplicationWorkbench [message #485156 is a reply to message #485110] Thu, 10 September 2009 12:26 Go to previous message
Eclipse UserFriend
In an RCP app, you just need to update your ApplicationActionBarAdvisor with a CommandContributionItem instead of ActionFactory.COPY, for example (I think).

ex:
menu.add(getCopyItem());

private IContributionItem getCopyItem() {
return getItem(
ActionFactory.COPY.getId(),
ActionFactory.COPY.getCommandId(),
ISharedImages.IMG_TOOL_COPY,
ISharedImages.IMG_TOOL_COPY_DISABLED,
WorkbenchMessages.Workbench_copy,
WorkbenchMessages.Workbench_copyToolTip, null);
}

private IContributionItem getItem(String actionId, String commandId,
String image, String disabledImage, String label, String tooltip, String helpContextId) {
ISharedImages sharedImages = getWindow().getWorkbench()
.getSharedImages();

IActionCommandMappingService acms = (IActionCommandMappingService) getWindow()
.getService(IActionCommandMappingService.class);
acms.map(actionId, commandId);

CommandContributionItemParameter commandParm = new CommandContributionItemParameter(
getWindow(), actionId, commandId, null, sharedImages
.getImageDescriptor(image), sharedImages
.getImageDescriptor(disabledImage), null, label, null,
tooltip, CommandContributionItem.STYLE_PUSH, null, false);
return new CommandContributionItem(commandParm);
}

This is the code from 3.5, it might need to be tweaked for 3.4 (ActionFactory.COPY.getCommandId() doesn't exist in 3.4, for example).

PW
Previous Topic:Update site categories missing / feature dependencies broken
Next Topic:Command Parameter and dynamic menu
Goto Forum:
  


Current Time: Tue Jun 03 06:48:27 EDT 2025

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

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

Back to the top