]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #1186
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 26 Nov 2007 09:36:13 +0000 (09:36 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 26 Nov 2007 09:36:13 +0000 (09:36 +0000)
svn changeset:2942/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java
src/com/itmill/toolkit/ui/Upload.java

index 00e9ce542ace15035c02279eadec5b67bbe606c9..aef421a9837eda9e0d117e5408cee34676c6a14f 100644 (file)
@@ -17,7 +17,7 @@ import com.itmill.toolkit.terminal.gwt.client.UIDL;
 
 public class IUpload extends FormPanel implements Paintable, ClickListener,
         FormHandler {
-    
+
     public static final String CLASSNAME = "i-upload";
 
     /**
@@ -34,7 +34,7 @@ public class IUpload extends FormPanel implements Paintable, ClickListener,
     /**
      * Button that initiates uploading
      */
-    private Button b;
+    private Button submitButton;
 
     /**
      * When expecting big files, programmer may initiate some UI changes when
@@ -57,27 +57,23 @@ public class IUpload extends FormPanel implements Paintable, ClickListener,
 
         setWidget(panel);
         panel.add(fu);
-        // TODO
-        b = new Button("Click to Upload");
-        b.addClickListener(this);
-        panel.add(b);
+        submitButton = new Button();
+        submitButton.addClickListener(this);
+        panel.add(submitButton);
 
         addFormHandler(this);
-        
+
         setStyleName(CLASSNAME);
     }
 
     public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-        if (client.updateComponent(this, uidl, false)) {
+        if (client.updateComponent(this, uidl, true)) {
             return;
         }
         this.client = client;
         paintableId = uidl.getId();
         setAction(client.getAppUri());
-
-        if (uidl.hasAttribute("caption")) {
-            b.setText(uidl.getStringAttribute("caption"));
-        }
+        submitButton.setText(uidl.getStringAttribute("buttoncaption"));
         fu.setName(paintableId + "_file");
 
     }
@@ -111,12 +107,12 @@ public class IUpload extends FormPanel implements Paintable, ClickListener,
     }
 
     protected void disableUpload() {
-        b.setEnabled(false);
+        submitButton.setEnabled(false);
         fu.setVisible(false);
     }
 
     protected void enableUploaod() {
-        b.setEnabled(true);
+        submitButton.setEnabled(true);
         fu.setVisible(true);
     }
 
index a755b1413718dc8ccdc594dc2ae04db671912f1e..998178d0d257709b440535eb94d830b6fad71918 100644 (file)
@@ -76,6 +76,8 @@ public class Upload extends AbstractComponent implements Component.Focusable {
 
     private int totalBytes;
 
+    private String buttonCaption = "Upload";
+
     /**
      * ProgressListener to which information about progress is sent during
      * upload
@@ -193,6 +195,8 @@ public class Upload extends AbstractComponent implements Component.Focusable {
 
         target.addAttribute("state", isUploading);
 
+        target.addAttribute("buttoncaption", buttonCaption);
+
         target.addVariable(this, "fake", true);
 
         target.addUploadStreamVariable(this, "stream");
@@ -801,4 +805,22 @@ public class Upload extends AbstractComponent implements Component.Focusable {
          */
         public void updateProgress(long readBytes, long contentLength);
     }
+
+    /**
+     * @return String to be rendered into button that fires uploading
+     */
+    public String getButtonCaption() {
+        return buttonCaption;
+    }
+
+    /**
+     * File uploads usually have button that starts actual upload progress. This
+     * method is used to set text in that button.
+     * 
+     * @param buttonCaption
+     *                text for uploads button.
+     */
+    public void setButtonCaption(String buttonCaption) {
+        this.buttonCaption = buttonCaption;
+    }
 }