Home » Eclipse Projects » Technology Project and PMC » How does one monitor events in Eclipse (run, save, refactor, etc.)?
How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #72351] |
Fri, 02 June 2006 00:37 |
Eclipse User |
|
|
|
Originally posted by: pschlesi.NOSPAM.uci.edu
Hi! I'm building a plug-in that must monitor user events in Eclipse
(run, save, refactor, etc.). How does one do that? What is the API
call? Is there an example out there that I can model myself after?
Any help would be greatly appreciated...
Thanks, Phil
|
|
| |
Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #72387 is a reply to message #72368] |
Fri, 02 June 2006 16:24 |
Eclipse User |
|
|
|
Originally posted by: pschlesi.NOSPAM.uci.edu
Hi Paul - I will try this this weekend or early next week and will post
back my results.
Thanks!
- Phil
Paul Webster wrote:
> AFAIK, there's no general event bus that captures all actions.
>
> In 3.2, you can register an IExecutionListener with the ICommandService.
> That would notify any commands that are executing, which is most
> actions (but not all).
>
> Later,
> PW
|
|
|
Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #72531 is a reply to message #72368] |
Sun, 11 June 2006 08:13 |
Eclipse User |
|
|
|
Originally posted by: pschlesi.NOSPAM.uci.edu
Paul - that appears to have done the trick. Thanks for the pointer.
Once this plugin's done, I'm going to post the code somewhere - there's
no examples of how to use any of this stuff...
- Phil
Paul Webster wrote:
> AFAIK, there's no general event bus that captures all actions.
>
> In 3.2, you can register an IExecutionListener with the ICommandService.
> That would notify any commands that are executing, which is most
> actions (but not all).
>
> Later,
> PW
|
|
|
CODE for all to use - Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #72584 is a reply to message #72368] |
Sun, 11 June 2006 21:25 |
Eclipse User |
|
|
|
Originally posted by: pschlesi.NOSPAM.uci.edu
This will come out messy, sorry. Use this with the Eclipse default
plug-in for a View.
ArrayList<String> events = new ArrayList<String> ();
ICommandService commandService = (ICommandService)
PlatformUI.getWorkbench().getAdapter(ICommandService.class);
commandService.readRegistry();
Collection categories = commandService.getDefinedCategoryIds();
Object[] catString = categories.toArray();
Collection commandIds = commandService.getDefinedCommandIds();
Object[] comString = commandIds.toArray();
PrintWriter out = null;
try {
out = new PrintWriter( new BufferedWriter( new FileWriter( "c:/foo2.out"
) ) );
out.write("Categories\n");
for (int i = 0; i < catString.length; ++i)
out.write(i + ": " + catString[i].toString() + "\n");
out.write("\n\nCommandIds\n");
for (int i = 0; i < comString.length; ++i)
out.write(i + ": " + comString[i].toString() + "\n");
out.close();
} catch (IOException e) {
e.printStackTrace();
}
ExecutionListener executionListener = new ExecutionListener();
commandService.addExecutionListener(executionListener);
public class ExecutionListener implements IExecutionListener {
public void notHandled(String arg0, NotHandledException arg1) {
events.add("NotHandled: " + arg0);
viewer.refresh();
}
public void postExecuteFailure(String arg0, ExecutionException arg1) {
// do nothing - we watch preExecute and notHandled
}
public void postExecuteSuccess(String arg0, Object arg1) {
// do nothing - we watch preExecute and notHandled
}
public void preExecute(String arg0, ExecutionEvent arg1) {
events.add("preExecute: " + arg0);
viewer.refresh();
}
}
|
|
|
Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #72689 is a reply to message #72368] |
Thu, 15 June 2006 04:18 |
Eclipse User |
|
|
|
Originally posted by: pschlesi.NOSPAM.uci.edu
Paul,
Little problem: the IExecutionListener / ICommandService pairing only
reports what KEYBOARD shortcuts are used.
So Ctrl-S will show up.
However, if I click File/Save, or click the Disk button in the toolbar,
nothing is picked up.
What is the class for listening to commands via mouse or menus?
- Phil
Paul Webster wrote:
> AFAIK, there's no general event bus that captures all actions.
>
> In 3.2, you can register an IExecutionListener with the ICommandService.
> That would notify any commands that are executing, which is most
> actions (but not all).
>
> Later,
> PW
|
|
|
Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #72699 is a reply to message #72689] |
Thu, 15 June 2006 11:09 |
|
Philip Schlesinger wrote:
> Paul,
>
> Little problem: the IExecutionListener / ICommandService pairing only
> reports what KEYBOARD shortcuts are used.
>
> So Ctrl-S will show up.
>
> However, if I click File/Save, or click the Disk button in the toolbar,
> nothing is picked up.
>
> What is the class for listening to commands via mouse or menus?
As I said, there isn't one. Hopefully in 3.3.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #72800 is a reply to message #72689] |
Tue, 20 June 2006 06:47 |
Eclipse User |
|
|
|
Originally posted by: jekutsch.inf.fu-berlin.de
Hi Philip,
I had a similiar problem some weeks ago and posted my solution in
eclipse.platform. See the posting attached. Maybe the same technique is
useful for you as well. It requires that you'd like to catch events on
(Text)Editors. I didn't explore it in more details.
If you want to fetch Save operations, you may listen to the dirtyStateChange
of an IFileBufferListener which must be registrered as this:
FileBuffers.getTextFileBufferManager().addFileBufferListener (new
MyFileBufferListener());
where MyFileBufferListener implements IFileBufferListener. Dirty Flag state
callup methods are also provided by JDT's ElementStateListeners and
ResourceListeners.
Generally, I don't know any basic mechanism to catch user activities apart
from the basic SWT's Display.handleEvent().
I'm interested in your project. What are you about to implement? I'm
currently implementing a plugin to store meaningful user actions while
programming with Eclipse (for research purposes). Fuyy: The first version of
this (called ECG: http://www.inf.fu-berlin.de/ecg) has been compiled by a
student with surname "Schlesinger" :-)
Cheers,
Sebastian (http://www.inf.fu-berlin.de/~jekutsch)
"Philip Schlesinger" <pschlesi@NOSPAM.uci.edu> wrote in message
news:e6qn28$bpq$1@utils.eclipse.org...
> Paul,
>
> Little problem: the IExecutionListener / ICommandService pairing only
> reports what KEYBOARD shortcuts are used.
>
> So Ctrl-S will show up.
>
> However, if I click File/Save, or click the Disk button in the toolbar,
> nothing is picked up.
>
> What is the class for listening to commands via mouse or menus?
>
> - Phil
>
> Paul Webster wrote:
>> AFAIK, there's no general event bus that captures all actions.
>>
>> In 3.2, you can register an IExecutionListener with the ICommandService.
>> That would notify any commands that are executing, which is most actions
>> (but not all).
>>
>> Later,
>> PW
|
|
| | | | |
Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #600765 is a reply to message #72368] |
Thu, 15 June 2006 04:18 |
Philip Schlesinger Messages: 7 Registered: July 2009 |
Junior Member |
|
|
Paul,
Little problem: the IExecutionListener / ICommandService pairing only
reports what KEYBOARD shortcuts are used.
So Ctrl-S will show up.
However, if I click File/Save, or click the Disk button in the toolbar,
nothing is picked up.
What is the class for listening to commands via mouse or menus?
- Phil
Paul Webster wrote:
> AFAIK, there's no general event bus that captures all actions.
>
> In 3.2, you can register an IExecutionListener with the ICommandService.
> That would notify any commands that are executing, which is most
> actions (but not all).
>
> Later,
> PW
|
|
|
Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #600772 is a reply to message #72689] |
Thu, 15 June 2006 11:09 |
|
Philip Schlesinger wrote:
> Paul,
>
> Little problem: the IExecutionListener / ICommandService pairing only
> reports what KEYBOARD shortcuts are used.
>
> So Ctrl-S will show up.
>
> However, if I click File/Save, or click the Disk button in the toolbar,
> nothing is picked up.
>
> What is the class for listening to commands via mouse or menus?
As I said, there isn't one. Hopefully in 3.3.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: How does one monitor events in Eclipse (run, save, refactor, etc.)? [message #600811 is a reply to message #72689] |
Tue, 20 June 2006 06:47 |
Eclipse User |
|
|
|
Originally posted by: jekutsch.inf.fu-berlin.de
Hi Philip,
I had a similiar problem some weeks ago and posted my solution in
eclipse.platform. See the posting attached. Maybe the same technique is
useful for you as well. It requires that you'd like to catch events on
(Text)Editors. I didn't explore it in more details.
If you want to fetch Save operations, you may listen to the dirtyStateChange
of an IFileBufferListener which must be registrered as this:
FileBuffers.getTextFileBufferManager().addFileBufferListener (new
MyFileBufferListener());
where MyFileBufferListener implements IFileBufferListener. Dirty Flag state
callup methods are also provided by JDT's ElementStateListeners and
ResourceListeners.
Generally, I don't know any basic mechanism to catch user activities apart
from the basic SWT's Display.handleEvent().
I'm interested in your project. What are you about to implement? I'm
currently implementing a plugin to store meaningful user actions while
programming with Eclipse (for research purposes). Fuyy: The first version of
this (called ECG: http://www.inf.fu-berlin.de/ecg) has been compiled by a
student with surname "Schlesinger" :-)
Cheers,
Sebastian (http://www.inf.fu-berlin.de/~jekutsch)
"Philip Schlesinger" <pschlesi@NOSPAM.uci.edu> wrote in message
news:e6qn28$bpq$1@utils.eclipse.org...
> Paul,
>
> Little problem: the IExecutionListener / ICommandService pairing only
> reports what KEYBOARD shortcuts are used.
>
> So Ctrl-S will show up.
>
> However, if I click File/Save, or click the Disk button in the toolbar,
> nothing is picked up.
>
> What is the class for listening to commands via mouse or menus?
>
> - Phil
>
> Paul Webster wrote:
>> AFAIK, there's no general event bus that captures all actions.
>>
>> In 3.2, you can register an IExecutionListener with the ICommandService.
>> That would notify any commands that are executing, which is most actions
>> (but not all).
>>
>> Later,
>> PW
|
|
|
Goto Forum:
Current Time: Mon Jun 17 06:32:25 GMT 2024
Powered by FUDForum. Page generated in 0.05354 seconds
|