net.sf.colossus.webclient
Class WebClient

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by net.sf.colossus.guiutil.KFrame
                          extended by net.sf.colossus.webclient.WebClient
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, IWebClient

public class WebClient
extends KFrame
implements IWebClient

This is the main class for one user client for the web server. One such client can register and/or login to the web server, propose a game, browse proposed games and enroll to such a game. When a game has enough players, it can be started, and this brings up the MasterBoard like the network client would do.

Author:
Clemens Katzer
See Also:
Serialized Form

Nested Class Summary
(package private)  class WebClient.TriggerTimeIsUp
           
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  javax.swing.Box adminTab
           
private  javax.swing.JTextField atDateField
           
private  javax.swing.JTextField atTimeField
           
private  javax.swing.JCheckBox autoGamePaneCB
           
private static java.lang.String AutoGamePaneCBText
           
private static java.lang.String AutoGameStartActionClose
           
private static java.lang.String AutoGameStartActionHide
           
private static java.lang.String AutoGameStartActionNothing
           
private  javax.swing.JRadioButton autoGSCloseRB
           
private  javax.swing.JRadioButton autoGSHideRB
           
private  javax.swing.JRadioButton autoGSNothingRB
           
private  javax.swing.JCheckBox autologinCB
           
private static java.lang.String AutoLoginCBText
           
private  javax.swing.JCheckBox balancedTowersCB
           
private  javax.swing.JTextField beepCountField
           
private  javax.swing.JTextField beepIntervalField
           
private  javax.swing.JButton cancelButton
           
private static java.lang.String CancelButtonText
           
private static java.lang.String CantHideText
           
(package private) static java.lang.String CARD_PROPOSED
           
private static java.lang.String chgPasswordButtonText
           
private static java.lang.String chgPasswordLabelText
           
private  boolean clientIsUp
           
private  boolean clientStartFailed
           
private  java.lang.Object comingUpMutex
           
private  javax.swing.JTextField commandField
           
private static java.lang.String createAccountButtonText
           
private static java.lang.String createAccountLabelText
           
private  javax.swing.Box createGamesTab
           
private  javax.swing.JButton debugSubmitButton
           
private  java.awt.Point defaultLocation
           
private static java.lang.String defaultSummaryText
           
private  java.util.HashSet<java.lang.String> deletedGames
           
private static java.lang.String dialogMessage
           
private static java.lang.String dialogTitle
           
private  javax.swing.JButton dumpInfoButton
           
private  javax.swing.JTextField durationField
           
private  javax.swing.JButton enrollButton
           
private static java.lang.String EnrollButtonText
           
private static int EnrolledInstantGame
           
private  java.lang.String enrolledInstantGameId
           
(package private) static java.lang.String enrolledText
           
(package private) static java.lang.String enrollText
           
private  javax.swing.JComboBox eventExpiringBox
           
private  boolean failedDueToDuplicateLogin
           
private  Client gameClient
           
private  java.util.HashMap<java.lang.String,GameInfo> gameHash
          NOTE: shared with SocketThread, because WCST needs it to restore game tokens to an GameInfo object
private  RunGameInSameJVM gameRunner
           
private  javax.swing.JPanel gamesCards
           
private  javax.swing.JPanel gamesTablesPanel
           
private  java.util.ArrayList<GameInfo> gamesUpdates
           
private  ChatHandler generalChat
           
private  javax.swing.JButton hideButton
           
private  javax.swing.JLabel hideButtonText
           
private static java.lang.String HideButtonText
           
private  java.lang.String hostname
           
private static java.lang.String HowtoUnhideText
           
private  javax.swing.JLabel infoTextLabel
           
private  boolean isAdmin
           
private  Server localServer
           
private static int LoggedIn
           
private static java.util.logging.Logger LOGGER
           
private  java.lang.String login
           
private static java.lang.String LoginButtonText
           
private  javax.swing.JTextField loginField
           
private  javax.swing.JButton loginLogoutButton
           
private static java.lang.String LogoutButtonText
           
private  javax.swing.JLabel maxLabel
           
private static int maxPort
           
private static int minPort
           
private  java.text.DateFormat myDateFormat
           
(package private) static java.util.Locale myLocale
           
private  java.text.DateFormat myTimeFormat
           
(package private) static java.lang.String needLoginText
           
private  javax.swing.JTextField notifyMessageField
           
private  javax.swing.JTextField notifyUserField
           
private static int NotLoggedIn
           
private  javax.swing.JLabel nowDateAndTimeLabel
           
private static java.lang.String optAutoGameStartAction
           
private  Options options
           
private  java.lang.String password
           
private  javax.swing.JPasswordField passwordField
           
private static int Playing
           
(package private) static java.lang.String playingText
           
private  int port
           
private  javax.swing.JPanel preferencesPane
           
private  javax.swing.JPanel propGamesCard
           
private  javax.swing.JButton proposeButton
           
private static java.lang.String ProposeButtonText
           
private  GameTableModel proposedGameDataModel
           
private  javax.swing.JTable proposedGameTable
           
private  javax.swing.JButton quitButton
           
private static java.lang.String quitButtonText
           
private  javax.swing.JLabel receivedField
           
private  javax.swing.JButton registerOrPasswordButton
           
private  javax.swing.JLabel registerOrPasswordLabel
           
private  RegisterPasswordPanel registerPanel
           
private  GameTableModel runGameDataModel
           
private  javax.swing.JTable runGameTable
           
private  javax.swing.Box runningGamesTab
           
private  boolean scheduledGamesMode
           
private static java.lang.String sep
           
private  IWebServer server
           
private  javax.swing.Box serverTab
           
private  javax.swing.JButton shutdownButton
           
private  javax.swing.JSpinner spinner1
           
private  javax.swing.JSpinner spinner2
           
private  javax.swing.JSpinner spinner3
           
private  javax.swing.JButton startButton
           
private static java.lang.String StartButtonText
           
private  java.lang.String startedAtHost
           
private  int startedAtPort
           
private  java.lang.String startedGameId
           
(package private) static java.lang.String startedText
           
private  GameInfo startingGame
           
private  javax.swing.JButton startLocallyButton
           
private static java.lang.String StartLocallyButtonText
           
private  int state
           
private  javax.swing.JLabel statusField
           
private  javax.swing.JLabel statusLabel
           
private  java.lang.String statusText
           
private  javax.swing.JTextField summaryText
           
private  javax.swing.JTabbedPane tabbedPane
           
private  boolean timeIsUp
           
(package private) static java.lang.String TYPE_INSTANTLY
           
(package private) static java.lang.String TYPE_SCHEDULED
           
private  javax.swing.JButton unenrollButton
           
private static java.lang.String UnenrollButtonText
           
private  javax.swing.JCheckBox unlimitedMulligansCB
           
private  javax.swing.JLabel userinfoLabel
           
private  java.lang.String username
           
private  int usersDead
           
private  int usersEnrolled
           
private  int usersLoggedIn
           
private  long usersLogoffAgo
           
private  int usersPlaying
           
private  java.lang.String usersText
           
private  javax.swing.JComboBox variantBox
           
private  javax.swing.JComboBox viewmodeBox
           
(package private) static java.lang.String waitingText
           
private  javax.swing.JButton watchButton
           
private static java.lang.String WatchButtonText
           
private  WebClientSocketThread wcst
           
(package private) static int WEB_CLIENT_VERSION
           
private  javax.swing.JTextField webserverHostField
           
private  javax.swing.JTextField webserverPortField
           
private  WhatNextManager whatNextManager
           
private static java.lang.String windowTitle
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface net.sf.colossus.webcommon.IWebClient
alreadyLoggedIn, chatDeliver, connectionClosed, didEnroll, didUnenroll, forcedLogout, gameCancelled, gameInfo, gameStarted, gameStartsNow, gameStartsSoon, generalMessage, grantAdmin, pingRequest, requestAttention, systemMessage, tooManyUsers, userInfo
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
WebClient(WhatNextManager whatNextManager, java.lang.String hostname, int port, java.lang.String login, java.lang.String password)
           
 
Method Summary
private  void addAdminTab()
           
private  void addRadioButton(java.awt.Container cont, javax.swing.ButtonGroup group, java.lang.String text, java.lang.String current, java.awt.event.ItemListener listener)
           
private  void adjustToPossibleMax(javax.swing.JSpinner spinner, int max)
           
private  void autoActions()
           
 void beepButtonAction()
           
private  void cancelButtonAction()
           
private  void cancelOwnInstantGameOnLogout()
           
 void chatDeliver(java.lang.String chatId, long when, java.lang.String sender, java.lang.String message, boolean resent)
           
private  boolean checkIfCouldCancel()
           
private  boolean checkIfCouldEnroll()
           
private  boolean checkIfCouldPropose()
           
private  boolean checkIfCouldStartOnServer(int state)
           
private  boolean checkIfCouldUnenroll()
           
 void connectionReset(boolean forced)
           
private  void createAdminTab()
           
private  void createCreateGamesTab()
           
 java.lang.String createLoginWebClientSocketThread(boolean force)
           
private  void createPreferencesPane()
           
 java.lang.String createRegisterWebClientSocketThread(java.lang.String username, java.lang.String password, java.lang.String email, java.lang.String confCode)
           
private  void createRunningGamesTab()
           
private  void createServerTab()
           
private  void debugSubmitButtonAction()
           
 void deliverGeneralMessage(long when, boolean error, java.lang.String title, java.lang.String message)
           
 void didEnroll(java.lang.String gameId, java.lang.String user)
           
 void didUnenroll(java.lang.String gameId, java.lang.String user)
           
private  void displayOnlyOneInstantGameMessage(java.lang.String action, java.lang.String message)
           
 void dispose()
           
private  void do_proposeGame(java.lang.String variant, java.lang.String viewmode, long startAt, int duration, java.lang.String summary, java.lang.String expire, boolean unlimMulli, boolean balTowers, int min, int target, int max)
           
private  void doAutoGSAction()
           
private  void doCancel(java.lang.String gameId)
           
private  boolean doEnroll(java.lang.String gameId)
           
 void doLogin()
           
 void doLogout()
           
private  void doQuit()
           
private  void doRegisterOrPasswordDialog(boolean register)
           
 void doScheduleDummy()
           
(package private)  boolean doStart(java.lang.String gameId)
           
private  boolean doStartLocally(java.lang.String gameId)
           
private  boolean doUnenroll(java.lang.String gameId)
           
 void doUpdateGUI()
           
private  void dumpInfoButtonAction()
           
private  void enrollButtonAction()
           
private  GameInfo findGameById(java.lang.String gameId)
           
private  GameInfo findGameByIdNoComplaint(java.lang.String gameId)
           
private  java.util.List<GameInfo> findMyInstantGames()
          Find all "relevant" instant games owned by this player (relevant means except those who are running, ending or deleted).
 void gameCancelled(java.lang.String gameId, java.lang.String byUser)
           
 void gameInfo(GameInfo gi)
           
 void gameStartsNow(java.lang.String gameId, int port, java.lang.String hostingHost)
           
 void gameStartsSoon(java.lang.String gameId, java.lang.String startUser)
           
 int getClientVersion()
           
private  int getDuration()
           
 java.util.HashMap<java.lang.String,GameInfo> getGameHash()
           
 IGameRunner getGameRunner()
           
 java.lang.String getHost()
           
private  int getMaxForVariant(java.lang.String variant)
           
private  java.util.Calendar getNowPlusOffset(java.util.Calendar now, int days, int hours)
          Determine a point in time given amount of days and hours from now.
 java.lang.String getPort()
           
 boolean getScheduledGamesMode()
           
 java.lang.String getSelectedGameId()
           
private  long getStartTime()
           
private  java.lang.String getSummaryText()
           
private  java.lang.String getUserinfoText()
           
 INotifyWebServer getWhomToNotify()
           
 void grantAdminStatus()
           
private  void handleGameInfoUpdates(GameInfo gi)
           
private  void hideButtonAction()
           
 void informGameStartedLocally()
           
 void informLocallyGameOver()
           
 void informStartingOnPlayerHost(java.lang.String hostingPlayer, java.lang.String hostingHost, int hostingPort)
           
private  void initFormats()
           
private  void initValues(java.lang.String hostname, int port, java.lang.String login, java.lang.String password)
           
 boolean isAdmin()
           
private  boolean isEligibleToStart(GameInfo gi)
          Returns true if this user would be allowed to start this game (given that all other conditions are fulfilled).
private  boolean isOwner(java.lang.String gameId)
           
private  boolean isScheduledGameAndStartable(java.lang.String id)
           
private  void loginLogoutButtonAction(java.lang.String command)
           
private  boolean logout()
           
private  java.lang.String makeDateTimeInfoString(java.util.Calendar now)
           
private  java.lang.String makeInfoTextForState(int state)
           
private  java.lang.String makeStatusTextForState(int state)
           
private  javax.swing.Box makeTextBox(java.awt.Component c)
           
private  javax.swing.Box makeTextBox2(java.awt.Component c, java.awt.Component c2)
           
private  java.lang.String makeWindowTitleForState(int state)
           
private  javax.swing.JLabel nonBoldLabel(java.lang.String text)
           
 void notifyComingUp(boolean success)
           
 void onGameStartAutoAction()
           
private  GameInfo ownInstantGameIfAny()
          If there is at least one instant game by this player, return it (one of it if many), otherwise null.
private  void proposeButtonAction()
           
private  void quitButtonAction()
           
 void reactOnScheduleRadioButtonChange(java.awt.event.ItemEvent e)
           
private  void registerOrPasswordButtonAction(java.lang.String command)
           
private  void removeAdminTab()
           
private  void replaceInTable(javax.swing.JTable table, GameInfo gi)
           
 void requestAttention(long when, java.lang.String byUser, boolean byAdmin, java.lang.String message, int beepCount, long beepInterval, boolean windows)
           
private  void setAdmin(boolean isAdmin)
           
 void setGameClient(Client c)
           
 void setLocalServer(Server server)
           
private  void setScheduledGamesMode(boolean scheduled)
           
private  void setupGUI()
           
private  java.util.Timer setupTimer()
           
 void showAnswer(java.lang.String s)
           
private  void showRequestAttentionMessage()
           
private  void shutdownButtonAction()
           
private  void startButtonAction()
           
private  void startLocallyButtonAction()
           
 void startOwnClient(java.lang.String gameId, int port, java.lang.String hostingHost)
           
 void systemMessage(long when, java.lang.String message)
           
 void tellGameEnds()
           
 java.lang.String tryChangePassword(java.lang.String name, java.lang.String oldPW, java.lang.String newPW1)
           
private  void unenrollButtonAction()
           
private  void updateDateTimeInfoString()
           
 void updateGUI()
           
private  void updateMaxSpinner(java.lang.String variant)
           
 void updateStatus(java.lang.String text, java.awt.Color color)
           
 void userInfo(int loggedin, int enrolled, int playing, int dead, long ago, java.lang.String text)
           
 boolean validateField(java.awt.Component parent, java.lang.String content, java.lang.String fieldName)
           
(package private)  boolean validatePort(java.awt.Component parent, java.lang.String portText)
           
 boolean validateServerAndPort()
           
private  void watchButtonAction()
           
 
Methods inherited from class net.sf.colossus.guiutil.KFrame
centerOnScreen, setVisible, useSaveWindow
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

WEB_CLIENT_VERSION

static final int WEB_CLIENT_VERSION
See Also:
Constant Field Values

myLocale

static final java.util.Locale myLocale

CARD_PROPOSED

static final java.lang.String CARD_PROPOSED
See Also:
Constant Field Values

TYPE_SCHEDULED

static final java.lang.String TYPE_SCHEDULED
See Also:
Constant Field Values

TYPE_INSTANTLY

static final java.lang.String TYPE_INSTANTLY
See Also:
Constant Field Values

whatNextManager

private final WhatNextManager whatNextManager

hostname

private java.lang.String hostname

port

private int port

login

private java.lang.String login

username

private java.lang.String username

password

private java.lang.String password

isAdmin

private boolean isAdmin

options

private final Options options

gameClient

private Client gameClient

gameRunner

private RunGameInSameJVM gameRunner

localServer

private Server localServer

startedGameId

private java.lang.String startedGameId

startedAtPort

private int startedAtPort

startedAtHost

private java.lang.String startedAtHost

registerPanel

private RegisterPasswordPanel registerPanel

comingUpMutex

private final java.lang.Object comingUpMutex

timeIsUp

private boolean timeIsUp

clientIsUp

private boolean clientIsUp

clientStartFailed

private boolean clientStartFailed

NotLoggedIn

private static final int NotLoggedIn
See Also:
Constant Field Values

LoggedIn

private static final int LoggedIn
See Also:
Constant Field Values

EnrolledInstantGame

private static final int EnrolledInstantGame
See Also:
Constant Field Values

Playing

private static final int Playing
See Also:
Constant Field Values

startingGame

private GameInfo startingGame

minPort

private static final int minPort
See Also:
Constant Field Values

maxPort

private static final int maxPort
See Also:
Constant Field Values

sep

private static final java.lang.String sep
See Also:
Constant Field Values

failedDueToDuplicateLogin

private boolean failedDueToDuplicateLogin

state

private int state

enrolledInstantGameId

private java.lang.String enrolledInstantGameId

scheduledGamesMode

private boolean scheduledGamesMode

usersLoggedIn

private int usersLoggedIn

usersEnrolled

private int usersEnrolled

usersPlaying

private int usersPlaying

usersDead

private int usersDead

usersLogoffAgo

private long usersLogoffAgo

usersText

private java.lang.String usersText

server

private IWebServer server

wcst

private WebClientSocketThread wcst

tabbedPane

private javax.swing.JTabbedPane tabbedPane

serverTab

private javax.swing.Box serverTab

preferencesPane

private javax.swing.JPanel preferencesPane

createGamesTab

private javax.swing.Box createGamesTab

runningGamesTab

private javax.swing.Box runningGamesTab

adminTab

private javax.swing.Box adminTab

defaultLocation

private final java.awt.Point defaultLocation

statusLabel

private javax.swing.JLabel statusLabel

userinfoLabel

private javax.swing.JLabel userinfoLabel

webserverHostField

private javax.swing.JTextField webserverHostField

webserverPortField

private javax.swing.JTextField webserverPortField

loginField

private javax.swing.JTextField loginField

passwordField

private javax.swing.JPasswordField passwordField

commandField

private javax.swing.JTextField commandField

receivedField

private javax.swing.JLabel receivedField

loginLogoutButton

private javax.swing.JButton loginLogoutButton

quitButton

private javax.swing.JButton quitButton

autologinCB

private javax.swing.JCheckBox autologinCB

autoGamePaneCB

private javax.swing.JCheckBox autoGamePaneCB

registerOrPasswordLabel

private javax.swing.JLabel registerOrPasswordLabel

registerOrPasswordButton

private javax.swing.JButton registerOrPasswordButton

debugSubmitButton

private javax.swing.JButton debugSubmitButton

shutdownButton

private javax.swing.JButton shutdownButton

dumpInfoButton

private javax.swing.JButton dumpInfoButton

notifyMessageField

private javax.swing.JTextField notifyMessageField

notifyUserField

private javax.swing.JTextField notifyUserField

beepCountField

private javax.swing.JTextField beepCountField

beepIntervalField

private javax.swing.JTextField beepIntervalField

statusField

private javax.swing.JLabel statusField

statusText

private java.lang.String statusText

variantBox

private javax.swing.JComboBox variantBox

viewmodeBox

private javax.swing.JComboBox viewmodeBox

eventExpiringBox

private javax.swing.JComboBox eventExpiringBox

spinner1

private javax.swing.JSpinner spinner1

spinner2

private javax.swing.JSpinner spinner2

spinner3

private javax.swing.JSpinner spinner3

maxLabel

private javax.swing.JLabel maxLabel

unlimitedMulligansCB

private javax.swing.JCheckBox unlimitedMulligansCB

balancedTowersCB

private javax.swing.JCheckBox balancedTowersCB

nowDateAndTimeLabel

private javax.swing.JLabel nowDateAndTimeLabel

atDateField

private javax.swing.JTextField atDateField

atTimeField

private javax.swing.JTextField atTimeField

durationField

private javax.swing.JTextField durationField

summaryText

private javax.swing.JTextField summaryText

myDateFormat

private java.text.DateFormat myDateFormat

myTimeFormat

private java.text.DateFormat myTimeFormat

proposeButton

private javax.swing.JButton proposeButton

cancelButton

private javax.swing.JButton cancelButton

enrollButton

private javax.swing.JButton enrollButton

unenrollButton

private javax.swing.JButton unenrollButton

startButton

private javax.swing.JButton startButton

startLocallyButton

private javax.swing.JButton startLocallyButton

watchButton

private javax.swing.JButton watchButton

hideButton

private javax.swing.JButton hideButton

hideButtonText

private javax.swing.JLabel hideButtonText

autoGSNothingRB

private javax.swing.JRadioButton autoGSNothingRB

autoGSHideRB

private javax.swing.JRadioButton autoGSHideRB

autoGSCloseRB

private javax.swing.JRadioButton autoGSCloseRB

infoTextLabel

private javax.swing.JLabel infoTextLabel

needLoginText

static final java.lang.String needLoginText
See Also:
Constant Field Values

enrollText

static final java.lang.String enrollText
See Also:
Constant Field Values

startedText

static final java.lang.String startedText
See Also:
Constant Field Values

waitingText

static final java.lang.String waitingText
See Also:
Constant Field Values

enrolledText

static final java.lang.String enrolledText
See Also:
Constant Field Values

playingText

static final java.lang.String playingText
See Also:
Constant Field Values

generalChat

private ChatHandler generalChat

gamesUpdates

private final java.util.ArrayList<GameInfo> gamesUpdates

gameHash

private final java.util.HashMap<java.lang.String,GameInfo> gameHash
NOTE: shared with SocketThread, because WCST needs it to restore game tokens to an GameInfo object


deletedGames

private final java.util.HashSet<java.lang.String> deletedGames

gamesTablesPanel

private javax.swing.JPanel gamesTablesPanel

gamesCards

private javax.swing.JPanel gamesCards

propGamesCard

private javax.swing.JPanel propGamesCard

proposedGameTable

private javax.swing.JTable proposedGameTable

proposedGameDataModel

private GameTableModel proposedGameDataModel

runGameTable

private javax.swing.JTable runGameTable

runGameDataModel

private GameTableModel runGameDataModel

windowTitle

private static java.lang.String windowTitle

LoginButtonText

private static final java.lang.String LoginButtonText
See Also:
Constant Field Values

LogoutButtonText

private static final java.lang.String LogoutButtonText
See Also:
Constant Field Values

quitButtonText

private static final java.lang.String quitButtonText
See Also:
Constant Field Values

HideButtonText

private static final java.lang.String HideButtonText
See Also:
Constant Field Values

WatchButtonText

private static final java.lang.String WatchButtonText
See Also:
Constant Field Values

CantHideText

private static final java.lang.String CantHideText
See Also:
Constant Field Values

HowtoUnhideText

private static final java.lang.String HowtoUnhideText
See Also:
Constant Field Values

createAccountButtonText

private static final java.lang.String createAccountButtonText
See Also:
Constant Field Values

chgPasswordButtonText

private static final java.lang.String chgPasswordButtonText
See Also:
Constant Field Values

ProposeButtonText

private static final java.lang.String ProposeButtonText
See Also:
Constant Field Values

EnrollButtonText

private static final java.lang.String EnrollButtonText
See Also:
Constant Field Values

UnenrollButtonText

private static final java.lang.String UnenrollButtonText
See Also:
Constant Field Values

CancelButtonText

private static final java.lang.String CancelButtonText
See Also:
Constant Field Values

StartButtonText

private static final java.lang.String StartButtonText
See Also:
Constant Field Values

StartLocallyButtonText

private static final java.lang.String StartLocallyButtonText
See Also:
Constant Field Values

AutoLoginCBText

private static final java.lang.String AutoLoginCBText
See Also:
Constant Field Values

AutoGamePaneCBText

private static final java.lang.String AutoGamePaneCBText
See Also:
Constant Field Values

createAccountLabelText

private static final java.lang.String createAccountLabelText
See Also:
Constant Field Values

chgPasswordLabelText

private static final java.lang.String chgPasswordLabelText
See Also:
Constant Field Values

AutoGameStartActionNothing

private static final java.lang.String AutoGameStartActionNothing
See Also:
Constant Field Values

AutoGameStartActionHide

private static final java.lang.String AutoGameStartActionHide
See Also:
Constant Field Values

AutoGameStartActionClose

private static final java.lang.String AutoGameStartActionClose
See Also:
Constant Field Values

optAutoGameStartAction

private static final java.lang.String optAutoGameStartAction
See Also:
Constant Field Values

defaultSummaryText

private static final java.lang.String defaultSummaryText
See Also:
Constant Field Values

dialogTitle

private static java.lang.String dialogTitle

dialogMessage

private static java.lang.String dialogMessage
Constructor Detail

WebClient

public WebClient(WhatNextManager whatNextManager,
                 java.lang.String hostname,
                 int port,
                 java.lang.String login,
                 java.lang.String password)
Method Detail

getClientVersion

public int getClientVersion()
Specified by:
getClientVersion in interface IWebClient

initValues

private void initValues(java.lang.String hostname,
                        int port,
                        java.lang.String login,
                        java.lang.String password)

setGameClient

public void setGameClient(Client c)

setScheduledGamesMode

private void setScheduledGamesMode(boolean scheduled)

getScheduledGamesMode

public boolean getScheduledGamesMode()

onGameStartAutoAction

public void onGameStartAutoAction()

setupGUI

private void setupGUI()

autoActions

private void autoActions()

doAutoGSAction

private void doAutoGSAction()

updateStatus

public void updateStatus(java.lang.String text,
                         java.awt.Color color)

addAdminTab

private void addAdminTab()

removeAdminTab

private void removeAdminTab()

setAdmin

private void setAdmin(boolean isAdmin)

isAdmin

public boolean isAdmin()

showAnswer

public void showAnswer(java.lang.String s)

getHost

public java.lang.String getHost()

getPort

public java.lang.String getPort()

getGameRunner

public IGameRunner getGameRunner()

getWhomToNotify

public INotifyWebServer getWhomToNotify()

createServerTab

private void createServerTab()

addRadioButton

private void addRadioButton(java.awt.Container cont,
                            javax.swing.ButtonGroup group,
                            java.lang.String text,
                            java.lang.String current,
                            java.awt.event.ItemListener listener)

nonBoldLabel

private javax.swing.JLabel nonBoldLabel(java.lang.String text)

makeTextBox

private javax.swing.Box makeTextBox(java.awt.Component c)

makeTextBox2

private javax.swing.Box makeTextBox2(java.awt.Component c,
                                     java.awt.Component c2)

initFormats

private void initFormats()

makeDateTimeInfoString

private java.lang.String makeDateTimeInfoString(java.util.Calendar now)

updateDateTimeInfoString

private void updateDateTimeInfoString()

createCreateGamesTab

private void createCreateGamesTab()

getNowPlusOffset

private java.util.Calendar getNowPlusOffset(java.util.Calendar now,
                                            int days,
                                            int hours)
Determine a point in time given amount of days and hours from now. Round it to a full hour (down if min <= 10, next hour otherwise).

Parameters:
days -
hours -
Returns:

reactOnScheduleRadioButtonChange

public void reactOnScheduleRadioButtonChange(java.awt.event.ItemEvent e)

createPreferencesPane

private void createPreferencesPane()

updateMaxSpinner

private void updateMaxSpinner(java.lang.String variant)

adjustToPossibleMax

private void adjustToPossibleMax(javax.swing.JSpinner spinner,
                                 int max)

getMaxForVariant

private int getMaxForVariant(java.lang.String variant)

createRunningGamesTab

private void createRunningGamesTab()

createAdminTab

private void createAdminTab()

beepButtonAction

public void beepButtonAction()

createLoginWebClientSocketThread

public java.lang.String createLoginWebClientSocketThread(boolean force)

createRegisterWebClientSocketThread

public java.lang.String createRegisterWebClientSocketThread(java.lang.String username,
                                                            java.lang.String password,
                                                            java.lang.String email,
                                                            java.lang.String confCode)

logout

private boolean logout()

doQuit

private void doQuit()

dispose

public void dispose()
Overrides:
dispose in class KFrame

getUserinfoText

private java.lang.String getUserinfoText()

updateGUI

public void updateGUI()

getSelectedGameId

public java.lang.String getSelectedGameId()

makeWindowTitleForState

private java.lang.String makeWindowTitleForState(int state)

makeInfoTextForState

private java.lang.String makeInfoTextForState(int state)

makeStatusTextForState

private java.lang.String makeStatusTextForState(int state)

isEligibleToStart

private boolean isEligibleToStart(GameInfo gi)
Returns true if this user would be allowed to start this game (given that all other conditions are fulfilled). Usually the allowed player is the one who created it, but if that one is not enrolled, the first of the enrolled ones is allowed then to do it.

Parameters:
gi -
Returns:
Whether this player would be allowed to start this game

checkIfCouldStartOnServer

private boolean checkIfCouldStartOnServer(int state)

isScheduledGameAndStartable

private boolean isScheduledGameAndStartable(java.lang.String id)

checkIfCouldPropose

private boolean checkIfCouldPropose()

checkIfCouldCancel

private boolean checkIfCouldCancel()

checkIfCouldEnroll

private boolean checkIfCouldEnroll()

checkIfCouldUnenroll

private boolean checkIfCouldUnenroll()

doUpdateGUI

public void doUpdateGUI()

getGameHash

public java.util.HashMap<java.lang.String,GameInfo> getGameHash()

findGameByIdNoComplaint

private GameInfo findGameByIdNoComplaint(java.lang.String gameId)

findGameById

private GameInfo findGameById(java.lang.String gameId)

isOwner

private boolean isOwner(java.lang.String gameId)

validateField

public boolean validateField(java.awt.Component parent,
                             java.lang.String content,
                             java.lang.String fieldName)

validatePort

boolean validatePort(java.awt.Component parent,
                     java.lang.String portText)

doLogin

public void doLogin()

validateServerAndPort

public boolean validateServerAndPort()

doLogout

public void doLogout()

cancelOwnInstantGameOnLogout

private void cancelOwnInstantGameOnLogout()

doRegisterOrPasswordDialog

private void doRegisterOrPasswordDialog(boolean register)

tryChangePassword

public java.lang.String tryChangePassword(java.lang.String name,
                                          java.lang.String oldPW,
                                          java.lang.String newPW1)

doCancel

private void doCancel(java.lang.String gameId)

doScheduleDummy

public void doScheduleDummy()

do_proposeGame

private void do_proposeGame(java.lang.String variant,
                            java.lang.String viewmode,
                            long startAt,
                            int duration,
                            java.lang.String summary,
                            java.lang.String expire,
                            boolean unlimMulli,
                            boolean balTowers,
                            int min,
                            int target,
                            int max)

getStartTime

private long getStartTime()

getDuration

private int getDuration()

getSummaryText

private java.lang.String getSummaryText()

doEnroll

private boolean doEnroll(java.lang.String gameId)

doUnenroll

private boolean doUnenroll(java.lang.String gameId)

doStart

boolean doStart(java.lang.String gameId)

doStartLocally

private boolean doStartLocally(java.lang.String gameId)

informStartingOnPlayerHost

public void informStartingOnPlayerHost(java.lang.String hostingPlayer,
                                       java.lang.String hostingHost,
                                       int hostingPort)

informGameStartedLocally

public void informGameStartedLocally()

informLocallyGameOver

public void informLocallyGameOver()

setLocalServer

public void setLocalServer(Server server)

grantAdminStatus

public void grantAdminStatus()
Specified by:
grantAdminStatus in interface IWebClient

didEnroll

public void didEnroll(java.lang.String gameId,
                      java.lang.String user)
Specified by:
didEnroll in interface IWebClient

didUnenroll

public void didUnenroll(java.lang.String gameId,
                        java.lang.String user)
Specified by:
didUnenroll in interface IWebClient

gameStartsSoon

public void gameStartsSoon(java.lang.String gameId,
                           java.lang.String startUser)
Specified by:
gameStartsSoon in interface IWebClient

notifyComingUp

public void notifyComingUp(boolean success)

setupTimer

private java.util.Timer setupTimer()

gameStartsNow

public void gameStartsNow(java.lang.String gameId,
                          int port,
                          java.lang.String hostingHost)
Specified by:
gameStartsNow in interface IWebClient

startOwnClient

public void startOwnClient(java.lang.String gameId,
                           int port,
                           java.lang.String hostingHost)

gameCancelled

public void gameCancelled(java.lang.String gameId,
                          java.lang.String byUser)
Specified by:
gameCancelled in interface IWebClient

chatDeliver

public void chatDeliver(java.lang.String chatId,
                        long when,
                        java.lang.String sender,
                        java.lang.String message,
                        boolean resent)
Specified by:
chatDeliver in interface IWebClient

requestAttention

public void requestAttention(long when,
                             java.lang.String byUser,
                             boolean byAdmin,
                             java.lang.String message,
                             int beepCount,
                             long beepInterval,
                             boolean windows)
Specified by:
requestAttention in interface IWebClient

showRequestAttentionMessage

private void showRequestAttentionMessage()

deliverGeneralMessage

public void deliverGeneralMessage(long when,
                                  boolean error,
                                  java.lang.String title,
                                  java.lang.String message)
Specified by:
deliverGeneralMessage in interface IWebClient

systemMessage

public void systemMessage(long when,
                          java.lang.String message)
Specified by:
systemMessage in interface IWebClient

tellGameEnds

public void tellGameEnds()

userInfo

public void userInfo(int loggedin,
                     int enrolled,
                     int playing,
                     int dead,
                     long ago,
                     java.lang.String text)
Specified by:
userInfo in interface IWebClient

gameInfo

public void gameInfo(GameInfo gi)
Specified by:
gameInfo in interface IWebClient

handleGameInfoUpdates

private void handleGameInfoUpdates(GameInfo gi)

replaceInTable

private void replaceInTable(javax.swing.JTable table,
                            GameInfo gi)

connectionReset

public void connectionReset(boolean forced)
Specified by:
connectionReset in interface IWebClient

hideButtonAction

private void hideButtonAction()

watchButtonAction

private void watchButtonAction()

quitButtonAction

private void quitButtonAction()

loginLogoutButtonAction

private void loginLogoutButtonAction(java.lang.String command)

shutdownButtonAction

private void shutdownButtonAction()

dumpInfoButtonAction

private void dumpInfoButtonAction()

debugSubmitButtonAction

private void debugSubmitButtonAction()

registerOrPasswordButtonAction

private void registerOrPasswordButtonAction(java.lang.String command)

startLocallyButtonAction

private void startLocallyButtonAction()

startButtonAction

private void startButtonAction()

cancelButtonAction

private void cancelButtonAction()

unenrollButtonAction

private void unenrollButtonAction()

findMyInstantGames

private java.util.List<GameInfo> findMyInstantGames()
Find all "relevant" instant games owned by this player (relevant means except those who are running, ending or deleted). Normally there should ever be only one, but in strange cases... (like, game start failed or something...)


ownInstantGameIfAny

private GameInfo ownInstantGameIfAny()
If there is at least one instant game by this player, return it (one of it if many), otherwise null. Normally there should ever be only one, but in strange cases... (like, game start failed or something...)

Returns:
The (or: any) instant game or null

displayOnlyOneInstantGameMessage

private void displayOnlyOneInstantGameMessage(java.lang.String action,
                                              java.lang.String message)

enrollButtonAction

private void enrollButtonAction()

proposeButtonAction

private void proposeButtonAction()