Class Toolbar

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClearHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasVisibilityChangedHandlers, HasMembersChangedHandlers, HasItemClickHandlers, HasItemDragResizedHandlers
Direct Known Subclasses:
MenuBar, TabBar

public class Toolbar extends Layout implements HasItemDragResizedHandlers, HasItemClickHandlers
A Toolbar creates a vertical or horizontal strip of similar components (typically Buttons) and provides managed resizing and reordering behavior over those components.

If you are creating a bar with a mixture of different elements (eg some MenuButtons, some Labels, some Buttons, some custom components), you want to use a ToolStrip. A Toolbar is better suited for managing a set of highly similar, interchangeable components, such as ListGrid headers.

  • Constructor Details

  • Method Details

    • getOrCreateRef

      public static Toolbar getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class Layout
    • setCanAcceptDrop

      public Toolbar setCanAcceptDrop(Boolean canAcceptDrop)
      If true, items (buttons) can be dropped into this toolbar, and the toolbar will show a drop line at the drop location. Override drop() to decide what happens when the item is dropped.

      Note : This is an advanced setting

      Overrides:
      setCanAcceptDrop in class Canvas
      Parameters:
      canAcceptDrop - New canAcceptDrop value. Default value is false
      Returns:
      Toolbar instance, for chaining setter calls
      See Also:
    • getCanAcceptDrop

      public Boolean getCanAcceptDrop()
      If true, items (buttons) can be dropped into this toolbar, and the toolbar will show a drop line at the drop location. Override drop() to decide what happens when the item is dropped.
      Overrides:
      getCanAcceptDrop in class Canvas
      Returns:
      Current canAcceptDrop value. Default value is false
      See Also:
    • setCanReorderItems

      public Toolbar setCanReorderItems(Boolean canReorderItems)
      If true, items can be reordered by dragging on them.

      Note : This is an advanced setting

      Parameters:
      canReorderItems - New canReorderItems value. Default value is false
      Returns:
      Toolbar instance, for chaining setter calls
    • getCanReorderItems

      public Boolean getCanReorderItems()
      If true, items can be reordered by dragging on them.
      Returns:
      Current canReorderItems value. Default value is false
    • setCanResizeItems

      public Toolbar setCanResizeItems(Boolean canResizeItems)
      If true, items (buttons) can be resized by dragging on them.

      If this method is called after the component has been drawn/initialized: Setter for updating canResizeItems at runtime.

      Note : This is an advanced setting

      Parameters:
      canResizeItems - New value for this.canResizeItems. Default value is false
      Returns:
      Toolbar instance, for chaining setter calls
    • getCanResizeItems

      public Boolean getCanResizeItems()
      If true, items (buttons) can be resized by dragging on them.
      Returns:
      Current canResizeItems value. Default value is false
    • setCreateButtonsOnInit

      public Toolbar setCreateButtonsOnInit(Boolean createButtonsOnInit) throws IllegalStateException
      If set to true, causes child buttons to be created during initialization, instead of waiting until draw().

      This property principally exists for backwards compatibility; the default behavior of waiting until draw makes certain pre-draw operations more efficient (such as adding, removing or reordering buttons). However, if you have code that assumes Buttons are created early and crashes if they are not, createButtonsOnInit will allow that code to continue working, with a minor performance penalty.

      Parameters:
      createButtonsOnInit - New createButtonsOnInit value. Default value is null
      Returns:
      Toolbar instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getCreateButtonsOnInit

      public Boolean getCreateButtonsOnInit()
      If set to true, causes child buttons to be created during initialization, instead of waiting until draw().

      This property principally exists for backwards compatibility; the default behavior of waiting until draw makes certain pre-draw operations more efficient (such as adding, removing or reordering buttons). However, if you have code that assumes Buttons are created early and crashes if they are not, createButtonsOnInit will allow that code to continue working, with a minor performance penalty.

      Returns:
      Current createButtonsOnInit value. Default value is null
    • setVertical

      public Toolbar setVertical(Boolean vertical)
      Indicates whether the buttons are drawn horizontally from left to right (false), or vertically from top to bottom (true).
      Overrides:
      setVertical in class Layout
      Parameters:
      vertical - New vertical value. Default value is false
      Returns:
      Toolbar instance, for chaining setter calls
      See Also:
    • getVertical

      public Boolean getVertical()
      Indicates whether the buttons are drawn horizontally from left to right (false), or vertically from top to bottom (true).
      Overrides:
      getVertical in class Layout
      Returns:
      Current vertical value. Default value is false
      See Also:
    • itemDoubleClick

      public void itemDoubleClick(Button item, int itemNum)
      Called when one of the buttons receives a double-click event
      Parameters:
      item - pointer to the button in question
      itemNum - number of the button in question
    • addItemDragResizedHandler

      public HandlerRegistration addItemDragResizedHandler(ItemDragResizedHandler handler)
      Add a itemDragResized handler.

      Called when one of the Toolbar buttons is drag resized.

      Specified by:
      addItemDragResizedHandler in interface HasItemDragResizedHandlers
      Parameters:
      handler - the itemDragResized handler
      Returns:
      HandlerRegistration used to remove this handler
    • addItemClickHandler

      public HandlerRegistration addItemClickHandler(ItemClickHandler handler)
      Add a itemClick handler.

      Called when one of the buttons receives a click event.

      Specified by:
      addItemClickHandler in interface HasItemClickHandlers
      Parameters:
      handler - the itemClick handler
      Returns:
      HandlerRegistration used to remove this handler
    • setDefaultProperties

      public static void setDefaultProperties(Toolbar toolbarProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      toolbarProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(ToolbarLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class Layout