Package com.iizix.swt

Class DropdownSelectionListener

java.lang.Object
com.iizix.swt.DropdownSelectionListener
All Implemented Interfaces:
org.eclipse.swt.widgets.Listener

public class DropdownSelectionListener extends Object implements org.eclipse.swt.widgets.Listener
Class used as helper for toolbar drop-down items.
Author:
Christopher Mindus
  • Constructor Summary

    Constructors
    Constructor
    Description
    DropdownSelectionListener(org.eclipse.swt.widgets.ToolItem dropdown)
    Creates a drop-down handler for a drop-down toolbar item.
    DropdownSelectionListener(org.eclipse.swt.widgets.ToolItem dropdown, boolean lastDefault)
    Creates a drop-down handler for a drop-down toolbar item.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(String item, int style, org.eclipse.swt.widgets.Listener select)
    Adds a menu item with a selection listener to the drop-down menu.
    add(String item, int style, org.eclipse.swt.widgets.Listener select, boolean isDefault)
    Adds a menu item with a selection listener to the drop-down menu.
    add(String item, org.eclipse.swt.graphics.Image image, int style, org.eclipse.swt.widgets.Listener select)
    Adds a menu item with a selection listener to the drop-down menu.
    add(String item, org.eclipse.swt.graphics.Image image, int style, org.eclipse.swt.widgets.Listener select, boolean isDefault)
    Adds a menu item with a selection listener to the drop-down menu.
    add(String item, org.eclipse.swt.graphics.Image image, org.eclipse.swt.widgets.Listener select)
    Adds a menu item with a selection listener to the drop-down menu.
    add(String item, org.eclipse.swt.graphics.Image image, org.eclipse.swt.widgets.Listener select, boolean isDefault)
    Adds a menu item with a selection listener to the drop-down menu.
    add(String item, org.eclipse.swt.widgets.Listener select)
    Adds a menu item with a selection listener to the drop-down menu.
    add(String item, org.eclipse.swt.widgets.Listener select, boolean isDefault)
    Adds a menu item with a selection listener to the drop-down menu.
    add(org.eclipse.jface.action.IAction action)
    Adds an action that has a text and image.
    void
    addInitializer(IDropdownMenuInitializer init, int keepMenuItemCount)
    Adds a menu initializer.
    void
    Adds a menu listener when the menu becomes visible.
    void
    Adds a separator line.
    void
    Removes all menu items.
    void
    clearMenu(int keepMenuItemCount)
    Removes menu items from the bottom, keeping "count" menu items.
    Gets the menu.
    void
    handleEvent(org.eclipse.swt.widgets.Event event)
    Process selection.
    void
    Sets the default item.
    void
    setDefaultSelected(IzMenuItem mi, boolean forceLastDefault)
    Sets the default item.
    void
    Shows the drop-down menu.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DropdownSelectionListener

      public DropdownSelectionListener(org.eclipse.swt.widgets.ToolItem dropdown)
      Creates a drop-down handler for a drop-down toolbar item.
      Parameters:
      dropdown - The drop-down toolbar item.
    • DropdownSelectionListener

      public DropdownSelectionListener(org.eclipse.swt.widgets.ToolItem dropdown, boolean lastDefault)
      Creates a drop-down handler for a drop-down toolbar item.
      Parameters:
      dropdown - The drop-down toolbar item.
      lastDefault - Last item becomes the default one.
  • Method Details

    • getMenu

      public IzMenu getMenu()
      Gets the menu.
    • addMenuListener

      public void addMenuListener(Runnable listener)
      Adds a menu listener when the menu becomes visible.
      Parameters:
      listener - The menu listener.
    • add

      public IzMenuItem add(String item, org.eclipse.swt.widgets.Listener select)
      Adds a menu item with a selection listener to the drop-down menu.
      Parameters:
      item - The text for the item.
      select - The selection listener.
      Returns:
      The added menu item.
    • add

      public IzMenuItem add(String item, org.eclipse.swt.graphics.Image image, org.eclipse.swt.widgets.Listener select)
      Adds a menu item with a selection listener to the drop-down menu.
      Parameters:
      item - The text for the item.
      image - The image or null for none.
      select - The selection listener.
      Returns:
      The added menu item.
    • add

      public IzMenuItem add(String item, int style, org.eclipse.swt.widgets.Listener select)
      Adds a menu item with a selection listener to the drop-down menu.
      Parameters:
      item - The text for the item.
      style - The style, a combination of SWT flags, default SWT.NONE.
      select - The selection listener.
      Returns:
      The added menu item.
    • add

      public IzMenuItem add(String item, org.eclipse.swt.graphics.Image image, int style, org.eclipse.swt.widgets.Listener select)
      Adds a menu item with a selection listener to the drop-down menu.
      Parameters:
      item - The text for the item.
      image - The image or null for none.
      style - The style, a combination of SWT flags, default SWT.NONE.
      select - The selection listener.
      Returns:
      The added menu item.
    • add

      public IzMenuItem add(String item, org.eclipse.swt.widgets.Listener select, boolean isDefault)
      Adds a menu item with a selection listener to the drop-down menu.
      Parameters:
      item - The text for the item.
      select - The selection listener.
      isDefault - Flag for default selection in the pull-down menu.
      Returns:
      The added menu item.
    • add

      public IzMenuItem add(String item, org.eclipse.swt.graphics.Image image, org.eclipse.swt.widgets.Listener select, boolean isDefault)
      Adds a menu item with a selection listener to the drop-down menu.
      Parameters:
      item - The text for the item.
      image - The image or null for none.
      select - The selection listener.
      isDefault - Flag for default selection in the pull-down menu.
      Returns:
      The added menu item.
    • add

      public IzMenuItem add(String item, int style, org.eclipse.swt.widgets.Listener select, boolean isDefault)
      Adds a menu item with a selection listener to the drop-down menu.
      Parameters:
      item - The text for the item.
      style - The style, a combination of SWT flags, default SWT.NONE.
      select - The selection listener.
      isDefault - Flag for default selection in the pull-down menu.
      Returns:
      The added menu item.
    • add

      public IzMenuItem add(String item, org.eclipse.swt.graphics.Image image, int style, org.eclipse.swt.widgets.Listener select, boolean isDefault)
      Adds a menu item with a selection listener to the drop-down menu.
      Parameters:
      item - The text for the item.
      image - The image or null for none.
      style - The style, a combination of SWT flags, default SWT.NONE.
      select - The selection listener.
      isDefault - Flag for default selection in the pull-down menu.
      Returns:
      The added menu item.
    • addSeparator

      public void addSeparator()
      Adds a separator line.
    • add

      public IzMenuItem add(org.eclipse.jface.action.IAction action)
      Adds an action that has a text and image. The action is wrapped with an ActionContributionItem that creates the menu item.
      Parameters:
      action - The action to add.
      Returns:
      The menu item created.
    • setDefaultSelected

      public void setDefaultSelected(IzMenuItem mi)
      Sets the default item.
    • setDefaultSelected

      public void setDefaultSelected(IzMenuItem mi, boolean forceLastDefault)
      Sets the default item.
    • handleEvent

      public void handleEvent(org.eclipse.swt.widgets.Event event)
      Process selection.
      Specified by:
      handleEvent in interface org.eclipse.swt.widgets.Listener
    • clearMenu

      public void clearMenu()
      Removes all menu items.
    • clearMenu

      public void clearMenu(int keepMenuItemCount)
      Removes menu items from the bottom, keeping "count" menu items.
    • addInitializer

      public void addInitializer(IDropdownMenuInitializer init, int keepMenuItemCount)
      Adds a menu initializer.
      Parameters:
      init - The menu initializer.
      keepMenuItemCount - Item count to keep in the menu (-1 for all).
    • showMenu

      public void showMenu()
      Shows the drop-down menu.