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