looking for suggesting to locate/interact with the context menu of a source editor [message #22843] |
Wed, 18 February 2009 15:47  |
Eclipse User |
|
|
|
Hello,
I am trying to interact with a context menu of a vertical ruler in a
source editor in Eclipse. I have discovered one way to open the context
menu but haven't yet successfully been able to interact with it. Below
is the snippet of code that actually opens the context menu.
SWTBotEclipseEditor actMainEditor = bot.editor("act_main.c");
actMainEditor.setFocus();
actMainEditor.navigateTo(64, 0);
// Open the context menu of the vertical ruler in the editor
actMainEditor.notifyKeyboardEvent(SWT.CTRL, (char)0, SWT.F10);
I have tried interacting with the focused widget which didn't work and
haven't been able to find the menu using SWTBot yet. Any suggestions?
Thanks,
Joe
|
|
|
|
|
Re: looking for suggesting to locate/interact with the context menu of a source editor [message #23144 is a reply to message #23016] |
Thu, 19 February 2009 12:47   |
Eclipse User |
|
|
|
Thanks for the responses (both Ketans). I quickly tried to use the
EventContextMenuFinder as suggested in JavaDoc documentation. No success
yet.
Has something changed with the SWTBotMenu constructors since the snippet
was written.
Example usage:
EventContextMenuFinder eventContextMenuFinder = new
EventContextMenuFinder();
try {
eventContextMenuFinder.register();
button.click(); // a popup menu appears below the button
SWTBotMenu menu = new SWTBotMenu(new Finder(new
ControlFinder(), eventContextMenuFinder), "Menu Text");
menu.click();
} finally {
eventContextMenuFinder.unregister();
}
I didn't see where SWTBotMenu takes a Finder in a constructor.
Thanks,
Joe
Ketan Padegaonkar wrote:
> Hi Joe,
>
> The vertical ruler is not supported in swtbot, please open a bug if
> you're interested in this support.
>
> Sending CTRL+F10 will definitely not help in finding the context menu
> unless you hook in the EventContextMenuFinder *before* the menu pops up.
>
> Note that at the moment chaining in context menus is not possible so you
> cannot do:
>
> editor.contextMenu("foo").menu("bar").click();
>
> so you'll just need to do:
>
> editor.contextMenu("bar").click();
>
> instead.
>
> -- Ketan
>
> On 19/2/09 02:17, Joe Luebker wrote:
>> Hello,
>>
>> I am trying to interact with a context menu of a vertical ruler in a
>> source editor in Eclipse. I have discovered one way to open the context
>> menu but haven't yet successfully been able to interact with it. Below
>> is the snippet of code that actually opens the context menu.
>>
>> SWTBotEclipseEditor actMainEditor = bot.editor("act_main.c");
>> actMainEditor.setFocus();
>> actMainEditor.navigateTo(64, 0);
>>
>> // Open the context menu of the vertical ruler in the editor
>> actMainEditor.notifyKeyboardEvent(SWT.CTRL, (char)0, SWT.F10);
>>
>>
>> I have tried interacting with the focused widget which didn't work and
>> haven't been able to find the menu using SWTBot yet. Any suggestions?
>>
>> Thanks,
>> Joe
>
|
|
|
Re: looking for suggesting to locate/interact with the context menu of a source editor [message #23272 is a reply to message #23144] |
Thu, 19 February 2009 14:08   |
Eclipse User |
|
|
|
Hi Joe,
The usages I see for EventContextMenuFinder are in
SWTBotToolbarDropDownButton#menuItem and SWTBotTrayItem#contextMenu
-- Ketan
Joe Luebker wrote:
> Thanks for the responses (both Ketans). I quickly tried to use the
> EventContextMenuFinder as suggested in JavaDoc documentation. No success
> yet.
>
> Has something changed with the SWTBotMenu constructors since the snippet
> was written.
>
> Example usage:
> EventContextMenuFinder eventContextMenuFinder = new
> EventContextMenuFinder();
> try {
> eventContextMenuFinder.register();
> button.click(); // a popup menu appears below the button
> SWTBotMenu menu = new SWTBotMenu(new Finder(new ControlFinder(),
> eventContextMenuFinder), "Menu Text");
> menu.click();
> } finally {
> eventContextMenuFinder.unregister();
> }
>
> I didn't see where SWTBotMenu takes a Finder in a constructor.
>
> Thanks,
> Joe
>
> Ketan Padegaonkar wrote:
>> Hi Joe,
>>
>> The vertical ruler is not supported in swtbot, please open a bug if
>> you're interested in this support.
>>
>> Sending CTRL+F10 will definitely not help in finding the context menu
>> unless you hook in the EventContextMenuFinder *before* the menu pops up.
>>
>> Note that at the moment chaining in context menus is not possible so
>> you cannot do:
>>
>> editor.contextMenu("foo").menu("bar").click();
>>
>> so you'll just need to do:
>>
>> editor.contextMenu("bar").click();
>>
>> instead.
>>
>> -- Ketan
>>
>> On 19/2/09 02:17, Joe Luebker wrote:
>>> Hello,
>>>
>>> I am trying to interact with a context menu of a vertical ruler in a
>>> source editor in Eclipse. I have discovered one way to open the context
>>> menu but haven't yet successfully been able to interact with it. Below
>>> is the snippet of code that actually opens the context menu.
>>>
>>> SWTBotEclipseEditor actMainEditor = bot.editor("act_main.c");
>>> actMainEditor.setFocus();
>>> actMainEditor.navigateTo(64, 0);
>>>
>>> // Open the context menu of the vertical ruler in the editor
>>> actMainEditor.notifyKeyboardEvent(SWT.CTRL, (char)0, SWT.F10);
>>>
>>>
>>> I have tried interacting with the focused widget which didn't work and
>>> haven't been able to find the menu using SWTBot yet. Any suggestions?
>>>
>>> Thanks,
>>> Joe
>>
|
|
|
|
Re: looking for suggesting to locate/interact with the context menu of a source editor [message #23458 is a reply to message #23272] |
Fri, 20 February 2009 15:47  |
Eclipse User |
|
|
|
Thanks again to both Ketans for their suggestions. I did find a way find
and interact with a menu item on the context menu of a vertical ruler. I
do have a follow up question. When I performed a click on a found menu
item the context menu did not close as it would during user interaction.
Is this a bug in SWTBot? As a workaround a set the visibility of the
parent of the menu item to false. See below for the code that finally
worked for me:
// Open the source editor vertical ruler context menu and find the
// "Add Breakpoint" menu item
EventContextMenuFinder eventContextMenuFinder = new
EventContextMenuFinder();
SWTBotMenu addBreakpointMenu = null;
try {
eventContextMenuFinder.register();
// Open the context menu of the vertical ruler in the editor
actMainEditor.notifyKeyboardEvent(SWT.CTRL,(char) 0, SWT.F10);
List<MenuItem> foundMenus = eventContextMenuFinder
..findMenus(withMnemonic("Add Breakpoint"));
// We only expect to find one "Add Breakpoint" // Menu item
if (foundMenus.isEmpty()) { fail("Failed to find the 'Add
Breakpoint' menu item");
}
addBreakpointMenu = new SWTBotMenu((MenuItem) foundMenus.get(0));
} finally {
eventContextMenuFinder.unregister();
}
// Click the Add Breakpoint menu item
addBreakpointMenu.click();
// Close the vertical ruler context menu
final SWTBotMenu menu = addBreakpointMenu;
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
menu.widget.getParent().setVisible(false);
} catch (Exception e) {
// Ignore
}
}
});
Ketan Padegaonkar wrote:
> Hi Joe,
>
> The usages I see for EventContextMenuFinder are in
> SWTBotToolbarDropDownButton#menuItem and SWTBotTrayItem#contextMenu
>
> -- Ketan
>
> Joe Luebker wrote:
>> Thanks for the responses (both Ketans). I quickly tried to use the
>> EventContextMenuFinder as suggested in JavaDoc documentation. No success
>> yet.
>>
>> Has something changed with the SWTBotMenu constructors since the snippet
>> was written.
>>
>> Example usage:
>> EventContextMenuFinder eventContextMenuFinder = new
>> EventContextMenuFinder();
>> try {
>> eventContextMenuFinder.register();
>> button.click(); // a popup menu appears below the button
>> SWTBotMenu menu = new SWTBotMenu(new Finder(new ControlFinder(),
>> eventContextMenuFinder), "Menu Text");
>> menu.click();
>> } finally {
>> eventContextMenuFinder.unregister();
>> }
>>
>> I didn't see where SWTBotMenu takes a Finder in a constructor.
>>
>> Thanks,
>> Joe
>>
>> Ketan Padegaonkar wrote:
>>> Hi Joe,
>>>
>>> The vertical ruler is not supported in swtbot, please open a bug if
>>> you're interested in this support.
>>>
>>> Sending CTRL+F10 will definitely not help in finding the context menu
>>> unless you hook in the EventContextMenuFinder *before* the menu pops up.
>>>
>>> Note that at the moment chaining in context menus is not possible so
>>> you cannot do:
>>>
>>> editor.contextMenu("foo").menu("bar").click();
>>>
>>> so you'll just need to do:
>>>
>>> editor.contextMenu("bar").click();
>>>
>>> instead.
>>>
>>> -- Ketan
>>>
>>> On 19/2/09 02:17, Joe Luebker wrote:
>>>> Hello,
>>>>
>>>> I am trying to interact with a context menu of a vertical ruler in a
>>>> source editor in Eclipse. I have discovered one way to open the context
>>>> menu but haven't yet successfully been able to interact with it. Below
>>>> is the snippet of code that actually opens the context menu.
>>>>
>>>> SWTBotEclipseEditor actMainEditor = bot.editor("act_main.c");
>>>> actMainEditor.setFocus();
>>>> actMainEditor.navigateTo(64, 0);
>>>>
>>>> // Open the context menu of the vertical ruler in the editor
>>>> actMainEditor.notifyKeyboardEvent(SWT.CTRL, (char)0, SWT.F10);
>>>>
>>>>
>>>> I have tried interacting with the focused widget which didn't work and
>>>> haven't been able to find the menu using SWTBot yet. Any suggestions?
>>>>
>>>> Thanks,
>>>> Joe
|
|
|
Powered by
FUDForum. Page generated in 0.04062 seconds