WebDriver GWT TabPanel Issue - gwt

I'm trying to create a WebDriver Test for a GWT application which uses a TabPanel. Clicking on a tab works fine in the IDE (it uses the x-path to find the tab) however I cannot get the tab click working in the JUnit test.
All elements have a debugID including the Tabs (although tab id's do not appear to work even in the IDE) and I'm inheriting com.google.gwt.user.Debug. I've attempted to locate by Xpath which is the IDE default.
genericElement.findElement(By.xpath("//div[#id='gwt-debug-mainTabPanel']/div[2]/div/div[6]/div/div")
I've tried the code outlined in the documentation
genericElement.findElement(By.id("gwt-debug-mainTabPanel-bar-tab6")
I've also attempted a moveToelement(as clickAt is no longer supported) and click but that falls over too(unless I'm misunderstanding it). I'd also like to avoid this as it seems bad practice.
Actions builder = new Actions(driver);
genericElement = driver.findElement(By.id("gwt-debug-mainTabPanel"));
Action action = builder.moveToElement(genericElement,400, 370).click().build();
action.perform();
java.lang.UnsupportedOperationException: Moving to arbitrary X,Y
coordinates not supported.
I know GWT and Webdriver aren't getting along too well - but I feel like this will have a solution. Can anyone offer any help - has anyone implemented a working Webdriver test in which they click a tab in a GWT TabPanel?
EDIT
I've managed to locate the node using Firebug and xpath locators ( you can add /..to move to the parent gwt-TabLayoutPanelTabInner or add /../.. to mover to grandparent gwt-TabLayoutPanelTabInner and it should still work - it does in the IDE)
genericElement = driver.findElement(By.xpath("//div[contains(#class,'gwt-HTML') and contains(text(),'Users')]"));
However not the click doesn't change to the required tab - seems to be a known issue (likely don't need both moveToElement and click(genericElement) - hust giving it a shot)
Actions builder = new Actions(driver);
builder.moveToElement(genericElement).click(genericElement).build().perform();
See section 3 ....This is fun :)

Related

How to access the view of another plugin in Eclipse?

I'm developing an Eclipse plugin / extension of another plugin. For this I need to access the information displayed in a view by the other plugin.
Is there a way to accomplish this? I've only found how to do this if the view I want to access is created by the plugin I am currently developing
(using workbench.getActiveWorkbenchWindow().getActivePage().findView(MyView.ID);)
but this doesn't seem to be suitable in my situation as I do not know the ID of the view and do not have the MyView object.
Edit: The view contains a table with Strings / ints which I need. I guess it's also important to note that I have parts the source code of the other plugin available, so the class of the view.
Edit2: Because I have the source code of the other plugin, I was able to solve this - see comments.

How can I only display projects inside a treeviewer eclipse plugin?

I am making a tree viewer in Eclipse which would be used to pick a project and then I would find out the location of the project and zip it up.
I can currently display a tree which shows all the projects but it also allows you to expand the tree.
I am doing this in a wizard so I am unable to any dialogs.
I think I would need a filter but after using Google for a while I was unable to figure out how I could do this.
This is how I am currently making the viewer.
TreeViewer view = new TreeViewer(composite,new WorkbenchLabelProvider(),new BaseWorkbenchContentProvider());
view.setInput(ResourcesPlugin.getWorkspace().getRoot());
It's showing you exactly what that content provider is written to show.
The short answer is to setInput(ResourcesPlugin.getWorkspace().getRoot().getProjects()) and use the ArrayContentProvider with a ListViewer rather than the TableViewer.
The long answer is that the content provider you were using returns both the top level elements for the tree control using getElements() and any resource's children via getChildren(), and your case is not interested in the results of getChildren().
Projects are never nested so you only really need a TableViewer to show them. You can get the list of projects using:
IProject [] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
The same label provider will work.

Toolbar items dynamically

I need to create dynamically buttons in main toolbar. I found a solution, but I can create just one button (dynamic contribution item - class extending ContributionItem). But I need to create more than one button, but I cannot find the solution.
I'm fighting with task to create plugin, which parses a XML file containing structure of menu and toolbars. We've already done this plugin for Visual Studio. Its quite easy in principle, but I found swiftly, that not for Eclipse. There is one small but critical otherness. Plugins are implemented declaratively in Eclipse. The file plugin.xml is the gist of plugin's infrastructure, Java code is just ancillary.
The customer wants to refresh the menu and toolbar whenever the selected project is changed. Eclipse lacks several features needed to get the task done. Main menu and main toolbar are cteated at Eclipse's start-up and then they can be hardly rebuilt.
In the most cases the conditions defined at enabledWhen/visibleWhen elements are sufficient to filter contributions according to the context (active part, selected object, whatever else).
If you need to have more freedom, please try E4 ToolControl that allows you to implement your own UI elements:
#PostConstruct
public void createControls(Composite parent) {
//your custom code here
}
More details here https://www.vogella.com/tutorials/EclipseRCP/article.html#toolcontrols
From my understanding you want to have different buttons on the main toolbar depending on the selection of the project explorer (eg. 1 project is java project, the other is javascript etc.). First you will have to contribute to the main toolbar. I think there are some tutorial available so google will help.
The main steps are:
1. create a command (org.eclipse.ui.commmands)
2. create a handler (org.eclipse.ui.handlers) with the previously declared command id
3. contribute to the main toolbar (org.eclipse.ui.menus) with menucontribution and commandId with the following locationURI: toolbar:org.eclipse.ui.main.toolbar?after=misc
showing/hiding, enabling/disabling a menu item/button also can be done declaratively or "mixed". Declaratively means eg. using enabledWhen/visibleWhen...
Mixed means using property tester (org.eclipse.core.expressions.propertyTester). With this you can define your "enablement logic" in Java code.
In Eclipse e4 the UI is generated from a, EMF based, model. The Application.e4xmi serves as a base for that model. Contributions to the model can be done via fragments, which are again XML, or via processors. Processors are written in Java and use e4 services, like the part service, to modify the model at runtime.
I think you want to write a processor that parses your custom XML and modifies the eclipse e4 model accordingly.

Make Eclipse RCP Intro part of a perspective

For a product we are creating, we want to be able to have the welcome screen display in a perspective (which we are calling "Start Here"). The intro is the only thing that needs to be in that perspective, however, when I try to add our intro view to the perspective, it says that the view already exists in the layout.
I have tried programmatically closing the intro, messing around with standby mode etc but I cant get it working.
The intro is an XHTML one and we use internal Eclipse "action links" (e.g. http://org.eclipse...?runAction etc) extensively (hence the reason that we need to use the intro framework.
Does anyone have any ideas as to how I could get it added to a perspective, or at the very least get the intro fully maximised when you select a specific perspective (using the "showIntro" method results in it displaying oddly, bunched to one side).
Thanks!
Intro view is a sticky view, so its placeholder is created by default to every perspective, to the right of editor area. There's no public API to remove a placeholder once it is created and when you try to create one you get the error that it already exists.
You can maximize Intro view like this:
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.setPartState(page.findViewReference("org.eclipse.ui.internal.introview"),
IWorkbenchPage.STATE_MAXIMIZED);
This should probably be done in IPerspectiveListener.perspectiveChanged() rather than in perspective factory.
Instead of adding the view to the perspective, call IIntroManager.showIntro() or WorkbenchWindowAdvisor.openIntro()

SmartGWT Widgets not displaying properly

I have a basic GWT Maven project going. I added SmartGWT and started playing around with some widgets and nothing displays correctly. The ListGrid seems to somewhat render but things are off and even data isnt showing up (though the rows respond to indicate there is data within the row). Sorting arrows dont appear but are clickable, and filters are wildy off. Whats causing this. I deleted everything in the .css file.
GWT newbie here.
Did you add the following to your host html file?
var isomorphicDir = "MODULE_NAME/sc/";
where MODULE_NAME is the name of your GWT module. ie the name you have in your GWT module xml file.
See http://forums.smartclient.com/showthread.php?t=8159#aImages
fyi the next release of Smart GWT will no longer require users to add the isomorphicDir variable to the host html file.