Package com.e1c.langtool.ui.common.combo
Class MenuActionComboBox<T>
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.action.AbstractAction
org.eclipse.jface.action.Action
com.e1c.langtool.ui.common.combo.MenuActionComboBox<T>
- All Implemented Interfaces:
IComboBox<T>,org.eclipse.jface.action.IAction,org.eclipse.jface.action.IMenuCreator
public class MenuActionComboBox<T>
extends org.eclipse.jface.action.Action
implements IComboBox<T>, org.eclipse.jface.action.IAction, org.eclipse.jface.action.IMenuCreator
The implementation of combobox based on
Action with dropdown menu.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe factory is used to create items forMenuActionComboBox.static classThe base implementation of contribution item factory. -
Field Summary
Fields inherited from interface org.eclipse.jface.action.IAction
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT -
Constructor Summary
ConstructorsConstructorDescriptionMenuActionComboBox(MenuActionComboBox.IContributionItemFactory<T> itemFactory) Creates a new combobox.MenuActionComboBox(ILabelProvider labelProvider) Creates a new combobox with default item factoryMenuActionComboBox.ItemFactorythat initialized by this combobox and the given label provider.MenuActionComboBox(ILabelProvider labelProvider, List<T> content) Creates a new combobox with default item factoryMenuActionComboBox.ItemFactorythat initialized by this combobox and the given label provider. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the new item at the given zero-relative index.voidAdds the new item to the end of this combo.voidaddSelectionListener(org.eclipse.swt.events.SelectionListener selectionListener) Adds the listener that will be notified when the methodsselect(int)ordeselect()are called.voidclear()Removes all items from this combobox.intcount()Returns the number of items contained in this combobox.voiddeselect()Deselects the currently selected item.voiddispose()getItem(int index) Returns item at the given zero-relative index.org.eclipse.swt.widgets.MenugetMenu(org.eclipse.swt.widgets.Control parent) org.eclipse.swt.widgets.MenugetMenu(org.eclipse.swt.widgets.Menu parent) intReturns the index of currently selected item or-1if there is not any selected item.Returns the currently selected item orOptional.empty()if there is not any selected item.intReturns the index of the given item or-1if the given item is not found.voidremoveItem(int index) Removes the item at the given zero-relative index.voidremoveSelectionListener(org.eclipse.swt.events.SelectionListener selectionListener) Removes the given selection listener from the collection of listeners for this combobox.voidselect(int index) Selects the item at the zero-relative index.Methods inherited from class org.eclipse.jface.action.Action
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, run, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipTextMethods inherited from class org.eclipse.jface.action.AbstractAction
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListenerMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.jface.action.IAction
addPropertyChangeListener, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, removePropertyChangeListener, run, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
-
Constructor Details
-
MenuActionComboBox
Creates a new combobox.- Parameters:
itemFactory- the factory to create items for dropdown menu
-
MenuActionComboBox
Creates a new combobox with default item factoryMenuActionComboBox.ItemFactorythat initialized by this combobox and the given label provider.- Parameters:
labelProvider- the label provider is used for item factory- See Also:
-
MenuActionComboBox
Creates a new combobox with default item factoryMenuActionComboBox.ItemFactorythat initialized by this combobox and the given label provider. Also this constructor creates a combobox with content is provided by the given list.Note that methods of this class are not thread safe, so be careful with concurrent modification issues using an external list to store items.
- Parameters:
labelProvider- the label provider is used for item factorycontent- a list to provide elements- See Also:
-
-
Method Details
-
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener selectionListener) Adds the listener that will be notified when the methodsselect(int)ordeselect()are called.- Parameters:
selectionListener- the listener which should be notified- See Also:
-
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener selectionListener) Removes the given selection listener from the collection of listeners for this combobox.- Parameters:
selectionListener- the listener which should no longer be notified
-
dispose
public void dispose()- Specified by:
disposein interfaceorg.eclipse.jface.action.IMenuCreator
-
getMenu
public org.eclipse.swt.widgets.Menu getMenu(org.eclipse.swt.widgets.Control parent) - Specified by:
getMenuin interfaceorg.eclipse.jface.action.IMenuCreator
-
getMenu
public org.eclipse.swt.widgets.Menu getMenu(org.eclipse.swt.widgets.Menu parent) - Specified by:
getMenuin interfaceorg.eclipse.jface.action.IMenuCreator
-
deselect
public void deselect()Description copied from interface:IComboBoxDeselects the currently selected item. It does nothing if there is not any selected item.Note that after deselecting method
IComboBox.getSelectionIndex()returns-1andIComboBox.getSelectionItem()returns emptyOptional -
select
public void select(int index) Description copied from interface:IComboBoxSelects the item at the zero-relative index. -
indexOf
Description copied from interface:IComboBoxReturns the index of the given item or-1if the given item is not found.It starts to search item in the list and returns the index of the first founded item that equals to the given object.
-
addItem
Description copied from interface:IComboBoxAdds the new item at the given zero-relative index.- Specified by:
addItemin interfaceIComboBox<T>- Parameters:
index- the index to add item in range from0to.IComboBox.count()item- the new item to add
-
addItem
Description copied from interface:IComboBoxAdds the new item to the end of this combo. -
removeItem
public void removeItem(int index) Description copied from interface:IComboBoxRemoves the item at the given zero-relative index.- Specified by:
removeItemin interfaceIComboBox<T>- Parameters:
index- the index of item to remove
-
clear
public void clear()Description copied from interface:IComboBoxRemoves all items from this combobox. -
getItem
Description copied from interface:IComboBoxReturns item at the given zero-relative index. -
count
public int count()Description copied from interface:IComboBoxReturns the number of items contained in this combobox. -
getSelectionIndex
public int getSelectionIndex()Description copied from interface:IComboBoxReturns the index of currently selected item or-1if there is not any selected item.- Specified by:
getSelectionIndexin interfaceIComboBox<T>- Returns:
- the index of currently selected item or
-1if there is not any selected item
-
getSelectionItem
Description copied from interface:IComboBoxReturns the currently selected item orOptional.empty()if there is not any selected item.- Specified by:
getSelectionItemin interfaceIComboBox<T>- Returns:
- the currently selected item or
Optional.empty()if there is not any selected item. - See Also:
-