* appropriate monkey code for gwt directly in annotation processor and get rid
* of {@link WidgetMapGenerator}. Using annotation processor might be a good
* idea when dropping Java 1.5 support (integrated to javac in 6).
- *
+ *
*/
public class ClassPathExplorer {
private final static FileFilter DIRECTORIES_ONLY = new FileFilter() {
/**
* Finds available widgetset names.
- *
+ *
* @return
*/
- public static Collection<String> getAvailableWidgetSets() {
- Collection<String> widgetsets = new HashSet<String>();
+ public static Map<String, URL> getAvailableWidgetSets() {
+ Map<String, URL> widgetsets = new HashMap<String, URL>();
Set<URL> keySet = classpathLocations.keySet();
for (URL url : keySet) {
searchForWidgetSets(url, widgetsets);
}
private static void searchForWidgetSets(URL location,
- Collection<String> widgetsets) {
+ Map<String, URL> widgetsets) {
File directory = new File(location.getFile());
files[i].length() - 8);
classname = classpathLocations.get(location) + "."
+ classname;
- widgetsets.add(classname);
+ widgetsets.put(classname, location);
}
}
} else {
for (int i = 0; i < widgetsetNames.length; i++) {
String widgetsetname = widgetsetNames[i].trim()
.intern();
- widgetsets.add(widgetsetname);
+ widgetsets.put(widgetsetname, location);
}
}
}
/**
* Recursively add subdirectories and jar files to classpathlocations
- *
+ *
* @param name
* @param file
* @param locations
System.out.println();
System.out.println("Searching available widgetsets...");
- Collection<String> availableWidgetSets = ClassPathExplorer
+ Map<String, URL> availableWidgetSets = ClassPathExplorer
.getAvailableWidgetSets();
- for (String string : availableWidgetSets) {
- System.out.println(string);
+ for (String string : availableWidgetSets.keySet()) {
+ System.out.println(string + " in "
+ + availableWidgetSets.get(string));
}
}
}
\ No newline at end of file
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.Reader;
+import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
printUsage();
} else {
String widgetsetname = args[0];
- String sourcepath = args[1];
- updateWidgetSet(widgetsetname, sourcepath);
+ updateWidgetSet(widgetsetname);
}
}
- public static void updateWidgetSet(final String widgetset, String sourcepath)
+ public static void updateWidgetSet(final String widgetset)
throws IOException, FileNotFoundException {
boolean changed = false;
- String widgetsetfilename = sourcepath + "/"
+
+ Map<String, URL> availableWidgetSets = ClassPathExplorer
+ .getAvailableWidgetSets();
+
+ URL sourceUrl = availableWidgetSets.get(widgetset);
+
+ String widgetsetfilename = sourceUrl.getFile() + "/"
+ widgetset.replace(".", "/") + ".gwt.xml";
File widgetsetFile = new File(widgetsetfilename);
if (!widgetsetFile.exists()) {
Collection<String> oldInheritedWidgetsets = getCurrentWidgetSets(content);
- Collection<String> availableWidgetSets = ClassPathExplorer
- .getAvailableWidgetSets();
-
// add widgetsets that do not exist
- for (String ws : availableWidgetSets) {
+ for (String ws : availableWidgetSets.keySet()) {
if (ws.equals(widgetset)) {
// do not inherit the module itself
continue;
}
for (String ws : oldInheritedWidgetsets) {
- if (!availableWidgetSets.contains(ws)) {
+ if (!availableWidgetSets.containsKey(ws)) {
// widgetset not available in classpath
content = removeWidgetSet(ws, content);
}
o.println("\t1. Set the same classpath as you will "
+ "have for the GWT compiler.");
o.println("\t2. Give the widgetsetname (to be created or updated)"
- + " as first parameter, source path as a second parameter");
+ + " as first parameter");
o.println();
o
.println("All found vaadin widgetsets will be inherited in given widgetset");
\r
/**\r
* A wrapper for the GWT 1.6 compiler that runs the compiler in a new thread.\r
- * \r
+ *\r
* This allows circumventing a J2SE 5.0 bug (6316197) that prevents setting the\r
* stack size for the main thread. Thus, larger widgetsets can be compiled.\r
- * \r
+ *\r
* This class takes the same command line arguments as the\r
* com.google.gwt.dev.GWTCompiler class. The old and deprecated compiler is used\r
* for compatibility with GWT 1.5.\r
- * \r
+ *\r
* A typical invocation would use e.g. the following arguments\r
- * \r
+ *\r
* "-out WebContent/VAADIN/widgetsets com.vaadin.terminal.gwt.DefaultWidgetSet"\r
- * \r
+ *\r
* In addition, larger memory usage settings for the VM should be used, e.g.\r
- * \r
+ *\r
* "-Xms256M -Xmx512M -Xss8M"\r
- * \r
+ *\r
* The source directory containing widgetset and related classes must be\r
* included in the classpath, as well as the gwt-dev-[platform].jar and other\r
* relevant JARs.\r
\r
// TODO expecting this is launched via eclipse WTP\r
// project\r
- WidgetSetBuilder.updateWidgetSet(wsname, "src");\r
+ WidgetSetBuilder.updateWidgetSet(wsname);\r
\r
System.setProperty("gwt.nowarn.legacy.tools", "true");\r
Class<?> compilerClass = Class\r