Class CommandToggleGroupModel


  • public class CommandToggleGroupModel
    extends java.lang.Object
    Group of toggle commands.
    • 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 be null.
      • allowsClearingSelection

        private boolean allowsClearingSelection
        If false, the selection cannot be cleared. By default the command group allows clearing the selection in clearSelection() or setSelected(BaseCommand, boolean) (passing the currently selected command and false).
    • Constructor Detail

      • CommandToggleGroupModel

        public CommandToggleGroupModel()
        Creates a new command group.
    • 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. If true is passed, the selection can be cleared in clearSelection() or setSelected(BaseCommand, boolean) (passing the currently selected command and false).
        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 in clearSelection() or setSelected(BaseCommand, boolean) (passing the currently selected command and false).
        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.