aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2007-11-26 09:36:13 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2007-11-26 09:36:13 +0000
commitd7281512788e31efe252b937ef96167ade59a829 (patch)
treed471e56cc24fd6159c497403c9a66decfcb401a4 /src
parentc23b5b9264b2b1933bc30307e0f9400eedebb9eb (diff)
downloadvaadin-framework-d7281512788e31efe252b937ef96167ade59a829.tar.gz
vaadin-framework-d7281512788e31efe252b937ef96167ade59a829.zip
fixes #1186
svn changeset:2942/svn branch:trunk
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java24
-rw-r--r--src/com/itmill/toolkit/ui/Upload.java22
2 files changed, 32 insertions, 14 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java
index 00e9ce542a..aef421a983 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IUpload.java
@@ -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);
}
diff --git a/src/com/itmill/toolkit/ui/Upload.java b/src/com/itmill/toolkit/ui/Upload.java
index a755b14137..998178d0d2 100644
--- a/src/com/itmill/toolkit/ui/Upload.java
+++ b/src/com/itmill/toolkit/ui/Upload.java
@@ -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;
+ }
}