Class CommandToggleGroupModel
- java.lang.Object
-
- org.pushingpixels.radiance.component.api.common.model.CommandToggleGroupModel
-
public class CommandToggleGroupModel extends java.lang.Object
Group of toggle commands.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowsClearingSelection
Iffalse
, the selection cannot be cleared.private java.util.Vector<BaseCommand>
commands
Contains all group commands.private java.util.Map<BaseCommand,javax.swing.event.ChangeListener>
modelChangeListeners
Map of registered model change listeners.private BaseCommand
selection
The currently selected command.
-
Constructor Summary
Constructors Constructor Description CommandToggleGroupModel()
Creates a new command group.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(BaseCommand command)
Adds the specified command to the group.void
clearSelection()
Clears the selection of this command toggle group model.java.util.Collection<BaseCommand>
getCommands()
Returns an unmodifiable collection with all the commands tracked by this model.BaseCommand
getSelected()
Returns the selected command of this group model.boolean
isAllowsClearingSelection()
Returns the current value for clearing selection.void
remove(BaseCommand command)
Removes the specified command from the group.void
removeAll()
void
setAllowsClearingSelection(boolean allowsClearingSelection)
Sets the new value for clearing selection.void
setSelected(BaseCommand command, boolean isSelected)
Changes the selected status of the specified command.
-
-
-
Field Detail
-
commands
private java.util.Vector<BaseCommand> commands
Contains all group commands.
-
modelChangeListeners
private java.util.Map<BaseCommand,javax.swing.event.ChangeListener> modelChangeListeners
Map of registered model change listeners.
-
selection
private BaseCommand selection
The currently selected command. Can benull
.
-
allowsClearingSelection
private boolean allowsClearingSelection
Iffalse
, the selection cannot be cleared. By default the command group allows clearing the selection inclearSelection()
orsetSelected(BaseCommand, boolean)
(passing the currently selected command andfalse
).
-
-
Method Detail
-
getCommands
public java.util.Collection<BaseCommand> getCommands()
Returns an unmodifiable collection with all the commands tracked by this model.- Returns:
- An unmodifiable collection with all the commands tracked by this model.
-
setAllowsClearingSelection
public void setAllowsClearingSelection(boolean allowsClearingSelection)
Sets the new value for clearing selection. Iftrue
is passed, the selection can be cleared inclearSelection()
orsetSelected(BaseCommand, boolean)
(passing the currently selected command andfalse
).- Parameters:
allowsClearingSelection
- The new value for clearing selection.
-
isAllowsClearingSelection
public boolean isAllowsClearingSelection()
Returns the current value for clearing selection.true
is returned when selection can be cleared inclearSelection()
orsetSelected(BaseCommand, boolean)
(passing the currently selected command andfalse
).- Returns:
- The current value for clearing selection.
-
add
public void add(BaseCommand command)
Adds the specified command to the group. If the command is selected, and the group has a selected command, the newly added command is marked as unselected.- Parameters:
command
- The command to be added.
-
remove
public void remove(BaseCommand command)
Removes the specified command from the group.- Parameters:
command
- The command to be removed
-
removeAll
public void removeAll()
-
setSelected
public void setSelected(BaseCommand command, boolean isSelected)
Changes the selected status of the specified command.- Parameters:
command
- command.isSelected
- Selection indication.
-
getSelected
public BaseCommand getSelected()
Returns the selected command of this group model.- Returns:
- The selected command of this group model. The result can be
null
.
-
clearSelection
public void clearSelection()
Clears the selection of this command toggle group model.
-
-