com.vaadin.client.ui.orderedlayout.
Class Slot
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Panel
-
- com.google.gwt.user.client.ui.SimplePanel
-
- com.vaadin.client.ui.orderedlayout.Slot
-
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.AcceptsOneWidget
,com.google.gwt.user.client.ui.HasOneWidget
,com.google.gwt.user.client.ui.HasVisibility
,com.google.gwt.user.client.ui.HasWidgets
,com.google.gwt.user.client.ui.HasWidgets.ForIsWidget
,com.google.gwt.user.client.ui.IsWidget
,HasErrorIndicatorElement
,Iterable<com.google.gwt.user.client.ui.Widget>
public class Slot extends com.google.gwt.user.client.ui.SimplePanel implements HasErrorIndicatorElement
Represents a slot which contains the actual widget in the layout.
-
-
Field Summary
Fields Modifier and Type Field Description static String
SLOT_CLASSNAME
The default classname for this widget.
-
Constructor Summary
Constructors Constructor Description Slot()
Constructs a slot.
Slot(VAbstractOrderedLayout layout, com.google.gwt.user.client.ui.Widget widget)
Deprecated.
-
Method Summary
All Methods Modifier and Type Method Description AlignmentInfo
getAlignment()
Returns the alignment for the slot.
com.google.gwt.user.client.Element
getCaptionElement()
Get the slots caption element.
CaptionPosition
getCaptionPosition()
Get the position of the caption relative to the slot.
ElementResizeListener
getCaptionResizeListener()
Returns the caption resize listener for this slot if one has been set.
protected com.google.gwt.user.client.Element
getContainerElement()
com.google.gwt.dom.client.Element
getErrorIndicatorElement()
Gets the error indicator element.
double
getExpandRatio()
Get the expand ratio for the slot.
protected int
getHorizontalSpacing()
Get the horizontal amount of pixels of the spacing.
com.google.gwt.user.client.Element
getSpacingElement()
Get the element which is added to make the spacing.
ElementResizeListener
getSpacingResizeListener()
Returns the spacing element resize listener for this slot if one has been set.
protected int
getVerticalSpacing()
Get the vertical amount in pixels of the spacing.
ElementResizeListener
getWidgetResizeListener()
Returns the widget resize listener for this slot if one has been set.
boolean
hasCaption()
Does the slot have a caption.
boolean
hasRelativeHeight()
Returns whether the slot's height is relative.
boolean
hasRelativeWidth()
Returns whether the slot's width is relative.
boolean
hasSpacing()
Does the slot have spacing.
boolean
isRelativeInDirection(boolean vertical)
Returns whether this slot has relative size in the indicated direction.
protected void
onAttach()
void
onBrowserEvent(com.google.gwt.user.client.Event event)
protected void
onDetach()
boolean
remove(com.google.gwt.user.client.ui.Widget w)
void
setAlignment(AlignmentInfo alignment)
Sets how the widget is aligned inside the slot.
void
setCaption(String captionText, Icon icon, List<String> styles, String error, boolean showError, boolean required, boolean enabled)
Set the caption of the slot as text.
void
setCaption(String captionText, Icon icon, List<String> styles, String error, boolean showError, boolean required, boolean enabled, boolean captionAsHtml)
Set the caption of the slot.
void
setCaption(String captionText, Icon icon, List<String> styles, String error, ErrorLevel errorLevel, boolean showError, boolean required, boolean enabled, boolean captionAsHtml)
Set the caption of the slot.
void
setCaption(String captionText, String iconUrl, List<String> styles, String error, boolean showError, boolean required, boolean enabled)
Deprecated.
void
setCaptionPosition(CaptionPosition captionPosition)
Set the position of the caption relative to the slot.
void
setCaptionResizeListener(ElementResizeListener captionResizeListener)
Sets the caption resize listener for this slot.
void
setErrorIndicatorElementVisible(boolean visible)
Sets the visibility of the error indicator element.
void
setExpandRatio(double expandRatio)
Set how the slot should be expanded relative to the other slots.
void
setLayout(VAbstractOrderedLayout layout)
Set the layout in which this slot is.
void
setRelativeHeight(boolean relativeHeight)
Set if the slot has a relative height.
void
setRelativeWidth(boolean relativeWidth)
Set if the slot has a relative width.
void
setSpacing(boolean spacing)
Set the spacing for the slot.
void
setSpacingResizeListener(ElementResizeListener spacingResizeListener)
Sets the spacing element resize listener for this slot.
protected void
setStyleNames(String... stylenames)
Sets the style names for the slot containing the widget.
void
setWidget(com.google.gwt.user.client.ui.Widget w)
void
setWidgetResizeListener(ElementResizeListener widgetResizeListener)
Sets the widget resize listener for this slot.
-
Methods inherited from class com.google.gwt.user.client.ui.SimplePanel
add, getWidget, iterator, setWidget
-
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, 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, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
SLOT_CLASSNAME
public static final String SLOT_CLASSNAME
The default classname for this widget.
See Also:
-
-
Constructor Detail
-
Slot
public Slot()
Constructs a slot. When using this constructor, the layout and widget must be set before any other operations are performed on the slot.
Since:
7.6
-
Slot
@Deprecated public Slot(VAbstractOrderedLayout layout, com.google.gwt.user.client.ui.Widget widget)
Deprecated.Constructs a slot.
Parameters:
layout
- The layout to which this slot belongswidget
- The widget to put in the slot
-
-
Method Detail
-
setLayout
public void setLayout(VAbstractOrderedLayout layout)
Set the layout in which this slot is. This method must be called exactly once at slot construction time when using the default constructor. The method should normally only be called by
VAbstractOrderedLayout.createSlot(Widget)
.Parameters:
layout
- the layout containing the slotSince:
7.6
-
remove
public boolean remove(com.google.gwt.user.client.ui.Widget w)
Specified by:
remove
in interfacecom.google.gwt.user.client.ui.HasWidgets
Overrides:
remove
in classcom.google.gwt.user.client.ui.SimplePanel
-
setWidget
public void setWidget(com.google.gwt.user.client.ui.Widget w)
Specified by:
setWidget
in interfacecom.google.gwt.user.client.ui.HasOneWidget
Overrides:
setWidget
in classcom.google.gwt.user.client.ui.SimplePanel
-
getCaptionResizeListener
public ElementResizeListener getCaptionResizeListener()
Returns the caption resize listener for this slot if one has been set.
Returns:
the listener or
null
if not set
-
setCaptionResizeListener
public void setCaptionResizeListener(ElementResizeListener captionResizeListener)
Sets the caption resize listener for this slot.
Parameters:
captionResizeListener
- the listener to set, ornull
to remove a previously set listener
-
getWidgetResizeListener
public ElementResizeListener getWidgetResizeListener()
Returns the widget resize listener for this slot if one has been set.
Returns:
the listener or
null
if not set
-
setWidgetResizeListener
public void setWidgetResizeListener(ElementResizeListener widgetResizeListener)
Sets the widget resize listener for this slot.
Parameters:
widgetResizeListener
- the listener to set, ornull
to remove a previously set listener
-
getSpacingResizeListener
public ElementResizeListener getSpacingResizeListener()
Returns the spacing element resize listener for this slot if one has been set.
Returns:
the listener or
null
if not set
-
setSpacingResizeListener
public void setSpacingResizeListener(ElementResizeListener spacingResizeListener)
Sets the spacing element resize listener for this slot.
Parameters:
spacingResizeListener
- the listener to set, ornull
to remove a previously set listener
-
getAlignment
public AlignmentInfo getAlignment()
Returns the alignment for the slot.
Returns:
the alignment
-
setStyleNames
protected void setStyleNames(String... stylenames)
Sets the style names for the slot containing the widget.
Parameters:
stylenames
- The style names for the slot
-
setAlignment
public void setAlignment(AlignmentInfo alignment)
Sets how the widget is aligned inside the slot.
Parameters:
alignment
- The alignment inside the slot
-
setExpandRatio
public void setExpandRatio(double expandRatio)
Set how the slot should be expanded relative to the other slots. 0 means that the slot should not participate in the division of space based on the expand ratios but instead be allocated space based on its natural size. Other values causes the slot to get a share of the otherwise unallocated space in proportion to the slot's expand ratio value.
Parameters:
expandRatio
- The ratio of the space the slot should occupy
-
getExpandRatio
public double getExpandRatio()
Get the expand ratio for the slot. The expand ratio describes how the slot should be resized compared to other slots in the layout
Returns:
the expand ratio of the slot
See Also:
-
setSpacing
public void setSpacing(boolean spacing)
Set the spacing for the slot. The spacing determines if there should be empty space around the slot when the slot.
Parameters:
spacing
- Should spacing be enabled
-
getSpacingElement
public com.google.gwt.user.client.Element getSpacingElement()
Get the element which is added to make the spacing.
Returns:
the spacing element
-
hasSpacing
public boolean hasSpacing()
Does the slot have spacing.
Returns:
true
if the slot has spacing,false
otherwise
-
getVerticalSpacing
protected int getVerticalSpacing()
Get the vertical amount in pixels of the spacing.
Returns:
the height of the spacing element or zero if this slot doesn't have spacing
-
getHorizontalSpacing
protected int getHorizontalSpacing()
Get the horizontal amount of pixels of the spacing.
Returns:
the width of the spacing element or zero if this slot doesn't have spacing
-
setCaptionPosition
public void setCaptionPosition(CaptionPosition captionPosition)
Set the position of the caption relative to the slot.
Parameters:
captionPosition
- The position of the caption
-
getCaptionPosition
public CaptionPosition getCaptionPosition()
Get the position of the caption relative to the slot.
Returns:
the position
-
setCaption
@Deprecated public void setCaption(String captionText, String iconUrl, List<String> styles, String error, boolean showError, boolean required, boolean enabled)
Deprecated.Set the caption of the slot.
Parameters:
captionText
- The text of the captioniconUrl
- The icon URL, must already be run trough translateVaadinUri()styles
- The style nameserror
- The error messageshowError
- Should the error message be shownrequired
- Is the (field) requiredenabled
- Is the component enabled
-
setCaption
public void setCaption(String captionText, Icon icon, List<String> styles, String error, boolean showError, boolean required, boolean enabled)
Set the caption of the slot as text.
Parameters:
captionText
- The text of the captionicon
- The iconstyles
- The style nameserror
- The error messageshowError
- Should the error message be shownrequired
- Is the (field) requiredenabled
- Is the component enabled
-
setCaption
public void setCaption(String captionText, Icon icon, List<String> styles, String error, boolean showError, boolean required, boolean enabled, boolean captionAsHtml)
Set the caption of the slot.
Parameters:
captionText
- The text of the captionicon
- The iconstyles
- The style nameserror
- The error messageshowError
- Should the error message be shownrequired
- Is the (field) requiredenabled
- Is the component enabledcaptionAsHtml
- true if the caption should be rendered as HTML, false otherwise
-
setCaption
public void setCaption(String captionText, Icon icon, List<String> styles, String error, ErrorLevel errorLevel, boolean showError, boolean required, boolean enabled, boolean captionAsHtml)
Set the caption of the slot.
Parameters:
captionText
- The text of the captionicon
- The iconstyles
- The style nameserror
- The error messageerrorLevel
- The error levelshowError
- Should the error message be shownrequired
- Is the (field) requiredenabled
- Is the component enabledcaptionAsHtml
- true if the caption should be rendered as HTML, false otherwiseSince:
8.2
-
hasCaption
public boolean hasCaption()
Does the slot have a caption.
Returns:
true
if the slot has a caption,false
otherwise
-
getCaptionElement
public com.google.gwt.user.client.Element getCaptionElement()
Get the slots caption element.
Returns:
the caption element or
null
if there is no caption
-
setRelativeWidth
public void setRelativeWidth(boolean relativeWidth)
Set if the slot has a relative width.
Parameters:
relativeWidth
- True if slot uses relative width, false if the slot has a static width
-
hasRelativeWidth
public boolean hasRelativeWidth()
Returns whether the slot's width is relative.
Returns:
true
if the slot uses relative width,false
if the slot has a static width
-
setRelativeHeight
public void setRelativeHeight(boolean relativeHeight)
Set if the slot has a relative height.
Parameters:
relativeHeight
- True if the slot uses a relative height, false if the slot has a static height
-
hasRelativeHeight
public boolean hasRelativeHeight()
Returns whether the slot's height is relative.
Returns:
true
if the slot uses relative height,false
if the slot has a static height
-
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event event)
Specified by:
onBrowserEvent
in interfacecom.google.gwt.user.client.EventListener
Overrides:
onBrowserEvent
in classcom.google.gwt.user.client.ui.Widget
-
getContainerElement
protected com.google.gwt.user.client.Element getContainerElement()
Overrides:
getContainerElement
in classcom.google.gwt.user.client.ui.SimplePanel
-
onDetach
protected void onDetach()
Overrides:
onDetach
in classcom.google.gwt.user.client.ui.Widget
-
onAttach
protected void onAttach()
Overrides:
onAttach
in classcom.google.gwt.user.client.ui.Widget
-
isRelativeInDirection
public boolean isRelativeInDirection(boolean vertical)
Returns whether this slot has relative size in the indicated direction.
Parameters:
vertical
-true
if the height should be checked,false
if the width should be checkedReturns:
true
if the slot's indicated dimension is relative,false
otherwise
-
getErrorIndicatorElement
public com.google.gwt.dom.client.Element getErrorIndicatorElement()
Description copied from interface:
HasErrorIndicatorElement
Gets the error indicator element.
Specified by:
getErrorIndicatorElement
in interfaceHasErrorIndicatorElement
Returns:
the error indicator element
-
setErrorIndicatorElementVisible
public void setErrorIndicatorElementVisible(boolean visible)
Description copied from interface:
HasErrorIndicatorElement
Sets the visibility of the error indicator element.
Specified by:
setErrorIndicatorElementVisible
in interfaceHasErrorIndicatorElement
Parameters:
visible
-true
to show the error indicator element,false
to hide it
-
-