com.realtime.crossfire.jxclient.guistate
Class GuiStateManager

java.lang.Object
  extended by com.realtime.crossfire.jxclient.guistate.GuiStateManager

public class GuiStateManager
extends java.lang.Object

Maintains the current GuiState. Notifies registered listeners about changes.


Field Summary
private  ClientSocketListener clientSocketListener
          The ClientSocketListener used to detect connection state changes.
private  CrossfireServerConnectionListener crossfireServerConnectionListener
          The CrossfireServerConnectionListener used to detect connection progress changes.
private  GuiState guiState
          The current GUI state.
private  java.util.Collection<GuiStateListener> guiStateListeners
          The connection state listeners to notify.
private  java.lang.Object sync
          The synchronization object for accessing guiState.
 
Constructor Summary
GuiStateManager(CrossfireServerConnection crossfireServerConnection)
          Creates a new instance.
 
Method Summary
 void addGuiStateListener(GuiStateListener listener)
          Adds a gui state listener.
 void changeGUI(GuiState guiState)
          Sets a new GuiState.
private  void changeGUI(GuiState guiState, java.lang.String param)
          Sets a new GuiState.
 void connect(java.lang.String serverInfo)
          Connects to a Crossfire server.
 void disconnect()
          Disconnects from the Crossfire server.
 GuiState getGuiState()
          Returns the current GuiState.
 void removeGuiStateListener(GuiStateListener listener)
          Removes a gui state listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clientSocketListener

@NotNull
private final ClientSocketListener clientSocketListener
The ClientSocketListener used to detect connection state changes.


crossfireServerConnectionListener

@NotNull
private final CrossfireServerConnectionListener crossfireServerConnectionListener
The CrossfireServerConnectionListener used to detect connection progress changes.


guiState

@Nullable
private GuiState guiState
The current GUI state.


guiStateListeners

@NotNull
private final java.util.Collection<GuiStateListener> guiStateListeners
The connection state listeners to notify.


sync

@NotNull
private final java.lang.Object sync
The synchronization object for accessing guiState.

Constructor Detail

GuiStateManager

public GuiStateManager(@NotNull
                       CrossfireServerConnection crossfireServerConnection)
Creates a new instance.

Parameters:
crossfireServerConnection - the crossfire server connection to monitor
Method Detail

addGuiStateListener

public void addGuiStateListener(@NotNull
                                GuiStateListener listener)
Adds a gui state listener.

Parameters:
listener - the listener to add

changeGUI

public void changeGUI(GuiState guiState)
Sets a new GuiState.

Parameters:
guiState - the new gui state

changeGUI

private void changeGUI(@NotNull
                       GuiState guiState,
                       @Nullable
                       java.lang.String param)
Sets a new GuiState.

Parameters:
guiState - the new gui state
param - a parameter for the new gui state

connect

public void connect(@NotNull
                    java.lang.String serverInfo)
Connects to a Crossfire server.

Parameters:
serverInfo - the server to connect to

disconnect

public void disconnect()
Disconnects from the Crossfire server.


getGuiState

@Nullable
public GuiState getGuiState()
Returns the current GuiState.

Returns:
the gui state

removeGuiStateListener

public void removeGuiStateListener(@NotNull
                                   GuiStateListener listener)
Removes a gui state listener.

Parameters:
listener - the listener to remove