Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Hooking existing clipboard commands
Hooking existing clipboard commands [message #330598] Tue, 05 August 2008 08:03 Go to next message
Eclipse UserFriend
Originally posted by: mba.cosmigo.ru

Hi everyone,

I'm trying to create a plugin like MultiClipboard. I'm a bit new to the
JFace concepts so please bear with me.

What I want to do is to is to add my custom handlers to the
cut/copy/paste commands wrapping the default handlers in them.

Something like this:

case1:

handleCopyCommand()
{
runCopyCommandAsIfThereNoMyPlugin();
doMySpecificCopyHandling();
}

or maybe something like this:

case2:

handleMyCustomCopyCommand()
{
fireStabdardCopyCommand();
doMySpecificCopyHandling();
}


As far as I understand the whole thing after reading docs, I need to
play around the org.eclipse.ui.commands extension point, but there are
things I still don't understand:

1. How to add a global command which would be active everywhere? My
plugin does not provide the editor. It provides a view, but it might be
closed. And I still want to have some key combination registered in the
workbench to fire my custom command (case2).

2. How to programmable initiate the command which was defined already
(case2)?

3. Is it possible at all to hook to the command like in case1?


I've tried to search the newsgroups but it seems that I cannot invent
the proper request.. Will be grateful for any help.

--
Best regards
Mikhail Barg


ICQ: 132560784
Re: Hooking existing clipboard commands [message #330857 is a reply to message #330598] Thu, 14 August 2008 17:33 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Mikhail Barg wrote:
> What I want to do is to is to add my custom handlers to the
> cut/copy/paste commands wrapping the default handlers in them.

org.eclipse.ui defines commands the commands like:
org.eclipse.ui.edit.copy -> CTRL+C
org.eclipse.ui.edit.cut -> CTRL+V
etc

org.eclipse.ui then provides a default handler for each of these
commands, org.eclipse.ui.internal.handlers.WidgetMethodHandler, that
when left alone will invoke the appropriate SWT method on the control in
focus (like focusControl.copy())

Parts then provide their own handlers as they see fit, and the part
handler overrides the default handler for copy.

It would be difficult to to write your own handler that could find the
"handler that would be active now if it wasn't for me" handler, so you
could do your work and delegate.

You might be able to do what you want though, but using
org.eclipse.core.commands.IExecutionListener and attaching it to the
ICommandService. Then you could check for the org.eclipse.ui.edit.copy
commandId in the pre and post execute methods, and add your behaviour as
well.

Later,
PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:CVS and Linked Source Folder
Next Topic:Are enabled activities persisted?
Goto Forum:
  


Current Time: Mon Jan 13 15:29:28 GMT 2025

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

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

Back to the top