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 ClassesModifier and TypeClassDescriptionprotected 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
FieldsModifier and TypeFieldDescriptionprotected 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
ConstructorsConstructorDescriptionCmsUploadButton
(I_CmsUploadButtonHandler buttonHandler) The default constructor. -
Method Summary
Modifier and TypeMethodDescriptionCreates and adds a file input.void
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 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.getSize()
Returns the size.getText()
Returns the text.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
Returns if the upload button is enabled.boolean
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, 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
setSize
(I_CmsButton.Size size) Sets the size.void
Sets the text.void
void
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
-
Field Details
-
m_buttonFace
The button face. -
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
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 interfaceI_CmsUploadButton
- Returns:
- returns the previous file input widget
-
disable
Disables the button and changes the button title attribute to the disabled reason.- Parameters:
disabledReason
- the disabled reason
-
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 interfaceI_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 interfacecom.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
Returns the text.- Returns:
- the text
-
getTitle
Returns the title.- Overrides:
getTitle
in classcom.google.gwt.user.client.ui.UIObject
- Returns:
- the title
-
isEnabled
Returns if the upload button is enabled.- Returns:
true
if the upload button is enabled
-
isUseMinWidth
Checks if the button is constraint to a minimal width.- Returns:
true
if the button is constraint to a minimal width
-
reinitButton
Reinitializes the button with a new button handler.- Specified by:
reinitButton
in interfaceI_CmsUploadButton
- Parameters:
buttonHandler
- the button handler
-
setButtonStyle
Sets the button style.- Parameters:
style
- the style to setcolor
- the color to set
-
setEnabled
Description copied from interface:I_CmsUploadButton
Enables / disables the button.- Specified by:
setEnabled
in interfaceI_CmsUploadButton
- Parameters:
enabled
- true if the button should be enableddisabledMessage
- 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 interfacecom.google.gwt.user.client.ui.HasHorizontalAlignment
- See Also:
-
HasHorizontalAlignment.setHorizontalAlignment(com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant)
-
setImageClass
Sets the master image class.- Parameters:
imageClass
- the master image class to set
-
setSize
Sets the size.- Parameters:
size
- the size to set
-
setText
Sets the text.- Parameters:
text
- the text to set
-
setTitle
- Overrides:
setTitle
in classcom.google.gwt.user.client.ui.UIObject
- See Also:
-
UIObject.setTitle(java.lang.String)
-
setUpFace
Sets the up face text and image.- Parameters:
text
- the up face text to set, set tonull
to not show anyimageClass
- the up face image class to use, set tonull
to not show any
-
setUseMinWidth
Tells the button to use a minimal width.- Parameters:
useMinWidth
-true
to use a minimal width
-
updateFileInput
-
getFaceHtml
Convenience method to assemble the HTML to use for a button face.- Parameters:
text
- text the up face text to set, set tonull
to not show anyimageClass
- the up face image class to use, set tonull
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)
-