summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-01-23 14:22:45 +0200
committerArtur Signell <artur@vaadin.com>2012-01-23 14:22:45 +0200
commit0f00b0f2751e1196b51b96bf3900423bdd95d064 (patch)
tree1d595961c300b5d8fe16afede57262f872961cca /src
parent70173cfc6ec1a5d67f33c0477ae135935cf81314 (diff)
downloadvaadin-framework-0f00b0f2751e1196b51b96bf3900423bdd95d064.tar.gz
vaadin-framework-0f00b0f2751e1196b51b96bf3900423bdd95d064.zip
Created VAbstractPaintableWidget
Moved VLabel* to own package
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java49
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VLabelPaintable.java122
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java (renamed from src/com/vaadin/terminal/gwt/client/ui/VLabel.java)2
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java71
-rw-r--r--src/com/vaadin/ui/Label.java2
5 files changed, 122 insertions, 124 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
new file mode 100644
index 0000000000..dff5a286ba
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
@@ -0,0 +1,49 @@
+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.VPaintableWidget;
+
+public abstract class VAbstractPaintableWidget implements VPaintableWidget {
+
+ private Widget widget;
+
+ /**
+ * Default constructor
+ */
+ public VAbstractPaintableWidget() {
+ }
+
+ /**
+ * Creates and returns the widget for this VPaintableWidget. This method
+ * should only be called once when initializing the paintable.
+ *
+ * @return
+ */
+ protected Widget createWidget() {
+ return GWT.create(getWidgetClass());
+ }
+
+ /**
+ * Returns the widget associated with this paintable. The widget returned by
+ * this method must not changed during the life time of the paintable.
+ *
+ * @return The widget associated with this paintable
+ */
+ public Widget getWidgetForPaintable() {
+ if (widget == null) {
+ widget = createWidget();
+ }
+
+ return widget;
+ }
+
+ /**
+ * Returns the class of the widget for this paintable. Used to instansiate
+ * the widget.
+ *
+ * @return The widget class.
+ */
+ protected abstract Class<? extends Widget> getWidgetClass();
+
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VLabelPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VLabelPaintable.java
deleted file mode 100644
index 12f2c639da..0000000000
--- a/src/com/vaadin/terminal/gwt/client/ui/VLabelPaintable.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
-@VaadinApache2LicenseForJavaFiles@
- */
-package com.vaadin.terminal.gwt.client.ui;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.dom.client.Document;
-import com.google.gwt.dom.client.PreElement;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.dom.client.KeyDownEvent;
-import com.google.gwt.event.dom.client.KeyDownHandler;
-import com.google.gwt.event.dom.client.MouseMoveEvent;
-import com.google.gwt.event.dom.client.MouseMoveHandler;
-import com.google.gwt.event.dom.client.MouseOutEvent;
-import com.google.gwt.event.dom.client.MouseOutHandler;
-import com.google.gwt.event.dom.client.MouseOverEvent;
-import com.google.gwt.event.dom.client.MouseOverHandler;
-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.Util;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
-
-public class VLabelPaintable implements VPaintableWidget {
-
- private VLabel widget = GWT.create(VLabel.class);
- private ApplicationConnection client;
-
- class TooltipHandler implements ClickHandler, KeyDownHandler,
- MouseOverHandler, MouseOutHandler, MouseMoveHandler {
-
- public void onClick(ClickEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- public void onMouseMove(MouseMoveEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- public void onMouseOut(MouseOutEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- public void onMouseOver(MouseOverEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- public void onKeyDown(KeyDownEvent event) {
- // TODO Auto-generated method stub
-
- }
-
- }
-
- public VLabelPaintable() {
- TooltipHandler handler = new TooltipHandler();
-
- widget.addDomHandler(handler, ClickEvent.getType());
- widget.addDomHandler(handler, KeyDownEvent.getType());
- widget.addDomHandler(handler, MouseOverEvent.getType());
- widget.addDomHandler(handler, MouseOutEvent.getType());
- widget.addDomHandler(handler, MouseMoveEvent.getType());
-
- }
-
- public VLabel getWidget() {
- return widget;
- }
-
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
- if (client.updateComponent(getWidget(), uidl, true)) {
- return;
- }
-
- this.client = client;
-
- boolean sinkOnloads = false;
-
- final String mode = uidl.getStringAttribute("mode");
- if (mode == null || "text".equals(mode)) {
- getWidget().setText(uidl.getChildString(0));
- } else if ("pre".equals(mode)) {
- PreElement preElement = Document.get().createPreElement();
- preElement.setInnerText(uidl.getChildUIDL(0).getChildString(0));
- // clear existing content
- getWidget().setHTML("");
- // add preformatted text to dom
- getWidget().getElement().appendChild(preElement);
- } else if ("uidl".equals(mode)) {
- getWidget().setHTML(uidl.getChildrenAsXML());
- } else if ("xhtml".equals(mode)) {
- UIDL content = uidl.getChildUIDL(0).getChildUIDL(0);
- if (content.getChildCount() > 0) {
- getWidget().setHTML(content.getChildString(0));
- } else {
- getWidget().setHTML("");
- }
- sinkOnloads = true;
- } else if ("xml".equals(mode)) {
- getWidget().setHTML(uidl.getChildUIDL(0).getChildString(0));
- } else if ("raw".equals(mode)) {
- getWidget().setHTML(uidl.getChildUIDL(0).getChildString(0));
- sinkOnloads = true;
- } else {
- getWidget().setText("");
- }
- if (sinkOnloads) {
- Util.sinkOnloadForImages(getWidget().getElement());
- }
- }
-
- public Widget getWidgetForPaintable() {
- return getWidget();
- }
-
-}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VLabel.java b/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java
index f259d033c6..09f435227d 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VLabel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/label/VLabel.java
@@ -2,7 +2,7 @@
@VaadinApache2LicenseForJavaFiles@
*/
-package com.vaadin.terminal.gwt.client.ui;
+package com.vaadin.terminal.gwt.client.ui.label;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML;
diff --git a/src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java b/src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java
new file mode 100644
index 0000000000..796bce265e
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/ui/label/VLabelPaintable.java
@@ -0,0 +1,71 @@
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.ui.label;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.PreElement;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.Util;
+import com.vaadin.terminal.gwt.client.VPaintableWidget;
+
+public class VLabelPaintable implements VPaintableWidget {
+
+ private VLabel widget = GWT.create(VLabel.class);
+ private ApplicationConnection client;
+
+ public VLabelPaintable() {
+ }
+
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+
+ if (client.updateComponent(getWidgetForPaintable(), uidl, true)) {
+ return;
+ }
+
+ this.client = client;
+
+ boolean sinkOnloads = false;
+
+ final String mode = uidl.getStringAttribute("mode");
+ if (mode == null || "text".equals(mode)) {
+ getWidgetForPaintable().setText(uidl.getChildString(0));
+ } else if ("pre".equals(mode)) {
+ PreElement preElement = Document.get().createPreElement();
+ preElement.setInnerText(uidl.getChildUIDL(0).getChildString(0));
+ // clear existing content
+ getWidgetForPaintable().setHTML("");
+ // add preformatted text to dom
+ getWidgetForPaintable().getElement().appendChild(preElement);
+ } else if ("uidl".equals(mode)) {
+ getWidgetForPaintable().setHTML(uidl.getChildrenAsXML());
+ } else if ("xhtml".equals(mode)) {
+ UIDL content = uidl.getChildUIDL(0).getChildUIDL(0);
+ if (content.getChildCount() > 0) {
+ getWidgetForPaintable().setHTML(content.getChildString(0));
+ } else {
+ getWidgetForPaintable().setHTML("");
+ }
+ sinkOnloads = true;
+ } else if ("xml".equals(mode)) {
+ getWidgetForPaintable().setHTML(
+ uidl.getChildUIDL(0).getChildString(0));
+ } else if ("raw".equals(mode)) {
+ getWidgetForPaintable().setHTML(
+ uidl.getChildUIDL(0).getChildString(0));
+ sinkOnloads = true;
+ } else {
+ getWidgetForPaintable().setText("");
+ }
+ if (sinkOnloads) {
+ Util.sinkOnloadForImages(getWidgetForPaintable().getElement());
+ }
+ }
+
+ public VLabel getWidgetForPaintable() {
+ return widget;
+ }
+
+}
diff --git a/src/com/vaadin/ui/Label.java b/src/com/vaadin/ui/Label.java
index 29eb6df766..576bbd967f 100644
--- a/src/com/vaadin/ui/Label.java
+++ b/src/com/vaadin/ui/Label.java
@@ -10,7 +10,7 @@ import com.vaadin.data.Property;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
-import com.vaadin.terminal.gwt.client.ui.VLabelPaintable;
+import com.vaadin.terminal.gwt.client.ui.label.VLabelPaintable;
import com.vaadin.ui.ClientWidget.LoadStyle;
/**