]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make JsonPaintTarget use ResourceReference for getting urls (#9212)
authorLeif Åstrand <leif@vaadin.com>
Mon, 6 Aug 2012 06:56:53 +0000 (09:56 +0300)
committerLeif Åstrand <leif@vaadin.com>
Mon, 6 Aug 2012 06:56:53 +0000 (09:56 +0300)
src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java

index aed1c2c0e3a108b53e6f8ae820fa9270c20434c6..5a830ddb6366fae48669d7a2dfbbd8781d68e852 100644 (file)
@@ -15,14 +15,10 @@ import java.util.Stack;
 import java.util.Vector;
 import java.util.logging.Logger;
 
-import com.vaadin.Application;
-import com.vaadin.terminal.ApplicationResource;
-import com.vaadin.terminal.ExternalResource;
 import com.vaadin.terminal.PaintException;
 import com.vaadin.terminal.PaintTarget;
 import com.vaadin.terminal.Resource;
 import com.vaadin.terminal.StreamVariable;
-import com.vaadin.terminal.ThemeResource;
 import com.vaadin.terminal.VariableOwner;
 import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Component;
@@ -339,33 +335,12 @@ public class JsonPaintTarget implements PaintTarget {
     }
 
     @Override
-    @SuppressWarnings("deprecation")
     public void addAttribute(String name, Resource value) throws PaintException {
-
-        if (value instanceof ExternalResource) {
-            addAttribute(name, ((ExternalResource) value).getURL());
-
-        } else if (value instanceof ApplicationResource) {
-            final ApplicationResource r = (ApplicationResource) value;
-            final Application a = r.getApplication();
-            if (a == null) {
-                throw new PaintException(
-                        "Application not specified for resorce "
-                                + value.getClass().getName());
-            }
-            final String uri = a.getRelativeLocation(r);
-            addAttribute(name, uri);
-
-        } else if (value instanceof ThemeResource) {
-            final String uri = "theme://"
-                    + ((ThemeResource) value).getResourceId();
-            addAttribute(name, uri);
-        } else {
-            throw new PaintException("Ajax adapter does not "
-                    + "support resources of type: "
-                    + value.getClass().getName());
+        if (value == null) {
+            throw new NullPointerException();
         }
-
+        ResourceReference reference = ResourceReference.create(value);
+        addAttribute(name, reference.getURL());
     }
 
     @Override