From 5813e0e9e5af4f946e5ea9c73d426e95d93b7bc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Mon, 6 Aug 2012 09:56:53 +0300 Subject: [PATCH] Make JsonPaintTarget use ResourceReference for getting urls (#9212) --- .../terminal/gwt/server/JsonPaintTarget.java | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java index aed1c2c0e3..5a830ddb63 100644 --- a/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java +++ b/src/com/vaadin/terminal/gwt/server/JsonPaintTarget.java @@ -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 -- 2.39.5