Home » Eclipse Projects » SWTBot » How to access the JDT "quick outline" pop-up?
How to access the JDT "quick outline" pop-up? [message #507896] |
Thu, 14 January 2010 21:16 |
Robert M. Fuhrer Messages: 294 Registered: July 2009 |
Senior Member |
|
|
I'm working out how to test IDEs for IMP.
My current question is how to access information pop-ups, like the
"Quick Outline" view in the JDT, accessible (on Mac OS) via Cmd-O.
I tried the following:
srcEditor.pressShortcut(Keystrokes.COMMAND, KeyStroke.getInstance("o"));
bot.waitUntil(Conditions.waitForShell(new BaseMatcher<Shell>() {
public boolean matches(Object item) {
return (item instanceof JavaOutlineInformationControl);
}
public void describeTo(Description description) {
description.appendText("Shell of type " + JavaOutlineInformationControl.class);
}
}));
bot.tree().select("main(String[]) : void"); // hopefully gets the tree in the 'quick outline' view
but this doesn't work (times out, never finding the shell).
[BTW, JavaOutlineInformationControl is the active shell for the "Quick
Outline" pop-up view, according to EclipseSpy.]
This code runs when the variable 'srcEditor' refers to a Java source
editor, which presently has focus.
N.B.: I don't actually see the pop-up appear, so presumably the Cmd-O
shortcut I'm trying to invoke just isn't working, as opposed to the
waitForShell() call being wrong.
Any hints?
--
Cheers,
-- Bob
--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center
IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
|
|
|
Re: How to access the JDT "quick outline" pop-up? [message #508031 is a reply to message #507896] |
Fri, 15 January 2010 15:44 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
Robert M. Fuhrer wrote:
> I'm working out how to test IDEs for IMP.
>
> My current question is how to access information pop-ups, like the
> "Quick Outline" view in the JDT, accessible (on Mac OS) via Cmd-O.
>
> I tried the following:
>
> srcEditor.pressShortcut(Keystrokes.COMMAND,
> KeyStroke.getInstance("o"));
> bot.waitUntil(Conditions.waitForShell(new BaseMatcher<Shell>() {
> public boolean matches(Object item) {
> return (item instanceof JavaOutlineInformationControl);
> }
> public void describeTo(Description description) {
> description.appendText("Shell of type " +
> JavaOutlineInformationControl.class);
> }
> }));
> bot.tree().select("main(String[]) : void"); // hopefully gets the
> tree in the 'quick outline' view
>
> but this doesn't work (times out, never finding the shell).
>
> [BTW, JavaOutlineInformationControl is the active shell for the "Quick
> Outline" pop-up view, according to EclipseSpy.]
>
> This code runs when the variable 'srcEditor' refers to a Java source
> editor, which presently has focus.
>
> N.B.: I don't actually see the pop-up appear, so presumably the Cmd-O
> shortcut I'm trying to invoke just isn't working, as opposed to the
> waitForShell() call being wrong.
>
> Any hints?
>
I suspect that it is effectively the pressShortcut call that doesn't
work. I would suggest you try something like this:
String commandId = IJavaEditorActionDefinitionIds.SHOW_OUTLINE;
IWorkbenchPart part = srcEditor.getReference();
IHandlerService adapter = (IHandlerService)
part.getSite().getService(IHandlerService.class);
Object commandResult = adapter.executeCommand(commandId, null);
This little snippet shows how to activate a command programmatically.
The only thing I am not sure about is the commandId, but I think it's
the one you need in this case [1]. And make sure you run this inside the
UI thread, with a syncExec().
This should activate your pop-up, so watch the test execution to confirm.
[1] I have traced this using the handy "get reference in workspace"
action in Eclipse. First I looked for JavaOutlineInformationControl,
then I saw that the constructor requires a commandId. I then traced the
calls to
JavaSourceViewerConfiguration#getOutlinePresenterControlCrea tor, which
is called by JavaSourceViewerConfiguration#getOutlinePresenter with
IJavaEditorActionDefinitionIds.SHOW_OUTLINE as the commandId.
Hope this helps.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
|
|
|
Re: How to access the JDT "quick outline" pop-up? [message #508099 is a reply to message #508031] |
Fri, 15 January 2010 16:46 |
Robert M. Fuhrer Messages: 294 Registered: July 2009 |
Senior Member |
|
|
On 1/15/10 10:44 AM, Pascal Gelinas wrote:
> Robert M. Fuhrer wrote:
>> I'm working out how to test IDEs for IMP.
>>
>> My current question is how to access information pop-ups, like the
>> "Quick Outline" view in the JDT, accessible (on Mac OS) via Cmd-O.
>>
>> I tried the following:
>>
>> srcEditor.pressShortcut(Keystrokes.COMMAND, KeyStroke.getInstance("o"));
>> bot.waitUntil(Conditions.waitForShell(new BaseMatcher<Shell>() {
>> public boolean matches(Object item) {
>> return (item instanceof JavaOutlineInformationControl);
>> }
>> public void describeTo(Description description) {
>> description.appendText("Shell of type " +
>> JavaOutlineInformationControl.class);
>> }
>> }));
>> bot.tree().select("main(String[]) : void"); // hopefully gets the tree
>> in the 'quick outline' view
>>
>> but this doesn't work (times out, never finding the shell).
>>
>> [BTW, JavaOutlineInformationControl is the active shell for the "Quick
>> Outline" pop-up view, according to EclipseSpy.]
>>
>> This code runs when the variable 'srcEditor' refers to a Java source
>> editor, which presently has focus.
>>
>> N.B.: I don't actually see the pop-up appear, so presumably the Cmd-O
>> shortcut I'm trying to invoke just isn't working, as opposed to the
>> waitForShell() call being wrong.
>>
>> Any hints?
>>
>
> I suspect that it is effectively the pressShortcut call that doesn't
> work. I would suggest you try something like this:
>
> String commandId = IJavaEditorActionDefinitionIds.SHOW_OUTLINE;
> IWorkbenchPart part = srcEditor.getReference();
> IHandlerService adapter = (IHandlerService)
> part.getSite().getService(IHandlerService.class);
> Object commandResult = adapter.executeCommand(commandId, null);
>
> This little snippet shows how to activate a command programmatically.
> The only thing I am not sure about is the commandId, but I think it's
> the one you need in this case [1]. And make sure you run this inside the
> UI thread, with a syncExec().
>
> This should activate your pop-up, so watch the test execution to confirm.
Thanks!
I'll certainly try this out, but I'd really like to test that the shortcut
keystroke works as well. Is there any reason why the shortcut shouldn't
work?
--
Cheers,
-- Bob
--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center
IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
|
|
| | |
Goto Forum:
Current Time: Thu Apr 25 12:37:10 GMT 2024
Powered by FUDForum. Page generated in 0.03511 seconds
|