Intellij doesn't attach standard.css from GWT - gwt

I generated Sample Application using Intellij 14, but standard.css is missing both in generated artifact and when I run super dev mode configuration.
As a result of missing standard css, all widgets look ugly or will not be shown at all.
Did I configure something the wrong way or is it a bug?

standard.css is part of one of the four themes coming with the GWT SDK, and is only included if the theme-specific module is inherited by your module.
You need to add:
<inherits name='com.google.gwt.user.theme.standard.Standard' />
to your module to apply the "standard" theme, or possibly:
<inherits name='com.google.gwt.user.theme.standard.StandardResources' />
if you include the standard.css by your own means (using a <link> tag in your HTML host page, or the StyleInjector; i.e. this module will only copy the files to the output without applying them)
See also: http://www.gwtproject.org/doc/latest/tutorial/style.html#GWTtheme

Related

How to specify additional source folders for GWT project with Google Eclipse plugin?

My GWT project has all code in the src folder. But now I have some additional generated code which goes into a new generated folder. I have configured my Eclipse to use this additional folder, which works fine. But when I start the GWT server, the generated code is not available for the GWT client.
On my older projects (without Google Plugin), I was starting GWT with a custom Eclipse launcher configuration. There I could specify additional source folders by adding an additional <runtimeClasspathEntry> to the launcher XML file.
Additional source paths are also allowed for com.google.gwt.dev.Compiler in Ant.
But how to specify additional source folders when using the Google Eclipse Plugin?
If the GPE doesn't automatically update the launch configuration, you can still update it yourself, adding the generated folder to the classpath.
Simply try to add it in source as shown below to add it in build path of the project.
click on Add Folder... to add the generated folder on build path.
If it doesn't work the go to -> Libraries -> Add Class Folder...
Add entries in your gwt.xml to make it available for client side code as shown below
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- path related to root of GWT project similar to client and shared folder-->
<source path='generated_folder' />

What happens when the gwt.xml does not have <source> tags in it?

What is the default behaviour of the gwt java2js compiler if i do not specify in my gwt.xml something like <source path='insertname4folder'/> . I have seen some multi-module projects that do not use these tags and i can only tell that a class will be translated only because it is in a X.client.Y package; i assume the j2js compiler uses that convention by default too?
It assumes the default folder as named "client" which is parallel to module.gwt.xml file.
Example:
Location of module xml file - com.insanity.examples.gwt.HelloWorld.gwt.xml
Location of default gwt client code - com.insanity.examples.gwt.client
That is as good as having tag in the .gwt.xml file.
You can read more about it here - http://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html#DevGuideModules

SpiffyUI: help configuring existing GWT project; in particular, how exactly is spiffyui.min.js being found?

I feel as if I must be missing something obvious here. The Getting
Started page here http://www.spiffyui.org/?getStarted
says, among other things:
Add the Spiffy project dependency You can have Spiffy automatically downloaded through a Nexus server, or you can manually download JARs
from our downloads page. . . . .
Ok, I just use Apache Ant the way it was configured by the GWT
project generator. I downloaded the two .jar files and told the
build.xml file to copy them into war/WEB-INF/lib when I build.
(also setting spiffyui.sdk at the top)
<!-- Add any additional server libs that need to be copied -->
<copy todir="war/WEB-INF/lib" file="${spiffyui.sdk}/spiffyui-0.7.8.jar" />
<copy todir="war/WEB-INF/lib" file="${spiffyui.sdk}/spiffytasks-0.7.8.jar" />
Reference Spiffy in your HTML Now the CSS and JavaScript files are included in your project when you build. The next step is to reference
them in your HTML file. The Spiffy UI framework includes many
JavaScript and CSS files, but they are all combined into two files for
faster application loading. Reference this one file and the JQuery
library in the head section of your HTML files like this:
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="spiffyui.min.js"></script>
...
</head>
Ok, done.
Import Spiffy in your GWT module The last step is to import the Spiffy UI framework GWT module. Add the following line to your GWT
module file:
<inherits name="org.spiffyui.spiffyui" />
Ok, done
That's all it takes.
Really?
So now I am serving html file that refers to spiffyui.min.js as a
local file. It seems to me that I should tell my web server to serve
that file. I could not figure out where I was supposed to get that
file until I looked in the .jar files and found org/spiffyui/public/js/
spiffyui.js . Hmm, well maybe these Java web containers automatically
look for files down in the .jar libraries and serve them??! Sounds
odd, but ok.
I tried running under dev mode and then I manually went to the URL
that the script tag src property should imply:
http://127.0.0.1:8888/spiffyui.min.js
result: 404 Not found
maybe I need to special modified URL for dev mode?:
http://127.0.0.1:8888/spiffyui.min.js?gwt.codesvr=127.0.0.1:9997
result: nope, 404 Not found
What am I missing here?
The magic you're missing is the GWT compiler. When you add the module dependency to your GWT project for Spiffy UI you're giving the framework a chance to be part of your projects complication. Part of that means it will copy the spiffyui.min.js file out of the JAR files and into to the same directory in your project output as the rest of your GWT code.
Once the file is copied out the reference you added to your HTML file works because it can pick up spiffyui.min.js with a relative URL. Once the JavaScript loads Spiffy UI can import CSS and anything else it needs to make the framework run.
I hope this helps,
Zack

How do I compile a module without an EntryPoint?

I have a utility module for GWT which doesn't have an UI (hence, there is no class which inherits from com.google.gwt.core.client.EntryPoint. When I try to compile this module with GWT 1.7.1, I get this error:
[ERROR] Module has no entry points defined
How do I get rid of this error? Do I really have to define a dummy entry point? How did Google ever compile their own utility modules???
Utility Jars do not need to be compiled by GWT.
If you just want to reuse this as a library in other GWT applications then you just have to jar the .class and .java files in one jar and make sure that you have a .gwt.xml that says where the client source is. If you follow the conventions (client classes in client) then you can get away with just otherwise you need to specify a tag for the client package
Then make sure that you inherit this .gwt.xml in the projects where you want to compile an entry point.
No you don't need an EntryPoint. Here is an example of one of my modules that doesn't have one:
<?xml version="1.0" encoding="UTF-8"?>
<module>
<source path="grid" />
<inherits name="com.google.gwt.user.User"/>
</module>
The short answer is you don't compile code in modules. GWT just needs them as source code. When you compile your main module (the one with the entry point) it uses the source from any other modules you have inherited in your .gwt.xml file to compile the entire project.
I'm using the gwt-maven-plugin Maven2 plugin to compile my code. I migrated the code from an old version of the maven-googlewebtoolkit2-plugin plugin. For the old plugin, I had to specify which modules were entry points like so:
<compileTargets>
<param>com.project.module.Module</param>
</compileTargets>
For the new plugin, it's
<module>com.project.module.Module</module>
Since the plugin couldn't find which modules to compile, it search for "*.gwt.xml" and compiled all of them into "UI modules" (which must have an entry point).
We've got a utilities module, which constructs & handles some common UI elements, and a bunch of javascript/json common tasks.
It looks like what we did (also migrated from the totsp plugin to the codehaus plugin somewhere along the line) was to include an entry point in the util module; it was just empty. (It includes the comment "Intentional no-op").
Then the pom just refers to the thing as a dependency.
If using eclipse GWT plugin just remove the module without an EntryPoint from the moduleslist that pops up just before compiling.

Eclipse 3.4 GWT 1.6 project - how to reference source from other projects?

I've got a GWT 1.6 project in Eclipse 3.4 and am trying to reference source from another (non-GWT) project in my workspace. I've added the project to my build path, but I can't run the application in hosted mode. When I do, I get a "no source code is available" error.
I've done some searching and reading and have tried a few things that others have suggested (including creating a jar from the dependent project and linking to it), but frankly nothing has worked.
If you're actually doing this, could you please help me out with a simple step-by-step setup? I'd really appreciate it, thanks!
I have 2 Eclipse Projects. One is gwt project and one is not. Here's the directory structure that works for me:
workspace
-- gwt-project
-- src/main/java
-- com.gwt.GwtProjectModule
-- GwtProjectModule.gwt.xml
-- non-gwt-project
-- src/main/java
-- com.nongwt.package.that.contains.source.you.need
-- nongwt.gwt.xml
-- com.nongwt.package.that.contains.source.you.need.client
nongwt.gwt.xml tells gwt to look inside "client" package, here's what it looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='nongwt'>
<inherits name='com.google.gwt.user.User' />
<source path="client" />
</module>
GwtProjectModule.gwt.xml can then inherit source code from nongwt. Here's the relevant line from inside GwtProjectModule.gwt.xml:
<inherits name="com.nongwt.package.that.contains.source.you.need.nongwt" />
Make sure you include non-gwt-project inside gwt-project's classpath in eclipse. It's the normal drill; right click on gwt-project, choose properties, choose "Java Build Path", click "Projects" tab, and "non-gwt-project"
Or, instead of including non-gwt-project in gwt-project's classpath as a project reference, you can also jar the contents of non-gwt--project, ensure that you include the source in the jar, and then include the jar in gwt-project's classpath.
Good Luck!
I know this post is quite old but as I spent quite a lot of time on this issue and finally found the way to do it, I thought I might share the answer :
once you've created your launch configuration, open it run>run configurations...
go to classpath tab and select user entries. add advanced>folder and select the source folder of your other module project. If as me you've separated the module conf file in a src/main/resources folder you have to add it as well.
should work.
The client-side code in your GWT project (the classes under the client package) can't reference any classes that aren't in a GWT module.
If you've got code in another project that you want to reference from client code in your GWT project, you need to:
Make sure it's all "GWT safe", which means it doesn't reference any JRE classes that aren't emulated by GWT (http://code.google.com/webtoolkit/doc/1.6/RefJreEmulation.html), or reference any classes that reference JRE classes not emulated
Make sure all referenced classes are within a GWT module. This means putting a MyOtherProject.gwt.xml file in your other project, and all the referenced classes must be under a client subpackage
Make your GWT project inherit from the other project. So add the following to your GWT project's gwt.xml module file:
<inherits name='com.yourCompany.otherProject.MyOtherProject' />
Boden: add the following to your module file
<source path=""></source>
in addition to your other sources, eg:
<source path=""></source>
<source path="com.acme.otherpackage"></source>
then the compiler won't complain.
Atleast that's how I solved it. Not sure if using path="" allows inclusion of everything, I'm assuming it's the default value when no sources are specified.
This is a fantastic solution of your problem proposed by Sven Buschbeck (must a norwegian, lol!), worked for me!
When work­ing on sev­eral large scale projects (in Eclipse), it’s con­ve­nient and of course more effi­cient to share and reuse code via com­mon libraries. While those are in an early stage they need to be changed a lot and there­fore it’s handy to link projects in instead of cre­at­ing new jars each time the library has been updated.
Unfor­tu­nately, this stan­dard approach for Java devel­op­ment in Eclipse does not work that straight for­ward as with plain old Java projects, it requires three steps in total:
Link the library project to all rel­e­vant projects (“Project
Pref­er­ences” -> “Java Build Path” -> “Projects” -> “Add…”)
Then, add the client-side code of the library (by adding it as a
mod­ule.) There­fore, edit the gwt.xml of your appli­ca­tion and add
for exam­ple
where Super­Lib is the file name of the gwt.xml file in you library
project and before that is the pack­age it lies in.
Add the code to the project by link­ing a source folder.
Unfor­tu­nately, this is required if you do not want to write an Ant
script to com­pile your appli­ca­tion. (If you pre­fer Ant check
this out) I don’t like the idea of using such a script because if
you for­get to run it each time you make changes, you will end up in
confusion—let’s go for the con­ve­nient, auto­matic way then.
Add a folder to your appli­ca­tion project; open the “advanced” sec­tion in the folder cre­ation dia­log, select “Link to alter­nate loca­tion” and pick the source folder (usu­ally “src”) of your library project. (Hint: if you work within a team using a ver­sion­ing sys­tem, you can cre­ate a vari­able for that folder and use this instead. This way, each of your col­leagues can put the library project in a dif­fer­ent folder and accom­mo­date for that by adjust­ing the vari­able :) )
Right click the folder, “Build Path” -> “Use as Source Folder”. Done.
Sur­pris­ingly, the GWT plu­gin for Eclipse does not honor the project link­ing, thus all the ref­er­ences need to be made explicit or you will end up with lots of the fol­low­ing: ClassNotFoundException.
GWT doesn't know about that other code because it is not in the client directory of your project. You need to add the source path for the other code to the .gwt.xml file. Just added it to the xml as follows
<source path="common" />
common is the directory where the extra code is for this example.
Check out the XML Element Reference section of this doc
In your gwt project, go to properties, Java build path, source, click "link source" and point to your non-gwt project source package that you wish to include.
Edit: Found a eclipse fix. Run config > Classpath > Advanced > Add folder > otherproject/src .
Reason: Eclipse adds the bin folders of exported projects. GWT needs the src folders.
Elaborating on my comment.
I am using gwt 2.8 on Eclipse Neon, Java 1.8.0_92. Referring to another project in eclipse fails to launch devmode, because it cannot find the source for referred files from the other project.
What worked:
Switched to 'ant devmode' completely. Made the following changes to build.xml:
<target name="gwtc" ...>
<java ...>
<classpath>
<pathelement location="src"/>
<pathelement location="../otherproject/src"/><!-- Added -->
...
...
<target name="devmode" ...>
<java ...>
<classpath>
<pathelement location="src"/>
<pathelement location="../otherproject/src"/><!-- Added -->
Now do a production build with 'ant' or start devmode with 'ant devmode'.
Other things I noticed
Using the method in the accepted answer, otherproject/src/foo.gwt.xml is picked up (complains if not available), and static values from classes are picked up. Nothing else is. Very weird.
I understand that the DevMode/gwtc executables pick up sources from their class path. So all that is needed is for eclipse to add referred projects to their class path. I was not able to achieve this but this seems possible. FIXED see top.