]> source.dussan.org Git - vaadin-framework.git/commitdiff
#5026 WidgetSetBuilder creates duplicate references to non-Vaadin GWT modules
authorArtur Signell <artur.signell@itmill.com>
Tue, 18 Jan 2011 09:27:54 +0000 (09:27 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 18 Jan 2011 09:27:54 +0000 (09:27 +0000)
svn changeset:16919/svn branch:6.5

src/com/vaadin/terminal/gwt/widgetsetutils/ClassPathExplorer.java
src/com/vaadin/terminal/gwt/widgetsetutils/WidgetSetBuilder.java

index 0fa618ec4fd3a5c6b5fa70c0f236dbdaff073697..5bf6df1ea379a4d7fb14c55d807695b8dd2cb7b9 100644 (file)
@@ -189,30 +189,36 @@ public class ClassPathExplorer {
             String[] files = directory.list();
             for (int i = 0; i < files.length; i++) {
                 // we are only interested in .gwt.xml files
-                if (files[i].endsWith(".gwt.xml")) {
-                    // remove the extension
-                    String classname = files[i].substring(0,
-                            files[i].length() - 8);
-                    String packageName = locationString
-                            .substring(locationString.lastIndexOf("/") + 1);
-                    classname = packageName + "." + classname;
-                    if (!widgetsets.containsKey(classname)) {
-                        String packagePath = packageName.replaceAll("\\.", "/");
-                        String basePath = location.getFile().replaceAll(
-                                "/" + packagePath + "$", "");
-                        try {
-                            URL url = new URL(location.getProtocol(),
-                                    location.getHost(), location.getPort(),
-                                    basePath);
-                            widgetsets.put(classname, url);
-                        } catch (MalformedURLException e) {
-                            // should never happen as based on an existing URL,
-                            // only changing end of file name/path part
-                            logger.log(
-                                    Level.SEVERE,
-                                    "Error locating the widgetset " + classname,
-                                    e);
-                        }
+                if (!files[i].endsWith(".gwt.xml")) {
+                    continue;
+                }
+
+                // remove the .gwt.xml extension
+                String classname = files[i].substring(0, files[i].length() - 8);
+                String packageName = locationString.substring(locationString
+                        .lastIndexOf("/") + 1);
+                classname = packageName + "." + classname;
+
+                if (!WidgetSetBuilder.isWidgetset(classname)) {
+                    // Only return widgetsets and not GWT modules to avoid
+                    // comparing modules and widgetsets
+                    continue;
+                }
+
+                if (!widgetsets.containsKey(classname)) {
+                    String packagePath = packageName.replaceAll("\\.", "/");
+                    String basePath = location.getFile().replaceAll(
+                            "/" + packagePath + "$", "");
+                    try {
+                        URL url = new URL(location.getProtocol(),
+                                location.getHost(), location.getPort(),
+                                basePath);
+                        widgetsets.put(classname, url);
+                    } catch (MalformedURLException e) {
+                        // should never happen as based on an existing URL,
+                        // only changing end of file name/path part
+                        logger.log(Level.SEVERE,
+                                "Error locating the widgetset " + classname, e);
                     }
                 }
             }
index 7eaee22073e4b396f628af744312a519fe11c548..9b9639d3078cb76fa5d1960d112008e3cfeda7fd 100644 (file)
@@ -100,7 +100,7 @@ public class WidgetSetBuilder {
         if (isEditable(content)) {
             String originalContent = content;
 
-            Collection<String> oldInheritedWidgetsets = getCurrentGwtModules(content);
+            Collection<String> oldInheritedWidgetsets = getCurrentInheritedWidgetsets(content);
 
             // add widgetsets that do not exist
             Iterator<String> i = availableWidgetSets.keySet().iterator();
@@ -153,21 +153,26 @@ public class WidgetSetBuilder {
                 + "\" />" + "\n</module>");
     }
 
-    private static Collection<String> getCurrentGwtModules(String content) {
+    private static Collection<String> getCurrentInheritedWidgetsets(
+            String content) {
         HashSet<String> hashSet = new HashSet<String>();
         Pattern inheritsPattern = Pattern.compile(" name=\"([^\"]*)\"");
 
         Matcher matcher = inheritsPattern.matcher(content);
 
         while (matcher.find()) {
-            String possibleWidgetSet = matcher.group(1);
-            if (possibleWidgetSet.toLowerCase().contains("widgetset")) {
-                hashSet.add(possibleWidgetSet);
+            String gwtModule = matcher.group(1);
+            if (isWidgetset(gwtModule)) {
+                hashSet.add(gwtModule);
             }
         }
         return hashSet;
     }
 
+    static boolean isWidgetset(String gwtModuleName) {
+        return gwtModuleName.toLowerCase().contains("widgetset");
+    }
+
     private static String readFile(File widgetsetFile) throws IOException {
         Reader fi = new FileReader(widgetsetFile);
         BufferedReader bufferedReader = new BufferedReader(fi);