Vaadin GWT Widget Modification - gwt

I need to modify the GWT code of vaadin table widget. How do I begin ?. Where can I find the GWT code of the Table widget?
Thanks

Vaadin widgetset sources are included in the .jar file since gwt compiler needs java source code to generate javascript. Hence normally you can access sources in your IDE, for instance in Eclipse pushing F3 over a method o class name in your code.
In Vaadin, server components are bundled in vaadin-server.jar, and client widget implementations in vaadin-client.jar. You have original code available at https://github.com/vaadin/vaadin/
Normally the easier option for modifying a Vaadin widget is copying the code of the classes you want to modify in your project, using the same namespace, so the compiler will use them because of the classpath preference. Remember that you have to compile the widgetset each time you make modifications in client code.
But the recommended option is that you extends all the classes involved in that widget (server component, client classes) and use your own widgetset implementation. You have more info in the Book of Vaadin: https://vaadin.com/book/vaadin7/-/page/clientside.widget.html

Related

Is it possible to use mvp4g to create a library?

I'm creating a GWT application using mvp4g. As part of the application, I'm also creating a library in another gwt module; this library follows the mvp4g pattern, but here I'm creating everything by myself, Views, Presenters, Events, Handlers.
The library is used in different parts of the main application. Basically, the library gives a main widget which is configured depending on the section of the application, that's enabling features by adding other widgets (from the same library) to the main widget.
Also, the library is suposed to be used in other projects, therefore other widgets can be created and added to the main widget.
So, I'd like to know if there's a way to use mvp4g to create this library, or if mvp4g is only used for applications. Is there any other mvp library that allow to accomplish this?
Thanks in advance.
mvp4g allows you to follow a structured approach to developing with gwt code. It should be usable in a library project without entry point as easily as in project with entrypoint.
It is possible to create one or more client libraries and add them as dependencies to a webapp you are compiling using the GWT compiler.
See Dividing code into multiple modules, here:
https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects.
Maven or Gradle are good options for collecting, building and packaging your code into functional units.

GWT Designer, .ui.xml files

Question is about Google GWT Designer. GWT Designer can work with .java files without any .ui.xml files. But I have a gwt project where design is realized with .ui.xml files and java classes. It more complex then just java class. Do you heve any ideas what is it? May be it should be refactorized?
Thank you!
Firstly there's no need to refactor ready made UiBinder if it written well. This's a great GWT framework allowing separation of logic from view. If you reject it your project will be very difficult to maintain.
Secondly one and the same GWT project can contain the view implemented both in Java code and in UiBinder xml files. This situation occurs with a support of old projects where UiBinder wasn't yet. Uibinder is a much more modern approach which has many benefits. That is if you for some reason prefer declare view only in Java code without xml then write it in Java code. And this will coexist and work properly.
And most importantly present-day GWT Designer has support UiBinder. Otherwise, no one would use it.

Disable "Add Xtext nature" dialog in Eclipse

I'm using a custom DSL with Xtext grammar.
In my workspace there are several projects, one of them is the development relevant project, another one is for testing purposes.
In the testing project there are a lot (> 5000) of files of my DSL, required for JUnit tests.
When the Xtext nature is added to this project, rebuilding it takes a long time, so I removed it. It's not important to me in the project anyways.
But now everytime I open one of the files, Xtext asks me to add the nature to this project.
Can I disable this dialog, for a specific project or in general?
Thanks for answers!
I believe, the NatureAddingEditorCallback class is responsible for that feature.
To replace this functionality for your language, I would try the following:
Open the «LanguageName»UiModule class from your UI project (be careful, it is in the src folder; an abstract version is in the src-gen folder), and add the following lines (this piece of code came from the XtextUIModule class):
public Class<? extends IXtextEditorCallback> bindIXtextEditorCallback() {
return org.eclipse.xtext.builder.nature.NatureAddingEditorCallback.class;
}
Then replace the returned class with your own.

Unterstanding how Vaadin uses GWT

After playing around with Vaadin for about a week I'm curious about how Vaadin uses GWT. GWT compiles Javacode to Javascript. This has to be done everytime when you are redeploying.
Since Vaadin has to be understood as a server-centric framework, eliminating your flexibility on writing Code that is executed on Clientside and moving everything to the server (which sounds worse than it actually is), the GWT Compiler only runs once a time. For example this happens when you are importing a plugin from the vaadin website.
But it can't be that easy right? If it only would compile the code of the plugins to javascript this could have done before.
So, my question is:
When does VAADIN use the GWT Compiler and what does it do at that point other than compiling to js?
Basically you have it right, and mostly answered the question yourself.
In Vaadin the user interface components consist of two parts:
Server-side "component" compiled using JDK
Client-side "widget" compiled using GWT
These parts communicate with each other over HTTP and automatically synchronize their state as needed. Server-side part maintains the state of the user interface component and the client-side widget renders that state.
Application developers typically only use the server-side components to build the application and they don't really have to care about how the client-side works.
In general, new components to Vaadin can be developed in two ways:
Composing existing components
Creating a new widgets with GWT/JavaScript (+ other client-side tech)
The first method here uses the existing classes and don't need recompilation of the widgets with GWT. Only the application code is compiled (with JDK compiler). However, in the second scenario the client-side classes change and need recompilation. This is when the GWT compiler is needed.
Due to the rather monolithic nature of the GWT compiled JavaScript (regardless of new code splitting features of GWT the namespace is global) Vaadin uses the concept of widget set. That is a GWT module that contains all the widgets needed in the application. That means that adding new (client-side) widgets to an application a GWT recompilation is needed. It is also a good practice to recompile widget set when removing widgets to optimize the widget set size.
GWT compilation step itself is nothing special. However, Vaadin itself contains lot of additions, helpers and workaround to GWT classes that are applied and used by the widgets.
All this is quite visible when using Vaadin add-ons (see http://vaadin.com/directory). Even add-on are simply jar-files, if they contain a new client-side widget code, widget set compilation using GWT is needed, when they are added to a project.

cant find the create custom widget in the new project

i am new to vaadin and i have installed vaadin eclipse plugin and i cannot find the create custom widget in the File->New project->vaadin
and i cant find create themes etc ..as i see these things in the tutorial video and i cant find the visual editor also in the eclipse and i am using linux (operating system)
Check that you have installed the experimental visual editor like described on http://vaadin.com/eclipse. You can first create a Vaadin project from File->New project -> Vaadin project. You could also try to install the unstable version of the plugin from http://vaadin.com/eclipse/experimental (open URL with Eclipse plugin installer) if the stable one does not work.
Then you can check out the manual on http://vaadin.com/book/-/page/gwt.eclipse.html to get an idea of how to create a custom client side widget using GWT. This is practical if you wish to get some new client side behaviour not found in any existing widget(s).
However, if you just wish to have a new component without any new client side behaviour, you could extend the CustomComponent on the server side (in plain Vaadin, without making GWT components), add some custom logic and perhaps combine a number of existing components to be included. This composite CustomComponent can then be used in code as any other Vaadin component.