Class 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  CmsUploadButton.I_CmsUploadButtonUiBinder
      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 m_buttonFace
      The button face.
      protected CmsFlowPanel m_main
      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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CmsFileInput createFileInput()
      Creates and adds a file input.
      void disable​(java.lang.String disabledReason)
      Disables the button and changes the button title attribute to the disabled reason.
      void enable()
      Enables the button, switching the button title attribute from the disabled reason to the original title.
      static java.lang.String formatBytes​(long filesize)
      Formats a given bytes value (file size).
      I_CmsUploadButtonHandler getButtonHandler()
      Gets the upload button handler instance for this button.
      protected java.lang.String getFaceHtml​(java.lang.String text, java.lang.String imageClass)
      Convenience method to assemble the HTML to use for a button face.
      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.
      java.lang.String getImageClass()
      Returns the master image class.
      I_CmsButton.Size getSize()
      Returns the size.
      java.lang.String getText()
      Returns the text.
      java.lang.String getTitle()
      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 isEnabled()
      Returns if the upload button is enabled.
      boolean isUseMinWidth()
      Checks if the button is constraint to a minimal width.
      void reinitButton​(I_CmsUploadButtonHandler buttonHandler)
      Reinitializes the button with a new button handler.
      void setButtonStyle​(I_CmsButton.ButtonStyle style, I_CmsButton.ButtonColor color)
      Sets the button style.
      void setEnabled​(boolean enabled, java.lang.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​(java.lang.String imageClass)
      Sets the master image class.
      void setSize​(I_CmsButton.Size size)
      Sets the size.
      void setText​(java.lang.String text)
      Sets the text.
      void setTitle​(java.lang.String title)  
      void setUpFace​(java.lang.String text, java.lang.String imageClass)
      Sets the up face text and image.
      void setUseMinWidth​(boolean useMinWidth)
      Tells the button to use a minimal width.
      void updateFileInput()  
      • 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 Detail

      • m_buttonFace

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

      • CmsUploadButton

        public CmsUploadButton​(I_CmsUploadButtonHandler buttonHandler)
        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 Detail

      • formatBytes

        public static java.lang.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
      • disable

        public void disable​(java.lang.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.

      • 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

        public java.lang.String getImageClass()
        Returns the master image class.

        Returns:
        the master image class
      • getText

        public java.lang.String getText()
        Returns the text.

        Returns:
        the text
      • getTitle

        public java.lang.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
      • setEnabled

        public void setEnabled​(boolean enabled,
                               java.lang.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​(java.lang.String imageClass)
        Sets the master image class.

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

        public void setText​(java.lang.String text)
        Sets the text.

        Parameters:
        text - the text to set
      • setTitle

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

        public void setUpFace​(java.lang.String text,
                              java.lang.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
      • getFaceHtml

        protected java.lang.String getFaceHtml​(java.lang.String text,
                                               java.lang.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)