Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » a question about view menu
a question about view menu [message #35838] Tue, 19 May 2009 13:41 Go to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
Hi one more time :-)

i have one more problem, this time with "view menu".
(I mean the small triangel in right corner of a view besides icons close
and minimize)
if i try to access the items of this menu with
bot.view("myView").toolbarButton("menuItem");
i get the NullPointerexception;
if i meke it with
bot.view("myView").menu("menuItem");
swtbot returns "WidgetNotFoundException"

How could i get the access to this menu?

Thanks a lot in advance!

Pavel.
Re: a question about view menu [message #35872 is a reply to message #35838] Tue, 19 May 2009 13:55 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
P.S.
If i try to get the List of toolbarButtons of a view with:
List tbb = this.bot.view("myView").getToolbarButtons();
a get also the NulPointerException! :-(
Re: a question about view menu [message #35939 is a reply to message #35838] Tue, 19 May 2009 18:27 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
It would be difficult to say what's wrong in this case, it could
possibly be a bug with swtbot or a menu using a contribution that swtbot
does not understand.

Could you try setting a breakpoint inside
ViewMenuFinder#getMenuItemsInternal and report what you find ?

Cheers!

-- Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr

On 19/5/09 19:11, Pavel Cybulskij wrote:
> Hi one more time :-)
>
> i have one more problem, this time with "view menu". (I mean the small
> triangel in right corner of a view besides icons close and minimize)
> if i try to access the items of this menu with
> bot.view("myView").toolbarButton("menuItem");
> i get the NullPointerexception;
> if i meke it with bot.view("myView").menu("menuItem");
> swtbot returns "WidgetNotFoundException"
>
> How could i get the access to this menu?
>
> Thanks a lot in advance!
>
> Pavel.
>
Re: a question about view menu [message #35973 is a reply to message #35939] Wed, 20 May 2009 09:31 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
Hi Ketan,

The break point in ViewMenuFinder#getMenuItemsInternal doesn't stop the
application. :-(
But i report the exception i get:

org.eclipse.swt.SWTException: Failed to execute runnable
(java.lang.NullPointerException)
at org.eclipse.swt.SWT.error(SWT.java:3777)
at org.eclipse.swt.SWT.error(SWT.java:3695)
at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.j ava:194)
at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchroniz er.java:150)
at org.eclipse.swt.widgets.Display.syncExec(Display.java:4251)
at
org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.run(U IThreadRunnable.java:74)
at
org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncE xec(UIThreadRunnable.java:159)
at
org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncE xec(UIThreadRunnable.java:142)
at
org.eclipse.swtbot.eclipse.finder.widgets.SWTBotWorkbenchPar t.getToolbarButtons(SWTBotWorkbenchPart.java:163)
at
org.eclipse.swtbot.eclipse.finder.widgets.SWTBotWorkbenchPar t.toolbarButton(SWTBotWorkbenchPart.java:193)
at
de.cenit.eb.sm.finca.gui.test.serverconfperspective.InitGuiT estsForPlugInDetailsView.testInitMenues(InitGuiTestsForPlugI nDetailsView.java:89)
at
org.eclipse.swtbot.swt.finder.SWTBotTestCase.runBare(SWTBotT estCase.java:228)
at
org.eclipse.swtbot.eclipse.junit4.headless.EclipseTestRunner .run(EclipseTestRunner.java:350)
at
org.eclipse.swtbot.eclipse.junit4.headless.EclipseTestRunner .run(EclipseTestRunner.java:208)
at
org.eclipse.swtbot.eclipse.junit4.headless.UITestApplication .runTests(UITestApplication.java:190)
at
org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:68)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at
org.eclipse.swtbot.eclipse.finder.widgets.SWTBotWorkbenchPar t$3.run(SWTBotWorkbenchPart.java:170)
at
org.eclipse.swtbot.eclipse.finder.widgets.SWTBotWorkbenchPar t$3.run(SWTBotWorkbenchPart.java:1)
at
org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$2.doR un(UIThreadRunnable.java:157)
at
org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$1.run (UIThreadRunnable.java:87)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:133)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3800)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3425)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at de.cenit.eb.sm.finca.gui.application.Application.start(Unkno wn Source)
at
org.eclipse.swtbot.eclipse.junit4.headless.UITestApplication .runApplication(UITestApplication.java:135)
at
org.eclipse.swtbot.eclipse.junit4.headless.UITestApplication .run(UITestApplication.java:61)
at
org.eclipse.swtbot.eclipse.junit4.headless.UITestApplication .start(UITestApplication.java:203)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)



Ketan Padegaonkar wrote:

> It would be difficult to say what's wrong in this case, it could
> possibly be a bug with swtbot or a menu using a contribution that swtbot
> does not understand.

> Could you try setting a breakpoint inside
> ViewMenuFinder#getMenuItemsInternal and report what you find ?

> Cheers!

> -- Ketan
> http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
Re: a question about view menu [message #36006 is a reply to message #35973] Wed, 20 May 2009 23:29 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
This is the place you need to start...

SWTBotWorkbenchPart.java:170

It seems like the "part" you are working with does not have any toolbar
attached:

ViewPane obj = (ViewPane) ((WorkbenchPartReference)
partReference).getPane();
ToolBar toolbar = (ToolBar) obj.getToolBar();

List<SWTBotToolbarButton> l = new ArrayList<SWTBotToolbarButton>();
ToolItem[] items = toolbar.getItems(); // Error seems to be here...means
obj.getToolBar() is returning null.
Re: a question about view menu [message #36960 is a reply to message #36006] Wed, 27 May 2009 08:00 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
ok, no toolbar ...
but the question still remains: how can i get an access to the items in
"triangle"-pulldown-menu? (i have it definitely) :-)

Ketan Patel wrote:

> This is the place you need to start...

> SWTBotWorkbenchPart.java:170

> It seems like the "part" you are working with does not have any toolbar
> attached:

> ViewPane obj = (ViewPane) ((WorkbenchPartReference)
> partReference).getPane();
> ToolBar toolbar = (ToolBar) obj.getToolBar();

> List<SWTBotToolbarButton> l = new ArrayList<SWTBotToolbarButton>();
> ToolItem[] items = toolbar.getItems(); // Error seems to be here...means
> obj.getToolBar() is returning null.
Re: a question about view menu [message #37364 is a reply to message #36960] Fri, 29 May 2009 06:52 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 27/5/09 13:30, Pavel Cybulskij wrote:
> ok, no toolbar ...
> but the question still remains: how can i get an access to the items in
> "triangle"-pulldown-menu? (i have it definitely) :-)

Most tests for view menus and tool bars are documented in a test[1].

If this does not work for you you may need to set a breakpoint in
ViewMenuFinder#getMenuItemsInternal or SWTBotWorkbenchPart#toolbarButton

In case you're still unable to find the item you're looking for please
file a bug with instructions on how I can reproduce the issue.

[1] -
http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbo t.eclipse.finder.test/src/org/eclipse/swtbot/eclipse/finder/ widgets/SWTBotViewTest.java

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
Re: a question about view menu [message #551279 is a reply to message #37364] Thu, 05 August 2010 19:16 Go to previous messageGo to next message
Marko Tomljenovic is currently offline Marko TomljenovicFriend
Messages: 62
Registered: July 2009
Member
It is easily reproducible:

1. Execute a file search in Eclipse.
2. In the search result window try to click on "Show as List" or "Show as Tree"
3. The menu can't be found

I think it is mainly because in class ViewMenuFinder only ActionContributionItems are considered and not also SubContributionItems (which internally contain an ActionContributionItem).

Here the proposed code for class ViewMenuFinder:
	// This is expected to be called from within the UI thread. If not it will
	// throw exceptions based on invalid thread access.
	private List<SWTBotViewMenu> getMenuItemsInternal(
			IContributionItem[] items, Matcher<?> matcher, boolean recursive) {
		List<SWTBotViewMenu> l = new ArrayList<SWTBotViewMenu>();

		for (int i = 0; i < items.length; i++) {
			IContributionItem item = items[i];

			try {
				if ((item instanceof MenuManager) && recursive) {
					// Sub menus
					MenuManager menuManager = (MenuManager) item;

					l.addAll(getMenuItemsInternal(menuManager.getItems(),
							matcher, recursive));
				} else if (item instanceof ActionContributionItem) {
					// Menus
					ActionContributionItem actionContribution = (ActionContributionItem) item;

					if (matcher.matches(actionContribution.getAction()))
						l.add(new SWTBotViewMenu(actionContribution));
				}
				// ADDED CODE PART - START
				else if (item instanceof SubContributionItem) {
					SubContributionItem subContribItem = (SubContributionItem) item;
					if (subContribItem.getInnerItem() instanceof ActionContributionItem) {
						ActionContributionItem actionContribution = (ActionContributionItem) item;

						if (matcher.matches(actionContribution.getAction()))
							l.add(new SWTBotViewMenu(actionContribution));
					}
				}
				// ADDED CODE PART - END
			} catch (WidgetNotFoundException e) {
				log.warn(e);
			}
		}

		return l;
	}


Re: a question about view menu [message #551591 is a reply to message #551279] Sat, 07 August 2010 17:06 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
On 10-08-05 03:16 PM, Marko Tomljenovic wrote:
> It is easily reproducible:
>
> 1. Execute a file search in Eclipse.
> 2. In the search result window try to click on "Show as List" or "Show
> as Tree"
> 3. The menu can't be found
>
> I think it is mainly because in class ViewMenuFinder only
> ActionContributionItems are considered and not also SubContributionItems
> (which internally contain an ActionContributionItem).
>
> Here the proposed code for class ViewMenuFinder:
>
> // This is expected to be called from within the UI thread. If not it will
> // throw exceptions based on invalid thread access.
> private List<SWTBotViewMenu> getMenuItemsInternal(
> IContributionItem[] items, Matcher<?> matcher, boolean recursive) {
> List<SWTBotViewMenu> l = new ArrayList<SWTBotViewMenu>();
>
> for (int i = 0; i < items.length; i++) {
> IContributionItem item = items[i];
>
> try {
> if ((item instanceof MenuManager) && recursive) {
> // Sub menus
> MenuManager menuManager = (MenuManager) item;
>
> l.addAll(getMenuItemsInternal(menuManager.getItems(),
> matcher, recursive));
> } else if (item instanceof ActionContributionItem) {
> // Menus
> ActionContributionItem actionContribution = (ActionContributionItem) item;
>
> if (matcher.matches(actionContribution.getAction()))
> l.add(new SWTBotViewMenu(actionContribution));
> }
> // ADDED CODE PART - START
> else if (item instanceof SubContributionItem) {
> SubContributionItem subContribItem = (SubContributionItem) item;
> if (subContribItem.getInnerItem() instanceof ActionContributionItem) {
> ActionContributionItem actionContribution = (ActionContributionItem) item;
>
> if (matcher.matches(actionContribution.getAction()))
> l.add(new SWTBotViewMenu(actionContribution));
> }
> }
> // ADDED CODE PART - END
> } catch (WidgetNotFoundException e) {
> log.warn(e);
> }
> }
>
> return l;
> }
>
>
>

This sounds more like a bug report then a user question... please file a
bug report on the project's bugzilla and attach a patch so that someone
can take a look at it. See also the contributing FAQ [1] for general
information.

[1] http://wiki.eclipse.org/SWTBot/Contributing
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: a question about view menu [message #657384 is a reply to message #35838] Wed, 02 March 2011 16:09 Go to previous message
Jon Lai is currently offline Jon LaiFriend
Messages: 1
Registered: March 2011
Junior Member
Was there a fix or a solution to this? I'm also looking to access the View Menu and have not been able to do this successfully.

Thanks!
Previous Topic:Future of SWTBot
Next Topic:How to access toolbar buttons of an Eclipse editor?
Goto Forum:
  


Current Time: Thu Apr 25 08:30:17 GMT 2024

Powered by FUDForum. Page generated in 0.04076 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top