incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran...@apache.org
Subject cvs commit: incubator-ftpserver/src/java/org/apache/ftpserver/gui SpyPanel.java
Date Mon, 23 Jun 2003 16:35:29 GMT
rana_b      2003/06/23 09:35:29

  Modified:    src/java/org/apache/ftpserver/gui SpyPanel.java
  Log:
  request/response seperation
  
  Revision  Changes    Path
  1.2       +34 -8     incubator-ftpserver/src/java/org/apache/ftpserver/gui/SpyPanel.java
  
  Index: SpyPanel.java
  ===================================================================
  RCS file: /home/cvs/incubator-ftpserver/src/java/org/apache/ftpserver/gui/SpyPanel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpyPanel.java	31 Mar 2003 06:50:03 -0000	1.1
  +++ SpyPanel.java	23 Jun 2003 16:35:29 -0000	1.2
  @@ -57,11 +57,16 @@
   package org.apache.ftpserver.gui;
   
   import java.awt.BorderLayout;
  +import java.awt.Color;
   import java.rmi.RemoteException;
   
   import javax.swing.JPanel;
   import javax.swing.JScrollPane;
  -import javax.swing.JTextArea;
  +import javax.swing.JTextPane;
  +import javax.swing.text.BadLocationException;
  +import javax.swing.text.Document;
  +import javax.swing.text.SimpleAttributeSet;
  +import javax.swing.text.StyleConstants;
   
   import org.apache.ftpserver.FtpUser;
   import org.apache.ftpserver.gui.remote.SpyConnectionAdapter;
  @@ -69,19 +74,22 @@
   
   
   /**
  - * This panel is used to monitor user activity.
  + * This panel is used to monitor user activities.
    *
    * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
    */
   public
   class SpyPanel extends JPanel implements SpyConnectionInterface {
   
  -    private JTextArea mLogTxt    = null;
  +    private JTextPane mLogTxt    = null;
   
       private SpyConnectionAdapter mSpyAdapter = null;
       private CommonHandler mCommonHandler     = null;
       private FtpUser mUser                    = null;
   
  +    private SimpleAttributeSet mReqAttrs = null;
  +    private SimpleAttributeSet mResAttrs = null;
  +
       /**
        * Instantiate this dialog box
        */
  @@ -91,6 +99,12 @@
   
           initComponents();
           mSpyAdapter = new SpyConnectionAdapter(commonHandler.getConnectionService(), mUser.getSessionId(),
this);
  +    
  +        mReqAttrs = new SimpleAttributeSet();
  +        StyleConstants.setForeground(mReqAttrs, new Color(0xFF, 0x00, 0xFF));
  +        
  +        mResAttrs = new SimpleAttributeSet();
  +        StyleConstants.setForeground(mResAttrs, new Color(0x00, 0x00, 0x8B));
       }
   
       /**
  @@ -98,7 +112,7 @@
        */
       private void initComponents() throws RemoteException {
           setLayout(new BorderLayout());
  -        mLogTxt = new JTextArea();
  +        mLogTxt = new JTextPane();
           mLogTxt.setEditable(false);
           JScrollPane txtPane = new JScrollPane(mLogTxt,
                       JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  @@ -124,14 +138,26 @@
        * Write server response.
        */
       public void response(String msg) {
  -        mLogTxt.append(msg);
  +        Document doc = mLogTxt.getDocument();
  +        try {
  +            doc.insertString(doc.getLength(), msg, mResAttrs);
  +        }
  +        catch(BadLocationException ex) {
  +            ex.printStackTrace();
  +        }
       }
   
       /**
        * Write user request.
        */
       public void request(String msg) {
  -        mLogTxt.append(msg);
  +        Document doc = mLogTxt.getDocument();
  +        try {
  +            doc.insertString(doc.getLength(), msg, mReqAttrs);
  +        }
  +        catch(BadLocationException ex) {
  +            ex.printStackTrace();
  +        }
       }
   
       /**
  @@ -146,7 +172,7 @@
        */
       public void close() {
           mSpyAdapter.close();
  -        mLogTxt.setText("");
  +        clearLog();
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message