com.realtime.crossfire.jxclient.shortcuts
Class Shortcuts

java.lang.Object
  extended by com.realtime.crossfire.jxclient.shortcuts.Shortcuts
All Implemented Interfaces:
java.lang.Iterable<Shortcut>

public class Shortcuts
extends java.lang.Object
implements java.lang.Iterable<Shortcut>

Manages a list of Shortcuts.


Field Summary
private  CommandQueue commandQueue
          The command queue for executing commands.
private  java.io.File file
          The backing file.
private  javax.swing.event.EventListenerList listeners
          The listeners to be notified.
private  boolean modified
          Whether the contents of shortcuts have been modified from the last saved state.
private  java.util.List<Shortcut> shortcuts
          The shortcuts.
private  SpellsManager spellsManager
          The SpellsManager instance to watch.
 
Constructor Summary
Shortcuts(CommandQueue commandQueue, SpellsManager spellsManager)
          Creates a new instance.
 
Method Summary
 void addShortcutsListener(ShortcutsListener listener)
          Adds a ShortcutsListener.
 void clearShortcuts()
          Clears all defined shortcuts.
 void executeShortcut(int index)
          Executes a shortcut.
 java.io.File getFile()
          Returns the backing file.
private  Shortcut getShortcut(int index)
          Returns a shortcut.
 boolean isModified()
          Returns whether the shortcuts have been modified since creation or last call to resetModified().
 java.util.Iterator<Shortcut> iterator()
          
 void removeShortcutsListener(ShortcutsListener listener)
          Removes a ShortcutsListener.
 void resetModified()
          Resets the modified state.
 void setCommandShortcut(int index, java.lang.String command)
          Sets a Shortcut to a command.
 void setFile(java.io.File file)
          Sets the backing file.
 void setShortcut(int index, Shortcut shortcut)
          Sets a Shortcut.
 void setSpellShortcut(int index, Spell spell, boolean cast)
          Sets a Shortcut to a spell.
 void setSpellShortcut(int index, java.lang.String spellName, boolean cast)
          Sets a Shortcut to a spell.
 void unsetShortcut(int index)
          Unsets a Shortcut.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandQueue

@NotNull
private final CommandQueue commandQueue
The command queue for executing commands.


file

@Nullable
private java.io.File file
The backing file.


listeners

@NotNull
private final javax.swing.event.EventListenerList listeners
The listeners to be notified.


modified

private boolean modified
Whether the contents of shortcuts have been modified from the last saved state.


shortcuts

@NotNull
private final java.util.List<Shortcut> shortcuts
The shortcuts. Maps index to Shortcut. Unset entries are set to null.


spellsManager

@NotNull
private final SpellsManager spellsManager
The SpellsManager instance to watch.

Constructor Detail

Shortcuts

public Shortcuts(@NotNull
                 CommandQueue commandQueue,
                 @NotNull
                 SpellsManager spellsManager)
Creates a new instance.

Parameters:
commandQueue - the command queue for executing commands
spellsManager - the instance to watch
Method Detail

addShortcutsListener

public void addShortcutsListener(@NotNull
                                 ShortcutsListener listener)
Adds a ShortcutsListener.

Parameters:
listener - the listener to add

clearShortcuts

public void clearShortcuts()
Clears all defined shortcuts.


executeShortcut

public void executeShortcut(int index)
Executes a shortcut. Does nothing if the shortcut is unset.

Parameters:
index - the shortcut index

getFile

@Nullable
public java.io.File getFile()
Returns the backing file.

Returns:
the backing file or null if unknown

getShortcut

@Nullable
private Shortcut getShortcut(int index)
Returns a shortcut.

Parameters:
index - the shortcut index
Returns:
the shortcut or null if the shortcut is unset

isModified

public boolean isModified()
Returns whether the shortcuts have been modified since creation or last call to resetModified().

Returns:
whether anything was modified

iterator

public java.util.Iterator<Shortcut> iterator()

Specified by:
iterator in interface java.lang.Iterable<Shortcut>

removeShortcutsListener

public void removeShortcutsListener(@NotNull
                                    ShortcutsListener listener)
Removes a ShortcutsListener.

Parameters:
listener - the listener to remove

resetModified

public void resetModified()
Resets the modified state.


setCommandShortcut

public void setCommandShortcut(int index,
                               @NotNull
                               java.lang.String command)
Sets a Shortcut to a command.

Parameters:
index - the shortcut index
command - the command to execute

setFile

public void setFile(@Nullable
                    java.io.File file)
Sets the backing file.

Parameters:
file - the backing file or null if unknown

setShortcut

public void setShortcut(int index,
                        @Nullable
                        Shortcut shortcut)
Sets a Shortcut.

Parameters:
index - the shortcut index
shortcut - the shortcut to set or null to unset

setSpellShortcut

public void setSpellShortcut(int index,
                             @NotNull
                             Spell spell,
                             boolean cast)
Sets a Shortcut to a spell.

Parameters:
index - the shortcut index
spell - the spell to cast or invoke
cast - whether the spell should be cast (true) or invoked (false)

setSpellShortcut

public void setSpellShortcut(int index,
                             @NotNull
                             java.lang.String spellName,
                             boolean cast)
Sets a Shortcut to a spell.

Parameters:
index - the shortcut index
spellName - the spell name to cast or invoke
cast - whether the spell should be cast (true) or invoked (false)

unsetShortcut

public void unsetShortcut(int index)
Unsets a Shortcut.

Parameters:
index - the shortcut index