[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.newcomer] How can I get notified when CTRL+click (open declaration) is executed?
|
- From: bogdanditrsrc@xxxxxxxxx (Bogdan)
- Date: Tue, 24 Feb 2009 20:36:37 +0000 (UTC)
- Newsgroups: eclipse.newcomer
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
Hello,
I am writing a plug-in (using Eclipse 3.4) and I want to be notified if a
user opens a file using CTRL+click (open declaration) in a Java source
code file.
So far, I added a IExecutionListener to a ICommandService for the current
workbench window:
IWorkbenchWindow window =
PlatformUI.getWorkbench().getWorkbenchWindows()[0];
ICommandService service = (ICommandService)
window.getService(ICommandService.class);
service.addExecutionListener(new IExecutionListener() {
//? other methods (notHandled, postExecuteFailure, postExecuteSuccess)
public void preExecute(String commandId, ExecutionEvent event) {
//check for "open declaration" events
}
});
This code works fine (I triggers an ?open declaration? event which I catch
it inside the preExecute function) but ONLY in the following TWO cases: 1)
if I press F3 (Open declaration) or 2) Go to menu ?Navigate->Open
Declaration F3?. However, when I use CTRL+click (which the documentation
says should do the same thing (open declaration)), that event does not
trigger my preExecute function.
I also added an IPartListener to the active Workbench page to notify me
when a new file is being opened. This notifies me when a new file was
opened, but it does not tell me the source of the event (whether it was
CTRL+click, a file opened from the Package Explorer, a file opened from
Tabs, etc.)
IWorkbenchPage page=window.getActivePage();
page.addPartListener(new IPartListener()
{
//...other methods partOpened, partDeactivated, partClosed,
partBroughtToTop
public void partActivated(IWorkbenchPart arg0)
{
// notifies if a file was opened
//does not provide the source of the event (CTRL+click, package
explorer, opened files in tabs)
}
});
I was wondering if there is any other mechanism (listener) that could
notify me when the user presses CTRL+click, such as a listener for
actions, a source for where the action was generated or triggered, or
anything else. I searched for hyperlinks, editor listener, mouse hover,
etc., but nothing worked.
I would really appreciate any information that could help me solve this.
Thank you