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
CmsUploadButton.I_CmsUploadButtonUiBinder
The ui-binder interface.
-
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.
-
Constructor Summary
Constructors Constructor Description CmsUploadButton(I_CmsUploadButtonHandler buttonHandler)
The default constructor.
-
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
-
-
-
-
Field Detail
-
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 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
-
createFileInput
public CmsFileInput createFileInput()
Creates and adds a file input.- Specified by:
createFileInput
in interfaceI_CmsUploadButton
- Returns:
- returns the previous file input widget
-
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.
-
getButtonHandler
public I_CmsUploadButtonHandler 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
public java.lang.String getImageClass()
Returns the master image class.- Returns:
- the master image class
-
getSize
public I_CmsButton.Size getSize()
Returns the size.- Returns:
- the size
-
getText
public java.lang.String getText()
Returns the text.- Returns:
- the text
-
getTitle
public java.lang.String getTitle()
Returns the title.- Overrides:
getTitle
in classcom.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 interfaceI_CmsUploadButton
- Parameters:
buttonHandler
- the button handler
-
setButtonStyle
public void setButtonStyle(I_CmsButton.ButtonStyle style, I_CmsButton.ButtonColor color)
Sets the button style.- Parameters:
style
- the style to setcolor
- the color to set
-
setEnabled
public void setEnabled(boolean enabled, java.lang.String disabledMessage)
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
public void setImageClass(java.lang.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(java.lang.String text)
Sets the text.- Parameters:
text
- the text to set
-
setTitle
public void setTitle(java.lang.String title)
- Overrides:
setTitle
in classcom.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 tonull
to not show anyimageClass
- the up face image class to use, set tonull
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 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 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)
-
-