From cf2f43c99927ace4d5dfcdc4d1ac8ff0ebb5d2a0 Mon Sep 17 00:00:00 2001 From: Jens Jansson Date: Tue, 31 Jan 2012 11:15:50 +0200 Subject: [PATCH] #8324 Splitted VUnknownComponent into Widget and Paintable. --- .../gwt/client/ApplicationConfiguration.java | 6 ++- .../vaadin/terminal/gwt/client/WidgetSet.java | 9 ++-- .../gwt/client/ui/VUnknownComponent.java | 37 ++----------- .../client/ui/VUnknownComponentPaintable.java | 52 +++++++++++++++++++ 4 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 src/com/vaadin/terminal/gwt/client/ui/VUnknownComponentPaintable.java diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index 169934024b..862d156eb6 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -18,6 +18,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Timer; import com.vaadin.terminal.gwt.client.ui.VUnknownComponent; +import com.vaadin.terminal.gwt.client.ui.VUnknownComponentPaintable; public class ApplicationConfiguration implements EntryPoint { @@ -381,13 +382,14 @@ public class ApplicationConfiguration implements EntryPoint { return useDebugIdInDom; } - public Class getWidgetClassByEncodedTag(String tag) { + public Class getWidgetClassByEncodedTag( + String tag) { try { int parseInt = Integer.parseInt(tag); return classes[parseInt]; } catch (Exception e) { // component was not present in mappings - return VUnknownComponent.class; + return VUnknownComponentPaintable.class; } } diff --git a/src/com/vaadin/terminal/gwt/client/WidgetSet.java b/src/com/vaadin/terminal/gwt/client/WidgetSet.java index e6e365c258..4f3e510f9a 100644 --- a/src/com/vaadin/terminal/gwt/client/WidgetSet.java +++ b/src/com/vaadin/terminal/gwt/client/WidgetSet.java @@ -10,7 +10,7 @@ import com.vaadin.terminal.gwt.client.ui.VFilterSelectPaintable; import com.vaadin.terminal.gwt.client.ui.VListSelectPaintable; import com.vaadin.terminal.gwt.client.ui.VSplitPanelHorizontal; import com.vaadin.terminal.gwt.client.ui.VSplitPanelVertical; -import com.vaadin.terminal.gwt.client.ui.VUnknownComponent; +import com.vaadin.terminal.gwt.client.ui.VUnknownComponentPaintable; import com.vaadin.terminal.gwt.client.ui.VView; import com.vaadin.terminal.gwt.client.ui.VWindow; @@ -50,10 +50,11 @@ public class WidgetSet { final Class classType = resolveWidgetType( uidl, conf); - if (classType == null || classType == VUnknownComponent.class) { + if (classType == null || classType == VUnknownComponentPaintable.class) { String serverSideName = conf .getUnknownServerClassNameByEncodedTagName(uidl.getTag()); - VUnknownComponent c = GWT.create(VUnknownComponent.class); + VUnknownComponentPaintable c = GWT + .create(VUnknownComponentPaintable.class); c.setServerSideClassName(serverSideName); return c; } else if (VWindow.class == classType) { @@ -121,7 +122,7 @@ public class WidgetSet { public Class getImplementationByClassName( String fullyqualifiedName) { if (fullyqualifiedName == null) { - return VUnknownComponent.class; + return VUnknownComponentPaintable.class; } Class implementationByServerSideClassName = widgetMap .getImplementationByServerSideClassName(fullyqualifiedName); diff --git a/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponent.java b/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponent.java index 5b3790f521..ad702430f6 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponent.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponent.java @@ -6,19 +6,14 @@ package com.vaadin.terminal.gwt.client.ui; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Widget; -import com.vaadin.terminal.gwt.client.ApplicationConnection; -import com.vaadin.terminal.gwt.client.VPaintableWidget; import com.vaadin.terminal.gwt.client.SimpleTree; -import com.vaadin.terminal.gwt.client.UIDL; -import com.vaadin.terminal.gwt.client.VUIDLBrowser; -public class VUnknownComponent extends Composite implements VPaintableWidget { +public class VUnknownComponent extends Composite { com.google.gwt.user.client.ui.Label caption = new com.google.gwt.user.client.ui.Label();; SimpleTree uidlTree; - private VerticalPanel panel; - private String serverClassName = "unkwnown"; + protected VerticalPanel panel; + protected String serverClassName = "unkwnown"; public VUnknownComponent() { panel = new VerticalPanel(); @@ -32,33 +27,7 @@ public class VUnknownComponent extends Composite implements VPaintableWidget { this.serverClassName = serverClassName; } - public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { - if (client.updateComponent(this, uidl, false)) { - return; - } - setCaption("Widgetset does not contain implementation for " - + serverClassName - + ". Check its @ClientWidget mapping, widgetsets " - + "GWT module description file and re-compile your" - + " widgetset. In case you have downloaded a vaadin" - + " add-on package, you might want to refer to " - + "add-on " - + "instructions. Unrendered UIDL:"); - if (uidlTree != null) { - uidlTree.removeFromParent(); - } - - uidlTree = new VUIDLBrowser(uidl, client.getConfiguration()); - uidlTree.open(true); - uidlTree.setText("Unrendered UIDL"); - panel.add(uidlTree); - } - public void setCaption(String c) { caption.getElement().setInnerHTML(c); } - - public Widget getWidgetForPaintable() { - return this; - } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponentPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponentPaintable.java new file mode 100644 index 0000000000..252d7528ca --- /dev/null +++ b/src/com/vaadin/terminal/gwt/client/ui/VUnknownComponentPaintable.java @@ -0,0 +1,52 @@ +/* +@VaadinApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.client.ui; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.terminal.gwt.client.ApplicationConnection; +import com.vaadin.terminal.gwt.client.UIDL; +import com.vaadin.terminal.gwt.client.VUIDLBrowser; + +public class VUnknownComponentPaintable extends VAbstractPaintableWidget { + + public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + if (client.updateComponent(this, uidl, false)) { + return; + } + getWidgetForPaintable().setCaption( + "Widgetset does not contain implementation for " + + getWidgetForPaintable().serverClassName + + ". Check its @ClientWidget mapping, widgetsets " + + "GWT module description file and re-compile your" + + " widgetset. In case you have downloaded a vaadin" + + " add-on package, you might want to refer to " + + "add-on " + + "instructions. Unrendered UIDL:"); + if (getWidgetForPaintable().uidlTree != null) { + getWidgetForPaintable().uidlTree.removeFromParent(); + } + + getWidgetForPaintable().uidlTree = new VUIDLBrowser(uidl, + client.getConfiguration()); + getWidgetForPaintable().uidlTree.open(true); + getWidgetForPaintable().uidlTree.setText("Unrendered UIDL"); + getWidgetForPaintable().panel.add(getWidgetForPaintable().uidlTree); + } + + @Override + protected Widget createWidget() { + return GWT.create(VUnknownComponent.class); + } + + @Override + public VUnknownComponent getWidgetForPaintable() { + return (VUnknownComponent) super.getWidgetForPaintable(); + } + + public void setServerSideClassName(String serverClassName) { + getWidgetForPaintable().setServerSideClassName(serverClassName); + } +} -- 2.39.5