directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r449905 - in /directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat: ChatProtocolHandler.java client/ConnectDialog.java client/SwingChatClient.java
Date Tue, 26 Sep 2006 04:55:39 GMT
Author: trustin
Date: Mon Sep 25 21:55:38 2006
New Revision: 449905

URL: http://svn.apache.org/viewvc?view=rev&rev=449905
Log:
Reformated code (from tabs to spaces)

Modified:
    directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java
    directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ConnectDialog.java
    directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/SwingChatClient.java

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java?view=diff&rev=449905&r1=449904&r2=449905
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/ChatProtocolHandler.java
Mon Sep 25 21:55:38 2006
@@ -40,14 +40,14 @@
     private Set sessions = Collections.synchronizedSet( new HashSet() );
     private Set users = Collections.synchronizedSet( new HashSet() );
 
-	public void exceptionCaught( IoSession session, Throwable cause )
+    public void exceptionCaught( IoSession session, Throwable cause )
     {
         SessionLog.error( session, "", cause );
         // Close connection when unexpected exception is caught.
         session.close();
     }
 
-	public void messageReceived( IoSession session, Object message )
+    public void messageReceived( IoSession session, Object message )
     {
         String theMessage = ( String ) message;
         String[] result = theMessage.split( " ", 2 );
@@ -88,7 +88,8 @@
                 // check if the username is already used
                 if( users.contains( user ) )
                 {
-                    session.write( "LOGIN ERROR the name " + user + " is already used." );
+                    session.write( "LOGIN ERROR the name " + user
+                            + " is already used." );
                     return;
                 }
 
@@ -120,7 +121,7 @@
         }
     }
 
-    public void broadcast(String message)
+    public void broadcast( String message )
     {
         synchronized( sessions )
         {
@@ -134,9 +135,9 @@
                 }
             }
         }
-	}
+    }
 
-	public void sessionClosed( IoSession session ) throws Exception
+    public void sessionClosed( IoSession session ) throws Exception
     {
         String user = ( String ) session.getAttribute( "user" );
         users.remove( user );
@@ -144,16 +145,16 @@
         broadcast( "The user " + user + " has left the chat session." );
     }
 
-	public boolean isChatUser( String name )
+    public boolean isChatUser( String name )
     {
         return users.contains( name );
     }
-    
+
     public int getNumberOfUsers()
     {
         return users.size();
     }
-    
+
     public void kick( String name )
     {
         synchronized( sessions )
@@ -169,5 +170,5 @@
                 }
             }
         }
-    }    
+    }
 }

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ConnectDialog.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ConnectDialog.java?view=diff&rev=449905&r1=449904&r2=449905
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ConnectDialog.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/ConnectDialog.java
Mon Sep 25 21:55:38 2006
@@ -24,7 +24,6 @@
 import java.awt.event.ActionEvent;
 
 import javax.swing.AbstractAction;
-import javax.swing.Action;
 import javax.swing.BoxLayout;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
@@ -41,6 +40,8 @@
  */
 public class ConnectDialog extends JDialog
 {
+    private static final long serialVersionUID = 2009384520250666216L;
+
     private String serverAddress;
     private String username;
     private boolean useSsl;
@@ -68,6 +69,8 @@
         JButton okButton = new JButton();
         okButton.setAction( new AbstractAction( "OK" )
         {
+            private static final long serialVersionUID = -2292183622613960604L;
+
             public void actionPerformed( ActionEvent e )
             {
                 serverAddress = serverAddressField.getText();
@@ -80,6 +83,8 @@
         JButton cancelButton = new JButton();
         cancelButton.setAction( new AbstractAction( "Cancel" )
         {
+            private static final long serialVersionUID = 6122393546173723305L;
+
             public void actionPerformed( ActionEvent e )
             {
                 cancelled = true;

Modified: directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/SwingChatClient.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/SwingChatClient.java?view=diff&rev=449905&r1=449904&r2=449905
==============================================================================
--- directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/SwingChatClient.java
(original)
+++ directory/trunks/mina/example/src/main/java/org/apache/mina/example/chat/client/SwingChatClient.java
Mon Sep 25 21:55:38 2006
@@ -51,25 +51,27 @@
  */
 public class SwingChatClient extends JFrame implements Callback
 {
-	private JTextField inputText;
-	private JButton loginButton;
-	private JButton quitButton;
-	private JButton closeButton;
-	private JTextField serverField;
-	private JTextField nameField;
-	private JTextArea area;
-	private JScrollBar scroll;
+    private static final long serialVersionUID = 1538675161745436968L;
+
+    private JTextField inputText;
+    private JButton loginButton;
+    private JButton quitButton;
+    private JButton closeButton;
+    private JTextField serverField;
+    private JTextField nameField;
+    private JTextArea area;
+    private JScrollBar scroll;
+    private ChatClientSupport client;
+    private SwingChatClientHandler handler;
 
-	private ChatClientSupport client;
-	private SwingChatClientHandler handler;
     private SocketConnector connector;
 
-	public SwingChatClient()
+    public SwingChatClient()
     {
         super( "Chat Client based on Apache MINA" );
-        
+
         connector = new SocketConnector();
-        
+
         loginButton = new JButton( new LoginAction() );
         loginButton.setText( "Connect" );
         quitButton = new JButton( new LogoutAction() );
@@ -140,39 +142,45 @@
         setLoggedOut();
         setDefaultCloseOperation( EXIT_ON_CLOSE );
     }
-	
-	public class LoginAction extends AbstractAction
+
+    public class LoginAction extends AbstractAction
     {
+        private static final long serialVersionUID = 3596719854773863244L;
+
         public void actionPerformed( ActionEvent e )
         {
 
             ConnectDialog dialog = new ConnectDialog( SwingChatClient.this );
             dialog.pack();
             dialog.setVisible( true );
-            
+
             if( dialog.isCancelled() )
             {
                 return;
             }
-            
-            SocketAddress address = parseSocketAddress( dialog.getServerAddress() );
+
+            SocketAddress address = parseSocketAddress( dialog
+                    .getServerAddress() );
             String name = dialog.getUsername();
-            
+
             handler = new SwingChatClientHandler( SwingChatClient.this );
             client = new ChatClientSupport( name, handler );
             nameField.setText( name );
             serverField.setText( dialog.getServerAddress() );
-            
-            if( ! client.connect( connector, address, dialog.isUseSsl() ) )
+
+            if( !client.connect( connector, address, dialog.isUseSsl() ) )
             {
                 JOptionPane.showMessageDialog( SwingChatClient.this,
-                        "Could not connect to " + dialog.getServerAddress() + ". " );
+                        "Could not connect to " + dialog.getServerAddress()
+                                + ". " );
             }
         }
     }
-    
-	private class LogoutAction extends AbstractAction
+
+    private class LogoutAction extends AbstractAction
     {
+        private static final long serialVersionUID = 1655297424639924560L;
+
         public void actionPerformed( ActionEvent e )
         {
             try
@@ -187,18 +195,25 @@
             }
         }
     }
-	
-	private class BroadcastAction extends AbstractAction
+
+    private class BroadcastAction extends AbstractAction
     {
+        /**
+         * 
+         */
+        private static final long serialVersionUID = -6276019615521905411L;
+
         public void actionPerformed( ActionEvent e )
         {
             client.broadcast( inputText.getText() );
             inputText.setText( "" );
         }
     }
-	
-	private class QuitAction extends AbstractAction
+
+    private class QuitAction extends AbstractAction
     {
+        private static final long serialVersionUID = -6389802816912005370L;
+
         public void actionPerformed( ActionEvent e )
         {
             if( client != null )
@@ -208,7 +223,7 @@
             SwingChatClient.this.dispose();
         }
     }
-	
+
     private void setLoggedOut()
     {
         inputText.setEnabled( false );
@@ -229,12 +244,12 @@
         area.append( text );
     }
 
-	private void notifyError( String message )
+    private void notifyError( String message )
     {
         JOptionPane.showMessageDialog( this, message );
     }
 
-	private SocketAddress parseSocketAddress( String s )
+    private SocketAddress parseSocketAddress( String s )
     {
         s = s.trim();
         int colonIndex = s.indexOf( ":" );
@@ -251,7 +266,7 @@
         }
     }
 
-	private int parsePort( String s )
+    private int parsePort( String s )
     {
         try
         {
@@ -261,9 +276,9 @@
         {
             throw new IllegalArgumentException( "Illegal port number: " + s );
         }
-    }    
-	
-	public void connected()
+    }
+
+    public void connected()
     {
         client.login();
     }



Mime
View raw message