Class ClusteredCommand

  • All Implemented Interfaces:
    IUndoRedoCommand

    public class ClusteredCommand
    extends AbstractUndoRedoCommand
    One command to handle many sub-commands, such as a multi-drag/drop etc. All commands inside a clustered command will be Undone/Redone at the same time.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List _commands  
    • Constructor Summary

      Constructors 
      Constructor Description
      ClusteredCommand()
      Creates a new Clustered Command.
      ClusteredCommand​(java.util.List commands)
      Creates a new Clustered Command witha list of pre-set commands.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addCommand​(IUndoRedoCommand command)
      Adds a new command to the cluster.
      void dispose()
      Called when the event is about to be destroyed.
      java.util.List getCommandList()
      Simple getter for the list of commands that are transported by this ClusteredCommand.
      java.util.List getCommands()
      Deprecated.
      Because the name of this method is not unique and might me interpreted wrong.
      java.util.List getEvents()
      Return the individual events that are clustered in this command.
      java.util.List getFlattenedCommands()
      Return the individual commands that are clustered in this command.
      void redo()
      Redoes an event in the chart.
      void removeCommand​(IUndoRedoCommand command)
      Removes a command from the cluster.
      int size()
      Returns the number of commands that are inside the cluster.
      void undo()
      Undoes an event in the chart.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _commands

        private final java.util.List _commands
    • Constructor Detail

      • ClusteredCommand

        public ClusteredCommand()
        Creates a new Clustered Command.
      • ClusteredCommand

        public ClusteredCommand​(java.util.List commands)
        Creates a new Clustered Command witha list of pre-set commands.
    • Method Detail

      • addCommand

        public void addCommand​(IUndoRedoCommand command)
        Adds a new command to the cluster.
        Parameters:
        command - Command to add
      • removeCommand

        public void removeCommand​(IUndoRedoCommand command)
        Removes a command from the cluster.
        Parameters:
        command - Command to remove
      • size

        public int size()
        Returns the number of commands that are inside the cluster.
        Returns:
        Number of commands
      • getCommandList

        public java.util.List getCommandList()
        Simple getter for the list of commands that are transported by this ClusteredCommand.

        Note that this will only return the list of commands as is. There is no transformation made to the list.

        Returns:
        The list of commands that are transported by this ClusteredCommand.
        See Also:
        getFlattenedCommands()
      • dispose

        public void dispose()
        Description copied from interface: IUndoRedoCommand
        Called when the event is about to be destroyed. If any resources need to be cleaned up you should do so here.
      • redo

        public void redo()
        Description copied from interface: IUndoRedoCommand
        Redoes an event in the chart. This should put the event back to the state it was after the event took place.
      • undo

        public void undo()
        Description copied from interface: IUndoRedoCommand
        Undoes an event in the chart. This should put the event back to the state it was prior to the event taking place.
      • getCommands

        public java.util.List getCommands()
        Deprecated.
        Because the name of this method is not unique and might me interpreted wrong.
        Return the individual commands that are clustered in this command. If this ClusteredCommand also contains other ClusteredCommands, they will get unpacked so there will be one flat list of IUndoRedoCommands.
        Returns:
        A unmodifiable list of participating EventMoveCommands.
        See Also:
        getCommandList(), getFlattenedCommands()
      • getFlattenedCommands

        public java.util.List getFlattenedCommands()
        Return the individual commands that are clustered in this command. If this ClusteredCommand also contains other ClusteredCommands, they will get unpacked so there will be one flat list of IUndoRedoCommands.
        Returns:
        A unmodifiable list of participating EventMoveCommands.
        See Also:
        getCommandList()
      • getEvents

        public java.util.List getEvents()
        Return the individual events that are clustered in this command.
        Returns:
        An unmodifiable list of participating GanttEvents.