How to use GWT designer with Eclipse GWT plugin? - gwt

Sorry but I see no way to use it at all!
If I create GWT project with sample code, then SDK is generating a page with a HTML table where positions for sample TextBox-es and Button are already marked. So, if I open sample file with GWT designer and move button slightly down-right, I will get errors during run.
If I create GWT project without sample code, then GWT designer appears to be unable to open file with empty GUI.
Is there any way to design GUI from scratch or to see GWT designer usage sample?
Thanks

The problem is when you want GWT to create sample code for you, it puts the container parts of layout hard-coded in your projects html file. The generated sample uses RootPanel.get("someId").add(someWidget); to access these containers. When you open designer and move these widgets around, designer generates RootPanel.get("someId").add(someWidget,left,top); which doesn't work with this method.
On another note, when you want to create a class from scratch and open it with designer, you can simply add a reference to RootPanel to get around "this is not a gui class issue" such as :
public class SimpleClass {
RootPanel r = RootPanel.get();
public SimpleClass() {}
}

Related

Integrating EMF and view in plugin project

I created an EMF project and tested using <>.editor project generated by .genmodel file by creating a new project and a file through "Example EMF Model Creation Wizards". Is there any way that a view (in plugin project) can be created directly (probably project & file are automatically created when user runs the application)? I dont want the user to create these things. It should be automated and presented in a view.
In the .genmodel file, set .genmodel --> All ---> Runtime Platform to RCP. This creates an RCP app that does not use all the plugins of the IDE. If you want, you can generate your app to run in the IDE... However, for this answer I will simplify and assume you generated an RCP app. Go into the XXX.editor generated plugin, and into the .plugin file --> extensions. Add a new (org.eclipse.ui.views) View by declaring a new View extension -- see the Sample View for a template. Make sure to keep track of the ID you give this new View extension. Similarly add a new PerspectiveExtension extension. Add a reference to this new PerspectiveExtension with your unique View ID. In the View extension, click on the class link, this will create a skeleton ViewPart class. It is a good idea to put a public static final String YOUR_VIEW_ID = "com.yourplugin.ViewID" in that class.
This will get you started and if you added your new view to your perspective, it should be visible when running your EMF based RCP app.

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.

Gwt template file of panel

I am a new GWT developer, just do some coding practice on the MVP framework of GWT, I encounter a interesting problem with the ui template file,
WHen I use HtmlPanel as the root element for widgets in the template, everything show up after module is loaded.
this template works as expected, however if I remove the tag, using an absolutePanel instead nothing shows up,
can anyone tell what could cause the problem, thanks a lot.

Opening a new Window with a Widget in GWT

Before you start shooting me down i have checked for answers and i have googled till my fingers bled but i havent been able to find a simple, concise answer. So im asking again for all those that might have this problem.
Question: how to open a new window with a formpanel in side.
Context: i have an app that lists lots of items, i want someone to edit an entry, i want a new window to open so they can edit properties then hit save. A standard thing you find in a lot of applications.
Architecture:
I have one client module called UI, it has a dozen classes that draw widgets and fill a main area when selected from a menu. I have a single html page called UI.html which has the tag in the head. Thats it.
Options Ive Seen
Call Window.Open() but you need to define a html file. I dont have one. I can create an empty one but how do you inject a widget in to it ?
use jsni $wnd to create a new window and get a reference to it. But how do i inject a form panel into it ??
use a popuppanel. They look sucky - plus if opening a window through JS is quite simple i would expect it to be in gwt.
Maybe im miss understanding how to use GWT i dont know.
Any help would be appreciated
Thanks
The way i got this to work is as follows:
i wrote a jsni method to open a new window
public static native BodyElement getBodyElement() /*-{
var win = window.open("", "win", "width=940,height=400,status=1,resizeable=1,scrollbars=1"); // a window object
win.document.open("text/html", "replace");
i added a basic body to the new window and returned the body element
win.document.write("<HTML><HEAD>"+css1+css2+"</HEAD><BODY><div class=\"mainpanel\"><div style=\"width: 100%; height: 54px;\"><div id=\"mainbody\"class=\"mainbody\" style=\"width: 100%;\"></div></div></div></BODY></HTML>");
win.document.close();
win.focus();
return win.document.body;
}-*/;
i then called this method from my main java method
BodyElement bdElement = getBodyElement();
I then injected my panel which has lots of widgets into the returned body element
SystemConfiguration config = new SystemConfiguration(); bdElement.getOwnerDocument().getElementById("mainbody").appendChild(config.getElement());
I agree with Bogdan: Use a DialogBox.
If you can't, you Window.open() as you mentioned in option 1:
Create another GWT module, and form.html that will load it
Window.open("form.html?entry=54")
Have the form gwt module read from the URL, load the entry, allow it to be edited, and provide Save and Cancel buttons
Close the popup when Save or Cancel is clicked
Can't you just use a DialogBox?
Example

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.