From a166d6f52bf99d7616959f8e16b3972ed6b074d0 Mon Sep 17 00:00:00 2001 From: Knoobie Date: Thu, 21 Sep 2017 10:52:41 +0200 Subject: Add Upload#setButtonStyleName (#10044) --- .../vaadin/client/ui/upload/UploadConnector.java | 4 +++ server/src/main/java/com/vaadin/ui/Upload.java | 31 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java b/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java index 73c672c370..5b5c4a60e4 100644 --- a/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/upload/UploadConnector.java @@ -78,6 +78,10 @@ public class UploadConnector extends AbstractComponentConnector if (uidl.hasAttribute("buttoncaption")) { getWidget().submitButton .setText(uidl.getStringAttribute("buttoncaption")); + if (uidl.hasAttribute("buttonstylename")) { + getWidget().submitButton + .setStyleName(uidl.getStringAttribute("buttonstylename")); + } getWidget().submitButton.setVisible(true); } else { getWidget().submitButton.setVisible(false); diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java index cdc78bae35..4812c8ffd5 100644 --- a/server/src/main/java/com/vaadin/ui/Upload.java +++ b/server/src/main/java/com/vaadin/ui/Upload.java @@ -101,6 +101,8 @@ public class Upload extends AbstractComponent private String buttonCaption = "Upload"; + private String buttonStyleName; + /** * ProgressListeners to which information about progress is sent during * upload @@ -185,6 +187,9 @@ public class Upload extends AbstractComponent if (buttonCaption != null) { target.addAttribute("buttoncaption", buttonCaption); + if (buttonStyleName != null) { + target.addAttribute("buttonstylename", buttonStyleName); + } } target.addAttribute("nextid", nextid); @@ -975,12 +980,24 @@ public class Upload extends AbstractComponent } /** + * Returns the string rendered into button that fires uploading. + * * @return String to be rendered into button that fires uploading */ public String getButtonCaption() { return buttonCaption; } + /** + * Returns the stylename rendered into button that fires uploading. + * + * @return Stylename to be rendered into button that fires uploading + * @since 8.2 + */ + public String getButtonStyleName() { + return buttonStyleName; + } + /** * In addition to the actual file chooser, upload components have button * that starts actual upload progress. This method is used to set text in @@ -1008,6 +1025,20 @@ public class Upload extends AbstractComponent markAsDirty(); } + /** + * In addition to the actual file chooser, upload components have button + * that starts actual upload progress. This method is used to set a stylename + * to that button. + * + * @param buttonStyleName styleName for upload components button. + * @see #setButtonCaption(String) about when the button is shown / hidden. + * @since 8.2 + */ + public void setButtonStyleName(String buttonStyleName) { + this.buttonStyleName = buttonStyleName; + markAsDirty(); + } + /** * Forces the upload the send selected file to the server. *

-- cgit v1.2.3