]> source.dussan.org Git - vaadin-framework.git/commitdiff
Splitted VTextualDate into Widget and Paintable.
authorJens Jansson <peppe@vaadin.com>
Mon, 30 Jan 2012 13:35:14 +0000 (15:35 +0200)
committerJens Jansson <peppe@vaadin.com>
Mon, 30 Jan 2012 13:35:14 +0000 (15:35 +0200)
src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
src/com/vaadin/terminal/gwt/client/ui/VTextualDatePaintable.java [new file with mode: 0644]

index a522c7973643aa1c4eb7fbbab7c2e5f1c28d67d8..bb808321b9e99d65a214c05c47efcf2fc1606ca0 100644 (file)
@@ -14,25 +14,22 @@ import com.google.gwt.event.dom.client.FocusEvent;
 import com.google.gwt.event.dom.client.FocusHandler;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.TextBox;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.ContainerResizedListener;
 import com.vaadin.terminal.gwt.client.EventId;
 import com.vaadin.terminal.gwt.client.Focusable;
 import com.vaadin.terminal.gwt.client.LocaleNotLoadedException;
 import com.vaadin.terminal.gwt.client.LocaleService;
-import com.vaadin.terminal.gwt.client.UIDL;
 import com.vaadin.terminal.gwt.client.VConsole;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
 
-public class VTextualDate extends VDateField implements VPaintableWidget,
-        Field, ChangeHandler, ContainerResizedListener, Focusable, SubPartAware {
+public class VTextualDate extends VDateField implements Field, ChangeHandler,
+        ContainerResizedListener, Focusable, SubPartAware {
 
     private static final String PARSE_ERROR_CLASSNAME = CLASSNAME
             + "-parseerror";
 
-    private final TextBox text;
+    protected final TextBox text;
 
-    private String formatStr;
+    protected String formatStr;
 
     private String width;
 
@@ -40,11 +37,11 @@ public class VTextualDate extends VDateField implements VPaintableWidget,
 
     protected int fieldExtraWidth = -1;
 
-    private boolean lenient;
+    protected boolean lenient;
 
     private static final String CLASSNAME_PROMPT = "prompt";
-    private static final String ATTR_INPUTPROMPT = "prompt";
-    private String inputPrompt = "";
+    protected static final String ATTR_INPUTPROMPT = "prompt";
+    protected String inputPrompt = "";
     private boolean prompting = false;
 
     public VTextualDate() {
@@ -65,8 +62,8 @@ public class VTextualDate extends VDateField implements VPaintableWidget,
                     setPrompting(false);
                 }
                 if (getClient() != null
-                        && getClient().hasEventListeners(VTextualDate.this,
-                                EventId.FOCUS)) {
+                        && getClient().hasWidgetEventListeners(
+                                VTextualDate.this, EventId.FOCUS)) {
                     getClient()
                             .updateVariable(getId(), EventId.FOCUS, "", true);
                 }
@@ -83,8 +80,8 @@ public class VTextualDate extends VDateField implements VPaintableWidget,
                     text.setText(readonly ? "" : inputPrompt);
                 }
                 if (getClient() != null
-                        && getClient().hasEventListeners(VTextualDate.this,
-                                EventId.BLUR)) {
+                        && getClient().hasWidgetEventListeners(
+                                VTextualDate.this, EventId.BLUR)) {
                     getClient().updateVariable(getId(), EventId.BLUR, "", true);
                 }
             }
@@ -92,37 +89,6 @@ public class VTextualDate extends VDateField implements VPaintableWidget,
         add(text);
     }
 
-    @Override
-    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-        int origRes = currentResolution;
-        String oldLocale = currentLocale;
-        super.updateFromUIDL(uidl, client);
-        if (origRes != currentResolution || oldLocale != currentLocale) {
-            // force recreating format string
-            formatStr = null;
-        }
-        if (uidl.hasAttribute("format")) {
-            formatStr = uidl.getStringAttribute("format");
-        }
-
-        inputPrompt = uidl.getStringAttribute(ATTR_INPUTPROMPT);
-
-        lenient = !uidl.getBooleanAttribute("strict");
-
-        buildDate();
-        // not a FocusWidget -> needs own tabindex handling
-        if (uidl.hasAttribute("tabindex")) {
-            text.setTabIndex(uidl.getIntAttribute("tabindex"));
-        }
-
-        if (readonly) {
-            text.addStyleDependentName("readonly");
-        } else {
-            text.removeStyleDependentName("readonly");
-        }
-
-    }
-
     protected String getFormatString() {
         if (formatStr == null) {
             if (currentResolution == RESOLUTION_YEAR) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDatePaintable.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDatePaintable.java
new file mode 100644 (file)
index 0000000..6a9da31
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+@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;
+
+public class VTextualDatePaintable extends VDateFieldPaintable {
+
+    @Override
+    public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+        int origRes = getWidgetForPaintable().currentResolution;
+        String oldLocale = getWidgetForPaintable().currentLocale;
+        super.updateFromUIDL(uidl, client);
+        if (origRes != getWidgetForPaintable().currentResolution
+                || oldLocale != getWidgetForPaintable().currentLocale) {
+            // force recreating format string
+            getWidgetForPaintable().formatStr = null;
+        }
+        if (uidl.hasAttribute("format")) {
+            getWidgetForPaintable().formatStr = uidl
+                    .getStringAttribute("format");
+        }
+
+        getWidgetForPaintable().inputPrompt = uidl
+                .getStringAttribute(VTextualDate.ATTR_INPUTPROMPT);
+
+        getWidgetForPaintable().lenient = !uidl.getBooleanAttribute("strict");
+
+        getWidgetForPaintable().buildDate();
+        // not a FocusWidget -> needs own tabindex handling
+        if (uidl.hasAttribute("tabindex")) {
+            getWidgetForPaintable().text.setTabIndex(uidl
+                    .getIntAttribute("tabindex"));
+        }
+
+        if (getWidgetForPaintable().readonly) {
+            getWidgetForPaintable().text.addStyleDependentName("readonly");
+        } else {
+            getWidgetForPaintable().text.removeStyleDependentName("readonly");
+        }
+
+    }
+
+    @Override
+    protected Widget createWidget() {
+        return GWT.create(VTextualDate.class);
+    }
+
+    @Override
+    public VTextualDate getWidgetForPaintable() {
+        return (VTextualDate) super.getWidgetForPaintable();
+    }
+}