* Utility class so I don't have to think about GridBagLayout
*/
+import javax.swing.*;
import java.awt.*;
-public class PairPanel extends Panel {
+public class PairPanel extends JPanel {
GridBagLayout gbLayout;
GridBagConstraints gbLeft, gbRight;
- go to any old room by double-clicking from list
_ can get to hidden or guessable-named rooms
_ can go to password protected rooms (tested)
-* can't zap rooms
+- can zap rooms
* can't list zapped rooms
"message"
go to the next room, the three unread messages will still be unread with
the java client while they wouldn't be with the text client. I like it
better personally, but hey, that's me.
-* can't view room info
+- can view room info
everything else isn't done.
+import javax.swing.*;
import java.awt.*;
-public class VertPanel extends Panel {
+public class VertPanel extends JPanel {
GridBagLayout gbLayout;
GridBagConstraints cur;
boolean top = true;
loginPanel lp;
mainPanel mp;
logoffPanel lfp;
+ JMenu cit, rooms;
+ JMenuItem logoff;
public citGui() {
frame = new JFrame( "Shaggy" );
+ JLayeredPane p = new JLayeredPane();
+ JMenuBar mbar = new JMenuBar();
+
c = frame.getContentPane();
+ c.setLayout( new BorderLayout() );
+ c.add( mbar, BorderLayout.NORTH );
+
+ c.add( p, BorderLayout.CENTER );
+ c = p;
c.setLayout( cdLayout = new CardLayout() );
c.add( "Host", hp = new hostPanel() );
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
citadel.me.closeFrame();
- System.exit( 0 );
}
});
+ JMenu m;
+ JMenuItem mi;
+
+ m = new JMenu( "File" );
+
+ mi = new JMenuItem( "Load hosts..." );
+ mi.setEnabled( false );
+ m.add( mi );
+
+ mi = new JMenuItem( "Save hosts..." );
+ mi.setEnabled( false );
+ m.add( mi );
+
+ mi = new JMenuItem( "Shaggy Preferences" );
+ mi.setEnabled( false );
+ m.add( mi );
+
+ m.add( new JSeparator() );
+
+ logoff = new JMenuItem( "Logoff" );
+ logoff.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ citadel.me.logoff();
+ } } );
+ m.add( logoff );
+ logoff.setEnabled( false );
+ logoff.setMnemonic( 'L' );
+
+ mi = new JMenuItem( "Quit" );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ citadel.me.closeFrame();
+ } } );
+ m.add( mi );
+ mi.setMnemonic( 'Q' );
+
+ mbar.add( m );
+
+ cit = new JMenu( "Citadel" );
+ cit.setEnabled( false );
+ cit.add( mi = new JMenuItem( "Page User..." ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ new pageUserWindow();
+ } } );
+
+ cit.add( mi = new JMenuItem( "Who is Online" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ new whoOnlineWindow();
+ } } );
+
+ cit.add( new JSeparator() );
+ cit.add( mi = new JMenuItem( "User List" ) );
+ mi.setEnabled( false );
+ cit.add( mi = new JMenuItem( "User Biographies" ) );
+ mi.setEnabled( false );
+ cit.add( new JSeparator() );
+ cit.add( mi = new JMenuItem( "User Configuration" ) );
+ mi.setEnabled( false );
+ cit.add( mi = new JMenuItem( "Server Information" ) );
+ mi.setEnabled( false );
+
+ mbar.add( cit );
+
+ rooms = new JMenu( "Rooms" );
+ rooms.setEnabled( false );
+ rooms.add( mi = new JMenuItem( "Next Room" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ citadel.me.enterRoom( citadel.me.rooms.nextNewRoom() );
+ } } );
+
+ rooms.add( mi = new JMenuItem( "Goto Room" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ citadel.me.enterRoom();
+ } } );
+
+ rooms.add( new JSeparator() );
+ rooms.add( mi = new JMenuItem( "List Zapped Rooms" ) );
+ mi.setEnabled( false );
+ rooms.add( mi = new JMenuItem( "Create Room..." ) );
+ mi.setEnabled( false );
+ rooms.add( mi = new JMenuItem( "Edit Room" ) );
+ mi.setEnabled( false );
+
+ mbar.add( rooms );
+
+ frame.getLayeredPane().moveToFront( mbar );
+ frame.getLayeredPane().moveToFront( mi );
+ frame.getLayeredPane().moveToFront( cit );
+ frame.getLayeredPane().moveToFront( rooms );
+ frame.getLayeredPane().moveToBack( p );
+
frame.pack();
frame.setVisible( true );
}
public void showHostBrowser() {
cdLayout.show( c, "Host" );
hp.refresh();
+ cit.setEnabled( false );
+ rooms.setEnabled( false );
+ logoff.setEnabled( false );
}
public void showLoginPanel() {
cdLayout.show( c, "Login" );
lp.refresh();
+ cit.setEnabled( false );
+ rooms.setEnabled( false );
+ logoff.setEnabled( false );
}
public void showLoginPanel( String user, String pass ) {
public void showMainPanel() {
cdLayout.show( c, "Main" );
+ cit.setEnabled( true );
+ rooms.setEnabled( true );
+ logoff.setEnabled( true );
mp.refresh();
}
public void showLogoffPanel() {
cdLayout.show( c, "Logoff" );
+ cit.setEnabled( false );
+ rooms.setEnabled( false );
+ logoff.setEnabled( false );
lfp.refresh();
}
JOptionPane.WARNING_MESSAGE);
}
}
-
-
-
-
theNet.done = true;
cg.errMsg( reason );
cg.showHostBrowser();
+ cleanup();
}
public void warning( String text ) {
}
public void closeFrame() {
- System.out.println( "Closed the friggin frame." );
+ /* prompt here? */
+ System.out.println( "Closed the frame." );
+ System.exit( 0 );
}
public void networkEvent( String cmd ) {
}
public void logoff() {
+ cleanup();
+
+ cg.showLogoffPanel();
+ networkEvent( "QUIT", new CallBack() {
+ public void run( citReply r ) {
+ theNet.done();
+ } } );
+ }
+
+ public void cleanup() {
/* close windows */
if( rf != null )
rf.dispose();
JFrame f = (JFrame)e.nextElement();
f.dispose();
}
-
- cg.showLogoffPanel();
- networkEvent( "QUIT", new CallBack() {
- public void run( citReply r ) {
- theNet.done();
- } } );
- }
+ }
public void setUser( user theUser ) {
this.theUser = theUser;
PairPanel pp = new PairPanel(3, 10);
pp.addLeft( new JLabel( "BBS Name:" ) );
pp.addRight( h_name = new JTextField( 20 ) );
+ h_name.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ dns_name.requestFocus();
+ } } );
pp.addLeft( new JLabel( "IP Address:" ) );
pp.addRight( dns_name = new JTextField( 20 ) );
dns_name.setText( "127.0.0.1" );
+ dns_name.addActionListener( new ActionListener () {
+ public void actionPerformed( ActionEvent e ) {
+ port.requestFocus();
+ } } );
pp.addLeft( new JLabel( "Port:" ) );
pp.addRight( port = new JTextField( "504" ) );
+ port.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ user.requestFocus();
+ } } );
pp.addLeft( new JLabel( "Username:" ) );
pp.addRight( user = new JTextField( 10 ) );
+ user.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ pass.requestFocus();
+ } } );
pp.addLeft( new JLabel( "Password:" ) );
pp.addRight( pass = new JPasswordField( 10 ) );
+ pass.addActionListener(new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ citadel.me.setServer( dns_name.getText(), port.getText() );
+ citadel.me.showLoginPanel( user.getText(), pass.getText() );
+ }
+ });
+
add( "Center", pp );
JButton but = new JButton( "Connect" );
time = makeDate( time );
blurb = (cur_pos+1) + "/" + count + " " + time + " from " + from;
- if( !node.equals( citadel.me.serverInfo.human_name ) )
+ // if( !node.equals( citadel.me.serverInfo.human_name ) )
+ if( ri.net )
blurb = blurb + " (@"+node+")";
if( !rcpt.equals( "" ) )
blurb = blurb + " to " + rcpt;
p.add( prev_msg = new JButton( "Prev Message" ) );
prev_msg.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
- cur_pos--;
- displayMessage();
+ prevMessage();
} } );
p.add( next_msg = new JButton( "Next Message" ) );
next_msg.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
- cur_pos++;
- displayMessage();
+ nextMessage();
} } );
add( "Center", p );
}
+ public void nextMessage() {
+ cur_pos++;
+ displayMessage();
+ }
+
+ public void prevMessage() {
+ cur_pos--;
+ displayMessage();
+ }
+
public void refresh() {
refresh( ri );
}
}
} );
- this.pack();
- this.show();
+ JMenuBar mbar = new JMenuBar();
+ JMenu m = new JMenu( "Rooms" );
+ mbar.add( m );
+ JMenuItem mi = new JMenuItem( "Next Room" );
+ m.add( mi );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ citadel.me.enterRoom( citadel.me.rooms.nextNewRoom() );
+ } } );
+
+ m.add( mi = new JMenuItem( "Goto Room" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ citadel.me.enterRoom();
+ } } );
+
+ m.add( mi = new JMenuItem( "Zap Room" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ if( JOptionPane.showConfirmDialog( null, "Zap " + mp.ri.name + "?" ) == 0 )
+ citadel.me.zapRoom( mp.ri );
+ } } );
+
+ m.add( new JSeparator() );
+
+ m.add( mi = new JMenuItem( "Room Info" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ new roomInfoWindow( mp.ri );
+ } } );
+
+ mbar.add( m = new JMenu( "Messages" ) );
+ m.add( mi = new JMenuItem( "Next Message" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ mp.nextMessage();
+ } } );
+
+ m.add( mi = new JMenuItem( "Previous Message" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ mp.prevMessage();
+ } } );
+
+ m.add( mi = new JMenuItem( "Enter Message" ) );
+ mi.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ enterMessage();
+ } } );
+
+ setJMenuBar( mbar );
+ pack();
+ show();
}
public void setRoom( roomInfo ri ) {
public class roomInfo {
+ public final int PERMANENT=1, PRIVATE=4, PASSWORDED=8, GUESSNAME=16,
+ DIRECTORY=32, UPLOAD=64, DOWNLOAD=128, VISDIR=256, ANONONLY=512,
+ ANON2=1024, NETWORK=2048, PREFONLY=4096, READONLY=8192;
+
String name;
int total, unread, info, flags, highest, highest_read;
boolean mail, aide;
int mail_num, floor;
room rm;
+ boolean perm, priv, pass, guess, dir, upload, download, vis, a_anon,
+ o_anon, net, pref, read;
public roomInfo( room rm, citReply r ) {
this.rm = rm;
name = r.getArg( 0 );
- total = citadel.atoi( r.getArg( 1 ) );
- unread = citadel.atoi( r.getArg( 2 ) );
+ unread = citadel.atoi( r.getArg( 1 ) );
+ total = citadel.atoi( r.getArg( 2 ) );
info = citadel.atoi( r.getArg( 3 ) );
flags = citadel.atoi( r.getArg( 4 ) );
highest = citadel.atoi( r.getArg( 5 ) );
aide = citadel.atoi( r.getArg( 8 ) ) != 0;
mail_num = citadel.atoi( r.getArg( 9 ) );
floor = citadel.atoi( r.getArg( 10 ) );
+
+ perm = on( PERMANENT );
+ priv = on( PRIVATE );
+ pass = on( PASSWORDED );
+ guess = on( GUESSNAME );
+ dir = on( DIRECTORY );
+ upload = on( UPLOAD );
+ download= on( DOWNLOAD );
+ vis = on( VISDIR );
+ a_anon = on( ANONONLY );
+ o_anon = on( ANON2 );
+ net = on( NETWORK );
+ pref = on( PREFONLY );
+ read = on( READONLY );
}
+
+ public boolean on( int bit ) {
+ return (flags & bit ) == bit;
+ }
}
info.setEditable( false );
info.setLineWrap( true );
info.setWrapStyleWord( true );
-
+
+ VertPanel vp = new VertPanel();
+ vp.add( new JLabel( ri.total + " messages" ) );
+ vp.add( new JLabel( "Floor: " + citadel.me.rooms.getFloor( ri.floor ).name() ) );
+ JCheckBox cb;
+ vp.add( cb = new JCheckBox( "Permanent", ri.perm ) );
+ cb.setEnabled( false );
+ vp.add( cb = new JCheckBox( "Private", ri.priv ) );
+ cb.setEnabled( false );
+ vp.add( cb = new JCheckBox( "Password", ri.pass ) );
+ cb.setEnabled( false );
+ vp.add( cb = new JCheckBox( "Directory", ri.dir ) );
+ cb.setEnabled( false );
+ vp.add( cb = new JCheckBox( "Networked", ri.net ) );
+ cb.setEnabled( false );
+ p.add( "East", vp );
+
c = getContentPane();
c.setLayout( new BorderLayout() );
c.add( "Center", p );
- p = new JPanel();
+ JPanel pp = new JPanel();
+ final JButton change = new JButton( "Change Info" );
+ pp.add( change );
+ change.setEnabled( false );
+ change.addActionListener( new ActionListener() {
+ public void actionPerformed( ActionEvent e ) {
+ citadel.me.networkEvent( "EINF 1", info.getText(), new CallBack() {
+ public void run( citReply r ) {
+ refresh();
+ } } );
+ } } );
+
JButton b;
- p.add( b = new JButton( "Close" ) );
- c.add( "South", p );
+
+ pp.add( b = new JButton( "Close" ) );
b.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
closeWin();
} } );
+ c.add( "South", pp );
+
addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
closeWin();
} } );
- pack();
+ setSize( 400, 400 );
show();
citadel.me.registerWindow( this );
+ refresh();
+ citadel.me.networkEvent( "EINF 0", new CallBack() {
+ public void run( citReply r ) {
+ if( r.ok() ) {
+ info.setEditable( true );
+ change.setEnabled( true );
+ }
+ } } );
+
+ }
+
+ public void refresh() {
citadel.me.networkEvent( "RINF", new CallBack() {
public void run( citReply r ) {
if( r.error() ) info.setText( r.getArg(0) );
else info.setText( r.getData() );
} } );
- }
+ }
public void closeWin() {
citadel.me.removeWindow( this );
return cur_floor;
}
+ public floor getFloor( int num ) {
+ return getFloor( "" + num );
+ }
+
public floor getFloor( String name ) {
return (floor)floors.get( name );
}