public class TLcyComboBoxActionBar extends ALcyActionBar implements ILcyToolBar
Implementation of ILcyActionBar
that is represented as a combo
box. Its items are displayed in the drop-down. Sub-menus aren't supported.
It is meant to contain a series of ILcyActiveSettables
s that behave similar to radio
buttons (only one button of a series is active at a time). It does not support check box style
active settables. This means aDeactivatePossible
of the insertActiveSettable
method must be false
.
It can also contain regular ILcdAction
s. The active settable that is active is displayed
as the current value of the combo box, also when it is collapsed.
The difference with a regular sub-menu of a TLcyToolBar
is that a combo box
provides feedback on the currently selected item without having to expand the menu.
Consider a TLcyComboBoxActionBar
having a series of active settables,
each enabling a certain projection on the map. The active settables themselves listen to the map,
and when the projection is changed, they update their 'active' state accordingly. Suppose there
also is a regular action that can be used to pop up a dialog, showing some additional projection
properties.
If you select such a projection active settable from the combo box, it gets activated by this action bar. The active settable that used to be active now becomes inactive, as it was notified by the map that another projection was activated (by a third party). At all times, the collapsed combo box shows the current map projection. If you select the regular action from the combo, the dialog is shown, but the active state of all active settables remains unchanged.
aDeactivatePossible
of the insertActiveSettable
method
must be false
, an exception is thrown otherwise.ILcyCustomizableRepresentationAction
or
ILcyCustomizableRepresentationActiveSettable
Constructor and Description |
---|
TLcyComboBoxActionBar()
Creates a new
TLcyComboBoxActionBar , ready to be used. |
TLcyComboBoxActionBar(ALcyHelpManager aHelpManager)
Creates a new
TLcyComboBoxActionBar , ready to be used. |
Modifier and Type | Method and Description |
---|---|
protected Component |
createItem(ILcdAction aAction,
TLcyGroupDescriptor aGroupDescriptor,
String[] aMenus,
TLcyGroupDescriptor[] aMenuGroupDescriptors)
Creates a gui widget to represent the given action.
|
protected Component |
createItem(ILcyActiveSettable aActiveSettable,
TLcyGroupDescriptor aGroupDescriptor,
String[] aMenus,
TLcyGroupDescriptor[] aMenuGroupDescriptors,
boolean aDeactivatePossible)
Creates a gui widget to represent the given active settable.
|
protected Container |
createItemContainer(String[] aMenus,
TLcyGroupDescriptor[] aMenuGroupDescriptors)
Creates a new container for the given (sub)menus.
|
protected Component[] |
getChildren(Container aParent)
Returns all children of a given parent, including separators etc.
|
Component |
getComponent()
Returns the visual component representing this action bar, so that it can be
added to the application UI.
|
protected Container |
getItemContainer(String[] aMenus,
TLcyGroupDescriptor[] aMenuGroupDescriptors)
Retrieves the (sub)menu container that contains the actions or active
settables at the given (sub)menus.
|
protected Container |
getParent(Component aComponent)
Returns the parent of a given component.
|
protected void |
insertSeparator(int aIndex,
Container aContainerSFCT)
Inserts a separator at the given index into the given component.
|
boolean |
isAutoHide()
Returns the autoHide property of the action bar.
|
protected void |
removeSeparator(int aIndex,
Container aContainerSFCT)
Removes the separator at the given index from the given component.
|
void |
setAutoHide(boolean aAutoHide)
Set the autoHide property of the action bar.
|
addActionBarListener, getActionBarItem, getActionBarItemComparator, getActionBarItemCount, getGroupDescriptorComparator, getHelpManager, getProperties, insertAction, insertAction, insertActiveSettable, insertActiveSettable, insertActiveSettable, insertChildInParent, insertComponent, removeAction, removeActionBarListener, removeActiveSettable, removeChildFromParent, removeComponent, retrieveDeactivatePossible, retrieveGroupDescriptor, retrieveGroupDescriptor, retrieveHelpIDString, retrieveHelpIDString, retrieveMenuGroupDescriptors, retrieveMenuGroupDescriptors, retrieveMenus, retrieveMenus, setActionBarItemComparator, setGroupDescriptorComparator, setHelpIDString, setHelpIDString, setHelpManager, setProperties
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
insertComponent, removeComponent
addActionBarListener, getActionBarItem, getActionBarItemCount, insertAction, insertAction, insertActiveSettable, insertActiveSettable, insertActiveSettable, removeAction, removeActionBarListener, removeActiveSettable, retrieveDeactivatePossible, retrieveGroupDescriptor, retrieveGroupDescriptor, retrieveHelpIDString, retrieveHelpIDString, retrieveMenuGroupDescriptors, retrieveMenuGroupDescriptors, retrieveMenus, retrieveMenus, setHelpIDString, setHelpIDString
public TLcyComboBoxActionBar()
TLcyComboBoxActionBar
, ready to be used.public TLcyComboBoxActionBar(ALcyHelpManager aHelpManager)
TLcyComboBoxActionBar
, ready to be used.aHelpManager
- The help manager.public boolean isAutoHide()
Returns the autoHide property of the action bar.
When the autoHide property is true
, the component of the action bar will become
invisible when it is empty.
This action bar is considered empty when the combo-box does not contain any items.
isAutoHide
in class ALcyActionBar
ALcyActionBar.setAutoHide(boolean)
public void setAutoHide(boolean aAutoHide)
Set the autoHide property of the action bar.
When set to true
, the component of the action bar will become invisible when the action bar
is empty.
The default implementation of this method considers an action bar empty when the component
representing the action bar is a Container
without any visible child components.
This action bar is considered empty when the combo-box does not contain any items.
setAutoHide
in class ALcyActionBar
aAutoHide
- true
when the an empty action bar must be invisible, false
otherwise.ALcyActionBar.isAutoHide()
public Component getComponent()
ILcyActionBar
Returns the visual component representing this action bar, so that it can be added to the application UI.
Components should not be added to it or removed from it directly using Swing. Use the various insert methods instead.
getComponent
in interface ILcyActionBar
protected Component createItem(ILcdAction aAction, TLcyGroupDescriptor aGroupDescriptor, String[] aMenus, TLcyGroupDescriptor[] aMenuGroupDescriptors)
ALcyActionBar
JMenuItem
to represent the given action. A toolbar
could create a JButton
to represent the given action.createItem
in class ALcyActionBar
aAction
- The action to create a gui widget for.aGroupDescriptor
- The group descriptor, for information only.aMenus
- The menus, for information only.aMenuGroupDescriptors
- The menu group descriptors, for information only.protected Component createItem(ILcyActiveSettable aActiveSettable, TLcyGroupDescriptor aGroupDescriptor, String[] aMenus, TLcyGroupDescriptor[] aMenuGroupDescriptors, boolean aDeactivatePossible)
ALcyActionBar
JCheckBoxMenuItem
to represent the given
action or a JRadioButtonMenuItem
when
aDeactivatePossible
is false. A toolbar could create a
JToggleButton
to represent the given active settable.createItem
in class ALcyActionBar
aActiveSettable
- The active settable to create a gui widget for.aGroupDescriptor
- The group descriptor, for information only.aMenus
- The menus, for information only.aMenuGroupDescriptors
- The menu group descriptors, for information only.aDeactivatePossible
- True means the active settable can be
deactivated using the created gui widget (e.g. a checkbox), false means it
cannot be deactivated by the created gui widget, probably only by another
widget (e.g. radio button).protected Container getItemContainer(String[] aMenus, TLcyGroupDescriptor[] aMenuGroupDescriptors)
ALcyActionBar
getItemContainer
in class ALcyActionBar
aMenus
- The (sub)menus to retrieve the container for. If null or an
empty array, the top level container should be returned.aMenuGroupDescriptors
- The menu group descriptors, just for
information. Could be null, or the length of the array can possibly
mismatch the length of the menus.protected Container createItemContainer(String[] aMenus, TLcyGroupDescriptor[] aMenuGroupDescriptors)
ALcyActionBar
An example implemention could look like this:
return new JMenu( aMenus[ aMenus.length - 1 ] )
createItemContainer
in class ALcyActionBar
aMenus
- The (sub)menus to create the menu item container for. Is
never null and length of array is at least 1.aMenuGroupDescriptors
- The menu group descriptors for the menus.
Could be null, or the length of the array can possibly mismatch the
length of the menus.protected void insertSeparator(int aIndex, Container aContainerSFCT)
ALcyActionBar
Implementation can be left empty, but if and only if implementation of
ALcyActionBar.removeSeparator(int, java.awt.Container)
is left empty as well.
insertSeparator
in class ALcyActionBar
aIndex
- The index of where to insert the separator. -1 means insert it at the end.aContainerSFCT
- The container to insert the separator into.protected void removeSeparator(int aIndex, Container aContainerSFCT)
ALcyActionBar
Implementation can be left empty, but if and only if implementation of
ALcyActionBar.insertSeparator(int, java.awt.Container)
is left empty as well.
removeSeparator
in class ALcyActionBar
aIndex
- The index where to remove the separator from the given component.aContainerSFCT
- The container to remove the separator from.protected Component[] getChildren(Container aParent)
ALcyActionBar
This implementation returns
aParent.getComponents()
, but subclasses using for instance
JMenu
s should be aware that they should return ( ( JMenu
) aParent ).getMenuComponents()
when the given parent is a
JMenu
.
getChildren
in class ALcyActionBar
aParent
- The parent to retrieve the children from.protected Container getParent(Component aComponent)
ALcyActionBar
This implementation returns
aComponent.getParent()
, but subclasses using for instance
JPopupMenu
s (these are used for example by
JMenu
s) must return ( ( JPopupMenu ) aComponent
).getInvoker()
when the given component is a
JPopupMenu
.
getParent
in class ALcyActionBar
aComponent
- The component to retrieve the parent for.