Class CmsUploadButton

java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Composite
org.opencms.gwt.client.ui.input.upload.CmsUploadButton
All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasHorizontalAlignment, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget, I_CmsUploadButton

public class CmsUploadButton extends com.google.gwt.user.client.ui.Composite implements com.google.gwt.user.client.ui.HasHorizontalAlignment, I_CmsUploadButton
Provides a upload button.

Since:
8.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static interface 
    The ui-binder interface.

    Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject

    com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled

    Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment

    com.google.gwt.user.client.ui.HasHorizontalAlignment.AutoHorizontalAlignmentConstant, com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.google.gwt.user.client.ui.HTML
    The button face.
    protected CmsFlowPanel
    The main panel.

    Fields inherited from class com.google.gwt.user.client.ui.UIObject

    DEBUG_ID_PREFIX

    Fields inherited from interface com.google.gwt.user.client.ui.HasHorizontalAlignment

    ALIGN_CENTER, ALIGN_DEFAULT, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_LOCALE_END, ALIGN_LOCALE_START, ALIGN_RIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    The default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates and adds a file input.
    void
    disable(String disabledReason)
    Disables the button and changes the button title attribute to the disabled reason.
    void
    Enables the button, switching the button title attribute from the disabled reason to the original title.
    static String
    formatBytes(long filesize)
    Formats a given bytes value (file size).
    Gets the upload button handler instance for this button.
    protected String
    getFaceHtml(String text, String imageClass)
    Convenience method to assemble the HTML to use for a button face.
    com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant
    This is the alignment of the text in reference to the image, possible values are left or right.
    Returns the master image class.
    Returns the size.
    Returns the text.
    Returns the title.
    protected void
    handleMouseOut(com.google.gwt.event.dom.client.MouseOutEvent event)
    Handles the mouse over event on the main panel.
    protected void
    handleMouseOver(com.google.gwt.event.dom.client.MouseOverEvent event)
    Handles the mouse over event on the main panel.
    boolean
    Returns if the upload button is enabled.
    boolean
    Checks if the button is constraint to a minimal width.
    void
    Reinitializes the button with a new button handler.
    void
    Sets the button style.
    void
    setEnabled(boolean enabled, String disabledMessage)
    Enables / disables the button.
    void
    setHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant align)
    This is the alignment of the text in reference to the image, possible values are left or right.
    void
    setImageClass(String imageClass)
    Sets the master image class.
    void
    Sets the size.
    void
    Sets the text.
    void
     
    void
    setUpFace(String text, String imageClass)
    Sets the up face text and image.
    void
    setUseMinWidth(boolean useMinWidth)
    Tells the button to use a minimal width.
    void
     

    Methods inherited from class com.google.gwt.user.client.ui.Composite

    claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget

    Methods inherited from class com.google.gwt.user.client.ui.Widget

    addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents

    Methods inherited from class com.google.gwt.user.client.ui.UIObject

    addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, setVisible, setWidth, sinkBitlessEvent, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • m_buttonFace

      @UiField protected com.google.gwt.user.client.ui.HTML m_buttonFace
      The button face.
    • m_main

      @UiField protected CmsFlowPanel m_main
      The main panel.
  • Constructor Details

    • CmsUploadButton

      The default constructor.

      Creates a new upload button. This upload button opens a new OS file selector on click.

      On change the button handler passed into the constructor is notified.

      Parameters:
      buttonHandler - the buttonHandler
  • Method Details

    • formatBytes

      public static String formatBytes(long filesize)
      Formats a given bytes value (file size).

      Parameters:
      filesize - the file size to format
      Returns:
      the formated file size in KB
    • createFileInput

      Creates and adds a file input.

      Specified by:
      createFileInput in interface I_CmsUploadButton
      Returns:
      returns the previous file input widget
    • disable

      public void disable(String disabledReason)
      Disables the button and changes the button title attribute to the disabled reason.

      Parameters:
      disabledReason - the disabled reason
    • enable

      public void enable()
      Enables the button, switching the button title attribute from the disabled reason to the original title.

    • getButtonHandler

      Gets the upload button handler instance for this button.

      Specified by:
      getButtonHandler in interface I_CmsUploadButton
      Returns:
      the upload button handler
    • getHorizontalAlignment

      public com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant getHorizontalAlignment()
      This is the alignment of the text in reference to the image, possible values are left or right.

      Specified by:
      getHorizontalAlignment in interface com.google.gwt.user.client.ui.HasHorizontalAlignment
      See Also:
      • HasHorizontalAlignment.getHorizontalAlignment()
    • getImageClass

      Returns the master image class.

      Returns:
      the master image class
    • getSize

      Returns the size.

      Returns:
      the size
    • getText

      public String getText()
      Returns the text.

      Returns:
      the text
    • getTitle

      public String getTitle()
      Returns the title.

      Overrides:
      getTitle in class com.google.gwt.user.client.ui.UIObject
      Returns:
      the title
    • isEnabled

      public boolean isEnabled()
      Returns if the upload button is enabled.

      Returns:
      true if the upload button is enabled
    • isUseMinWidth

      public boolean isUseMinWidth()
      Checks if the button is constraint to a minimal width.

      Returns:
      true if the button is constraint to a minimal width
    • reinitButton

      public void reinitButton(I_CmsUploadButtonHandler buttonHandler)
      Reinitializes the button with a new button handler.

      Specified by:
      reinitButton in interface I_CmsUploadButton
      Parameters:
      buttonHandler - the button handler
    • setButtonStyle

      Sets the button style.

      Parameters:
      style - the style to set
      color - the color to set
    • setEnabled

      public void setEnabled(boolean enabled, String disabledMessage)
      Description copied from interface: I_CmsUploadButton
      Enables / disables the button.
      Specified by:
      setEnabled in interface I_CmsUploadButton
      Parameters:
      enabled - true if the button should be enabled
      disabledMessage - the message to display for disabled buttons
    • setHorizontalAlignment

      public void setHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant align)
      This is the alignment of the text in reference to the image, possible values are left or right.

      Specified by:
      setHorizontalAlignment in interface com.google.gwt.user.client.ui.HasHorizontalAlignment
      See Also:
      • HasHorizontalAlignment.setHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant)
    • setImageClass

      public void setImageClass(String imageClass)
      Sets the master image class.

      Parameters:
      imageClass - the master image class to set
    • setSize

      public void setSize(I_CmsButton.Size size)
      Sets the size.

      Parameters:
      size - the size to set
    • setText

      public void setText(String text)
      Sets the text.

      Parameters:
      text - the text to set
    • setTitle

      public void setTitle(String title)
      Overrides:
      setTitle in class com.google.gwt.user.client.ui.UIObject
      See Also:
      • UIObject.setTitle(java.lang.String)
    • setUpFace

      public void setUpFace(String text, String imageClass)
      Sets the up face text and image.

      Parameters:
      text - the up face text to set, set to null to not show any
      imageClass - the up face image class to use, set to null to not show any
    • setUseMinWidth

      public void setUseMinWidth(boolean useMinWidth)
      Tells the button to use a minimal width.

      Parameters:
      useMinWidth - true to use a minimal width
    • updateFileInput

      public void updateFileInput()
    • getFaceHtml

      protected String getFaceHtml(String text, String imageClass)
      Convenience method to assemble the HTML to use for a button face.

      Parameters:
      text - text the up face text to set, set to null to not show any
      imageClass - the up face image class to use, set to null to not show any
      Returns:
      the HTML
    • handleMouseOut

      @UiHandler("m_main") protected void handleMouseOut(com.google.gwt.event.dom.client.MouseOutEvent event)
      Handles the mouse over event on the main panel.

      Parameters:
      event - the event
      See Also:
      • MouseOutHandler.onMouseOut(com.google.gwt.event.dom.client.MouseOutEvent)
    • handleMouseOver

      @UiHandler("m_main") protected void handleMouseOver(com.google.gwt.event.dom.client.MouseOverEvent event)
      Handles the mouse over event on the main panel.

      Parameters:
      event - the event
      See Also:
      • MouseOverHandler.onMouseOver(com.google.gwt.event.dom.client.MouseOverEvent)