org.relayirc.swingui
Class ChatApp

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--org.relayirc.swingui.ChatApp
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, ServerListener, javax.swing.WindowConstants

public class ChatApp
extends javax.swing.JFrame
implements ServerListener

Main class of the Relay-JFC chat application.

Version:
$Revision: 1.6.2.4 $

The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL

Original Code: Relay IRC Chat Engine
Initial Developer: David M. Johnson
Contributor(s): No contributors to this file
Copyright (C) 1997-2000 by David M. Johnson
All Rights Reserved.
Author:
David M. Johnson
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  Server _server
           
static java.lang.String ABOUT
          Action name for the ABOUT action.
static java.lang.String CASCADE
          Action name for the CASCADE action.
static java.lang.String CONNECT
          Action name for CONNECT action.
static java.lang.String CUSTOMIZE_ACTIONS
          Action name for the CUSTOMIZER_ACTIONS action.
static java.lang.String CUSTOMIZE_LISTENERS
          Action name for the CUSTOMIZE_LISTENERS action.
static java.lang.String DISCONNECT
          Action name for the DISCONNECT action.
static java.lang.String EDIT_SERVER_LIST
          Action name for the EDIT_SERVER_LIST action.
static java.lang.String EXIT
          Action name for the EXIT action.
static java.lang.String JOIN_CHANNEL
          Action name for the JOIN_CHANNEL action.
static java.lang.String LIST_CHANNELS
          Action name for the LIST_CHANNELS action.
static java.lang.String SETUP
          Action name for the SETUP action.
static java.lang.String TILE_HORZ
          Action name for the TILE_HORZ action.
static java.lang.String TILE_VERT
          Action name for the TILE_VERT action.
static java.lang.String WHOIS
          Action name for the WHOIS action.
 
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, 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 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
ChatApp()
          Construct a chat application.
 
Method Summary
 void cascade()
          Arrange windows in cascade formation.
 void closeApp()
          Disconnect from the IRC server, save options and exit applicatin.
 void connect()
          Present connection dialog to user and allow connection.
 void connect(Server server)
          Connect to the specified chat server.
 void display(java.lang.String str)
          Display text on the main console.
 void dock(MDIClientPanel panel)
          To dock/undock a MDIClientPanel, first set the panel's dock state then call this function to register that dock state.
 IChatAction getAction(java.lang.String actionName)
          Get action by name.
 java.lang.String getAppName()
          Returns the name of the chat application.
 java.lang.String getAppVersion()
          Returns the version of the chat application.
static ChatApp getChatApp()
          Returns the one-and-only chat application object.
static javax.swing.text.Style getChatStyle(java.lang.String st)
           
 ChatOptions getOptions()
           
 org.python.util.PythonInterpreter getPythonInterpreter()
           
 Server getServer()
           
static java.util.Hashtable initActions(java.lang.Object[][] actionArray, java.lang.Object declaringObject)
           
 void initGUI()
           
 boolean isConnected()
           
 boolean isConnecting()
           
 void layoutGUI()
           
 void listChannels()
          Show the channel search window.
 void loadLookAndFeel(java.lang.String name)
          Load a Swing pluggable look and feel specified by name
static void main(java.lang.String[] args)
          Main method for the Relay-JFC chat application.
 void onChannelAdd(ServerEvent event)
          Handle channel object addition.
 void onChannelJoin(ServerEvent event)
          Create channel window for this new channel
 void onChannelPart(ServerEvent event)
          Does nothing as channel objects take care of parting.
 void onConnect(ServerEvent event)
          On connection, ask actions to update themselves.
 void onDisconnect(ServerEvent event)
          On disconnection, ask actions to update themselves.
 void onInvite(ServerEvent event)
          Display information from INVITE message.
 void onIsOn(ServerEvent event)
          Display information from ISON reply.
 void onStatus(ServerEvent event)
          Respond to onStatus() event from chat engine by displaying status message on console.
 void onWhoIs(ServerEvent event)
          Respond to WhoIs message.
 void removeChatPanel(ChannelPanel panel)
          Remove chat channel panel from MDI panel and close, hide and dispose of channel's frame as well.
 void run()
          The main application thread, for internal use only.
 void sendWhoIs(java.lang.String nick, boolean popup)
          Request whois information for user specified by nick name.
 void sendWhoIs(User user, boolean popup)
          Request whois information for user specified by user object.
static void setChatApp(ChatApp a)
          Returns the one-and-only chat application object.
static void setChatFont(java.awt.Font font)
           
 void setOptions(ChatOptions options)
           
 void setServer(Server server)
           
 void setShowConsole(boolean show)
           
 void setShowFavorites(boolean show)
           
 void setShowPython(boolean show)
           
 void setStatusBarEnabled(boolean flag)
           
 void showJoinChannelDlg()
          Present the join channel dialog and if the user specifies a channel then send join command to chat server.
 void showServerListDlg()
          Present the server list dialog.
 void shutdown()
          Currenly, does nothing.
 void tileHorizontal()
          Tile windows horizontally.
 void tileVertical()
          Tile windows vertically.
 void updateActions()
           
 void updateLookAndFeel()
          Sets look and feel according to current ChatOptions settings.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, 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, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

_server

protected Server _server

ABOUT

public static final java.lang.String ABOUT
Action name for the ABOUT action.

CASCADE

public static final java.lang.String CASCADE
Action name for the CASCADE action.

CONNECT

public static final java.lang.String CONNECT
Action name for CONNECT action. You may supply a server value by setting the action's "Server" property to the Server object that you wish to connect. If this value is not set, then the ConnectDlg dialog will be shown so that the user may choose a server.

CUSTOMIZE_ACTIONS

public static final java.lang.String CUSTOMIZE_ACTIONS
Action name for the CUSTOMIZER_ACTIONS action.

CUSTOMIZE_LISTENERS

public static final java.lang.String CUSTOMIZE_LISTENERS
Action name for the CUSTOMIZE_LISTENERS action.

DISCONNECT

public static final java.lang.String DISCONNECT
Action name for the DISCONNECT action. This action will trigger a disconnect from the current server.

EDIT_SERVER_LIST

public static final java.lang.String EDIT_SERVER_LIST
Action name for the EDIT_SERVER_LIST action.

EXIT

public static final java.lang.String EXIT
Action name for the EXIT action.

JOIN_CHANNEL

public static final java.lang.String JOIN_CHANNEL
Action name for the JOIN_CHANNEL action.

LIST_CHANNELS

public static final java.lang.String LIST_CHANNELS
Action name for the LIST_CHANNELS action.

SETUP

public static final java.lang.String SETUP
Action name for the SETUP action. This action will pop-up the ChatOptionsDlg setup dialog will be shown.

TILE_HORZ

public static final java.lang.String TILE_HORZ
Action name for the TILE_HORZ action.

TILE_VERT

public static final java.lang.String TILE_VERT
Action name for the TILE_VERT action.

WHOIS

public static final java.lang.String WHOIS
Action name for the WHOIS action.
Constructor Detail

ChatApp

public ChatApp()
Construct a chat application.
Method Detail

main

public static void main(java.lang.String[] args)
Main method for the Relay-JFC chat application.

getChatApp

public static ChatApp getChatApp()
Returns the one-and-only chat application object.

setChatApp

public static void setChatApp(ChatApp a)
Returns the one-and-only chat application object.

run

public void run()
The main application thread, for internal use only.

getAction

public IChatAction getAction(java.lang.String actionName)
Get action by name. See action name fields ChatApp.CONNECT ChatApp.DISCONNECT, etc. for possible values.

initActions

public static java.util.Hashtable initActions(java.lang.Object[][] actionArray,
                                              java.lang.Object declaringObject)

getAppName

public java.lang.String getAppName()
Returns the name of the chat application.

getAppVersion

public java.lang.String getAppVersion()
Returns the version of the chat application.

getChatStyle

public static javax.swing.text.Style getChatStyle(java.lang.String st)

setChatFont

public static void setChatFont(java.awt.Font font)

isConnected

public boolean isConnected()

isConnecting

public boolean isConnecting()

getServer

public Server getServer()

setServer

public void setServer(Server server)

setOptions

public void setOptions(ChatOptions options)

getOptions

public ChatOptions getOptions()

getPythonInterpreter

public org.python.util.PythonInterpreter getPythonInterpreter()

setStatusBarEnabled

public void setStatusBarEnabled(boolean flag)

setShowConsole

public void setShowConsole(boolean show)

setShowFavorites

public void setShowFavorites(boolean show)

setShowPython

public void setShowPython(boolean show)

connect

public void connect(Server server)
Connect to the specified chat server. If already connected to that then say so and do nothing. If already connected to a different prompt user if it is OK to disconnect and reconnect to the specified server.

connect

public void connect()
Present connection dialog to user and allow connection.

display

public void display(java.lang.String str)
Display text on the main console.

closeApp

public void closeApp()
Disconnect from the IRC server, save options and exit applicatin.

showJoinChannelDlg

public void showJoinChannelDlg()
Present the join channel dialog and if the user specifies a channel then send join command to chat server.

showServerListDlg

public void showServerListDlg()
Present the server list dialog.

cascade

public void cascade()
Arrange windows in cascade formation.

tileHorizontal

public void tileHorizontal()
Tile windows horizontally.

tileVertical

public void tileVertical()
Tile windows vertically.

shutdown

public void shutdown()
Currenly, does nothing.

onStatus

public void onStatus(ServerEvent event)
Respond to onStatus() event from chat engine by displaying status message on console.
Specified by:
onStatus in interface ServerListener

onChannelAdd

public void onChannelAdd(ServerEvent event)
Handle channel object addition.
Specified by:
onChannelAdd in interface ServerListener

onChannelJoin

public void onChannelJoin(ServerEvent event)
Create channel window for this new channel
Specified by:
onChannelJoin in interface ServerListener

onIsOn

public void onIsOn(ServerEvent event)
Display information from ISON reply.
Specified by:
onIsOn in interface ServerListener

onInvite

public void onInvite(ServerEvent event)
Display information from INVITE message.
Specified by:
onInvite in interface ServerListener

onChannelPart

public void onChannelPart(ServerEvent event)
Does nothing as channel objects take care of parting.
Specified by:
onChannelPart in interface ServerListener

onConnect

public void onConnect(ServerEvent event)
On connection, ask actions to update themselves.
Specified by:
onConnect in interface ServerListener

onDisconnect

public void onDisconnect(ServerEvent event)
On disconnection, ask actions to update themselves.
Specified by:
onDisconnect in interface ServerListener

sendWhoIs

public void sendWhoIs(java.lang.String nick,
                      boolean popup)
Request whois information for user specified by nick name.

sendWhoIs

public void sendWhoIs(User user,
                      boolean popup)
Request whois information for user specified by user object.

onWhoIs

public void onWhoIs(ServerEvent event)
Respond to WhoIs message.
Specified by:
onWhoIs in interface ServerListener

initGUI

public void initGUI()

layoutGUI

public void layoutGUI()

dock

public void dock(MDIClientPanel panel)
To dock/undock a MDIClientPanel, first set the panel's dock state then call this function to register that dock state. Simply calls the MDIPanel.registerDockState() method for the specified panel.
See Also:
MDIPanel

removeChatPanel

public void removeChatPanel(ChannelPanel panel)
Remove chat channel panel from MDI panel and close, hide and dispose of channel's frame as well.

listChannels

public void listChannels()
Show the channel search window.

updateLookAndFeel

public void updateLookAndFeel()
Sets look and feel according to current ChatOptions settings.

loadLookAndFeel

public void loadLookAndFeel(java.lang.String name)
Load a Swing pluggable look and feel specified by name

updateActions

public void updateActions()