Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /antelope/src/ise/antelope/app/, /antelope/src/ise/antelope/app/jedit/

antelope
Discussion topic

Back to topic list

CVS update: /antelope/src/ise/antelope/app/, /antelope/src/ise/antelope/app/jedit/

Author danson
Full name Dale Anson
Date 2004-05-23 21:10:50 PDT
Message User: danson
Date: 04/05/23 21:10:50

Modified:
 /antelope/src/ise/antelope/app/
  Antelope.java, AntelopeGUILogHandler.java, FindDialog.java
 /antelope/src/ise/an​telope/app/jedit/
  FindAndReplace.java, JEditTextArea.java, TextAreaPainter.java

Log:
 added tail to app
 
 Issue number:
 Obtained from:
 Submitted by:
 Reviewed by:

File Changes:

Directory: /antelope/src/ise/antelope/app/
====================​====================​==

File [changed]: Antelope.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/app/Antelope.​java?r1=1.11&r2=​1.12
Delta lines: +7 -7
-------------------
--- Antelope.java 19 May 2004 19:13:02 -0000 1.11
+++ Antelope.java 24 May 2004 04:10:48 -0000 1.12
@@ -1,4 +1,4 @@
-// $Id: Antelope.java,v 1.11 2004/05/19 19:13:02 danson Exp $
+// $Id: Antelope.java,v 1.12 2004/05/24 04:10:48 danson Exp $
 
 /*
  * Based on the Apache Software License, Version 1.1
@@ -69,7 +69,7 @@
  * Main entry point for Antelope application.
  *
  * @author Dale Anson
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
  */
 public class Antelope extends JFrame implements Constants, CommonHelper {
 
@@ -322,10 +322,9 @@
 
         final AntelopeGUILogHandler logger = new AntelopeGUILogHandler( false );
         logger.setFont( _font );
-
- final JTextComponent ta = logger.getTextComponent();
         _antelope_panel.addLogHandler( logger );
 
+ final JTextComponent ta = logger.getTextComponent();
         find_mi.addActionListener(
             new ActionListener() {
                 public void actionPerformed( ActionEvent ae ) {
@@ -396,7 +395,7 @@
             }
         );
 
- _tabs.add( "Output", new JScrollPane( ta ) );
+ _tabs.add( "Output", logger.getPanel() );
         output_mi.addActionListener(
             new ActionListener() {
                 public void actionPerformed( ActionEvent ae ) {
@@ -539,6 +538,7 @@
         redo_mi.setEnabled( _editor.canRedo() );
 
         // look and feel
+ /*
         try {
             if (Constants.PREFS.getBoolean( USE_NATIVE_LF, true )) {
                 UIManager.setLookAnd​Feel(UIManager.getSy​stemLookAndFeelClass​Name());
@@ -549,8 +549,8 @@
             SwingUtilities.updat​eComponentTreeUI(thi​s);
             validate();
         }
- catch (Exception e) {}
-
+ catch (Throwable e) {}
+ */
         pack();
         ta.requestFocus();
         GUIUtils.fillScreen( this );

File [changed]: AntelopeGUILogHandler.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/app/AntelopeG​UILogHandler.java?r1​=1.1&r2=1.2
Delta lines: +240 -205
-----------------------
--- AntelopeGUILogHandler.java 16 Feb 2004 02:39:38 -0000 1.1
+++ AntelopeGUILogHandler.java 24 May 2004 04:10:49 -0000 1.2
@@ -1,4 +1,4 @@
-// $Id: AntelopeGUILogHandler.java,v 1.1 2004/02/16 02:39:38 danson Exp $
+// $Id: AntelopeGUILogHandler.java,v 1.2 2004/05/24 04:10:49 danson Exp $
 
 package ise.antelope.app;
 
@@ -68,19 +68,23 @@
 public class AntelopeGUILogHandler extends Handler {
 
    /**
- * Description of the Field
+ * The output area.
     */
    private JTextPane _text;
+
+ private boolean _tail = true;
+
+ private JPanel _content_pane;
    /**
- * Description of the Field
+ * Optional frame
     */
    private JFrame _frame;
    /**
- * Description of the Field
+ * Green
     */
    private Color GREEN = new Color( 0, 153, 51 );
    /**
- * Description of the Field
+ * Current font
     */
    private Font _font = null;
 
@@ -97,8 +101,13 @@
     * @param use_frame If true, will show the output in a separate frame.
     */
    public AntelopeGUILogHandler( boolean use_frame ) {
+
+ _content_pane = new JPanel(new BorderLayout());
+
       _text = new JTextPane();
       _text.setCaretPosition(0);
+ _content_pane.add(new JScrollPane(_text), BorderLayout.CENTER);
+ _content_pane.add(ge​tControlPanel(), BorderLayout.SOUTH);
 
       if ( use_frame ) {
          _frame = new JFrame( "Antelope Logger" );
@@ -109,7 +118,7 @@
                }
             }
                 );
- _frame.getContentPane().add( new JScrollPane( _text ) );
+ _frame.getContentPane().add( _content_pane );
          _frame.setSize( 600, 400 );
          GUIUtils.centerOnScreen( _frame );
       }
@@ -140,6 +149,14 @@
       return _text;
    }
 
+ public Document getDocument() {
+ return _text.getDocument();
+ }
+
+ public JPanel getPanel() {
+ return _content_pane;
+ }
+
    /**
     * Sets the font attribute of the AntelopeGUILogHandler object
     *
@@ -150,7 +167,7 @@
    }
 
    /**
- * Sets the visible attribute of the AntelopeGUILogHandler object
+ * Sets the visible attribute of the optional frame.
     *
     * @param b The new visible value
     */
@@ -159,14 +176,14 @@
    }
 
    /**
- * Description of the Method
+ * Disposes of the optional frame.
     */
    public void dispose() {
       _frame.dispose();
    }
 
    /**
- * Sets the location attribute of the AntelopeGUILogHandler object
+ * Sets the location attribute of the optional frame.
     *
     * @param x The new location value
     * @param y The new location value
@@ -176,7 +193,7 @@
    }
 
    /**
- * Sets the bounds attribute of the AntelopeGUILogHandler object
+ * Sets the bounds attribute of the optional frame.
     *
     * @param x The new bounds value
     * @param y The new bounds value
@@ -188,7 +205,7 @@
    }
 
    /**
- * Gets the size attribute of the AntelopeGUILogHandler object
+ * Gets the size attribute of the optional frame.
     *
     * @return The size value
     */
@@ -197,7 +214,7 @@
    }
 
    /**
- * Does nothing.
+ * Finish out the log.
     */
    public void close() {
       if ( getFormatter() != null )
@@ -207,11 +224,10 @@
    /**
     * Does nothing.
     */
- public void flush() {
- }
+ public void flush() {}
 
    /**
- * Description of the Method
+ * Starts the log.
     */
    public void open() {
       if ( getFormatter() != null ) {
@@ -219,8 +235,7 @@
          try {
             _text.getDocument().​insertString( index, getFormatter().getHead( AntelopeGUILogHandler.this ), null );
          }
- catch ( Exception e ) {
- }
+ catch ( Exception e ) {}
       }
    }
 
@@ -236,14 +251,15 @@
                public void run() {
                   String msg = lr.getMessage();
                   if ( msg == null )
- return;
+ return ;
                   if ( getFormatter() != null )
                      msg = getFormatter().format( lr );
                   if ( _text == null ) {
- return;
+ return ;
                   }
                   try {
                      int index = _text.getDocument().​getLength();
+ int caret_position = _text.getCaretPosition();
                      SimpleAttributeSet set = new SimpleAttributeSet();
                      if ( _font == null ) {
                         StyleConstants.setFontFamily( set, "Monospaced" );
@@ -261,16 +277,35 @@
                      else if ( lr.getLevel().equals( Level.INFO ) )
                         StyleConstants.setForeground( set, Color.BLUE );
                      _text.getDocument().​insertString( index, msg, set );
+ if (_tail)
                      _text.setCaretPosition( index + msg.length() );
+ else
+ _text.setCaretPositi​on(caret_position);
                   }
- catch ( Exception e ) {
+ catch ( Exception e ) {}
                   }
                }
- } );
+ );
       }
       catch ( Exception ignored ) {
          // ignored
       }
    }
+
+ private JPanel getControlPanel() {
+ JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ final JCheckBox tail_cb = new JCheckBox("Tail");
+ tail_cb.setSelected(true);
+ tail_cb.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ _tail = tail_cb.isSelected();
+ if (_tail)
+ _text.setCaretPositi​on(_text.getDocument​().getLength());
+ }
+ }
+ );
+ panel.add(tail_cb);
+ return panel;
+ }
 }
 

File [changed]: FindDialog.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/app/FindDialo​g.java?r1=1.1&r2​=1.2
Delta lines: +49 -115
----------------------
--- FindDialog.java 16 Feb 2004 02:39:38 -0000 1.1
+++ FindDialog.java 24 May 2004 04:10:49 -0000 1.2
@@ -12,7 +12,7 @@
  * A dialog for searching in the output panel.
  *
  * @author Dale Anson, danson at germane-software dot com
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
  */
 public class FindDialog extends JDialog {
 
@@ -54,82 +54,16 @@
       btn_panel.add( cancel_btn, "0, 2, 1, 1, 0, w, 3" );
       panel.add( btn_panel, "1, 0, 1, 3, 0, h, 5" );
 
- find_btn.addActionListener(
- new ActionListener() {
- public void actionPerformed( ActionEvent ae ) {
- String text_to_find = to_find.getText();
- if ( text_to_find == null || text_to_find.length() == 0 ) {
- return;
- }
- try {
- String doc = textarea.getDocument​().getText(0, textarea.getDocument​().getLength());
- Pattern pattern = Pattern.compile( text_to_find, Pattern.DOTALL );
- Matcher matcher = pattern.matcher( doc );
- if ( matcher.find() ) {
- int start = matcher.start();
- int end = matcher.end();
- String found = doc.substring( start, end );
- textarea.setCaretPosition( start );
- textarea.select( start, end );
- }
- }
- catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- } );
- find_next_btn.addAct​ionListener(
- new ActionListener() {
- public void actionPerformed( ActionEvent ae ) {
- String text_to_find = to_find.getText();
- if ( text_to_find == null || text_to_find.length() == 0 ) {
- return;
- }
- try {
- int initial_caret = textarea.getCaretPosition();
- int caret = initial_caret;
- String doc = textarea.getDocument​().getText(0, textarea.getDocument​().getLength());
- Pattern pattern = Pattern.compile( text_to_find, Pattern.DOTALL );
- Matcher matcher = pattern.matcher( doc );
- if ( matcher.find() ) {
- boolean done = false;
- while ( !done ) {
- matcher = pattern.matcher( doc );
- while ( matcher.find() ) {
- int start = matcher.start();
- int end = matcher.end();
- if ( start < caret ) {
- continue;
- }
- caret = end;
- String found = doc.substring( start, end );
- textarea.setCaretPosition( start );
- textarea.select( start, end );
- done = true;
- break;
- }
- if ( wrap_cb.isSelected() ) {
- caret = 0;
- }
- else {
- break;
- }
- }
- }
- }
- catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- } );
-
+ find_btn.addActionListener(new Finder(to_find, textarea, false, wrap_cb.isSelected()));
+ find_next_btn.addAct​ionListener(new Finder(to_find, textarea, true, wrap_cb.isSelected()));
       cancel_btn.addActionListener(
          new ActionListener() {
             public void actionPerformed( ActionEvent ae ) {
                setVisible( false );
                dispose();
             }
- } );
+ }
+ );
       pack();
       to_find.requestFocus();
    }

Directory: /antelope/src/ise/an​telope/app/jedit/
====================​====================​========

File [changed]: FindAndReplace.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/app/jedit/Fin​dAndReplace.java?r1=​1.1&r2=1.2
Delta lines: +275 -284
-----------------------
--- FindAndReplace.java 16 Feb 2004 02:39:38 -0000 1.1
+++ FindAndReplace.java 24 May 2004 04:10:49 -0000 1.2
@@ -19,7 +19,7 @@
  * A panel/dialog for doing find and replace on a JEditTextArea.
  *
  * @author Dale Anson, danson at germane-software dot com
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
  */
 public class FindAndReplace extends JDialog {
 
@@ -94,7 +94,7 @@
             public void actionPerformed( ActionEvent ae ) {
                String text_to_find = to_find.getText();
                if ( text_to_find == null || text_to_find.length() == 0 ) {
- return;
+ return ;
                }
                try {
                   String doc = textarea.getText();
@@ -113,13 +113,14 @@
                   e.printStackTrace();
                }
             }
- } );
+ }
+ );
       find_next_btn.addAct​ionListener(
          new ActionListener() {
             public void actionPerformed( ActionEvent ae ) {
                String text_to_find = to_find.getText();
                if ( text_to_find == null || text_to_find.length() == 0 ) {
- return;
+ return ;
                }
                try {
                   int initial_caret = textarea.getCaretPosition();
@@ -127,38 +128,22 @@
                   String doc = textarea.getText();
                   Pattern pattern = Pattern.compile( text_to_find, Pattern.DOTALL );
                   Matcher matcher = pattern.matcher( doc );
- if ( matcher.find() ) {
- boolean done = false;
- while ( !done ) {
- matcher = pattern.matcher( doc );
- while ( matcher.find() ) {
+ if (!matcher.find(caret) && wrap_cb.isSelected())
+ caret = 0;
+ if ( matcher.find(caret) ) {
                            int start = matcher.start();
                            int end = matcher.end();
- if ( start < caret ) {
- continue;
- }
- caret = end;
                            String found = doc.substring( start, end );
                            textarea.setCaretPosition( start );
- textarea.scrollToCaret();
                            textarea.select( start, end );
- done = true;
- break;
- }
- if ( wrap_cb.isSelected() ) {
- caret = 0;
- }
- else {
- break;
- }
- }
                   }
                }
                catch ( Exception e ) {
                   e.printStackTrace();
                }
             }
- } );
+ }
+ );
 
       cancel_btn.addActionListener(
          new ActionListener() {
@@ -166,7 +151,8 @@
                setVisible( false );
                dispose();
             }
- } );
+ }
+ );
 
       return panel;
    }
@@ -209,7 +195,7 @@
             public void actionPerformed( ActionEvent ae ) {
                String text_to_find = to_find.getText();
                if ( text_to_find == null || text_to_find.length() == 0 ) {
- return;
+ return ;
                }
                try {
                   String doc = textarea.getText();
@@ -228,13 +214,14 @@
                   e.printStackTrace();
                }
             }
- } );
+ }
+ );
       find_next_btn.addAct​ionListener(
          new ActionListener() {
             public void actionPerformed( ActionEvent ae ) {
                String text_to_find = to_find.getText();
                if ( text_to_find == null || text_to_find.length() == 0 ) {
- return;
+ return ;
                }
                try {
                   int initial_caret = textarea.getCaretPosition();
@@ -273,20 +260,22 @@
                   e.printStackTrace();
                }
             }
- } );
+ }
+ );
          
- replace_btn.addActio​nListener(new ActionListener(){
+ replace_btn.addActio​nListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
             textarea.setSelected​Text(replace_with.ge​tText());
          }
- });
+ }
+ );
 
       replace_all_btn.addA​ctionListener(
          new ActionListener() {
             public void actionPerformed( ActionEvent ae ) {
                String text_to_find = to_find.getText();
                if ( text_to_find == null || text_to_find.length() == 0 ) {
- return;
+ return ;
                }
                try {
                   String doc = textarea.getText();
@@ -306,7 +295,8 @@
                   e.printStackTrace();
                }
             }
- } );
+ }
+ );
          
       cancel_btn.addActionListener(
          new ActionListener() {
@@ -314,7 +304,8 @@
                setVisible( false );
                dispose();
             }
- } );
+ }
+ );
       return panel;
    }
 }

File [changed]: JEditTextArea.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/app/jedit/JEd​itTextArea.java?r1=1​.3&r2=1.4
Delta lines: +3 -3
-------------------
--- JEditTextArea.java 19 May 2004 19:13:02 -0000 1.3
+++ JEditTextArea.java 24 May 2004 04:10:49 -0000 1.4
@@ -47,7 +47,7 @@
  * + "}");</pre>
  *
  * @author Slava Pestov
- * @version $Id: JEditTextArea.java,v 1.3 2004/05/19 19:13:02 danson Exp $
+ * @version $Id: JEditTextArea.java,v 1.4 2004/05/24 04:10:49 danson Exp $
  */
 public class JEditTextArea extends JComponent {
     /**
@@ -601,7 +601,7 @@
     /**
      * Returns the document this text area is editing.
      */
- public final SyntaxDocument getDocument() {
+ public final Document getDocument() {
         return document;
     }
 

File [changed]: TextAreaPainter.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/app/jedit/Tex​tAreaPainter.java?r1​=1.3&r2=1.4
Delta lines: +2 -3
-------------------
--- TextAreaPainter.java 22 Mar 2004 23:40:35 -0000 1.3
+++ TextAreaPainter.java 24 May 2004 04:10:50 -0000 1.4
@@ -19,7 +19,7 @@
  * The text area repaint manager. It performs double buffering and paints
  * lines of text.
  * @author Slava Pestov
- * @version $Id: TextAreaPainter.java,v 1.3 2004/03/22 23:40:35 danson Exp $
+ * @version $Id: TextAreaPainter.java,v 1.4 2004/05/24 04:10:50 danson Exp $
  */
 public class TextAreaPainter extends JComponent implements TabExpander
 {
@@ -380,8 +380,7 @@
 
         try
         {
- TokenMarker tokenMarker = textArea.getDocument()
- .getTokenMarker();
+ TokenMarker tokenMarker = ((SyntaxDocument)tex​tArea.getDocument())​.getTokenMarker();
             int x = textArea.getHorizontalOffset();
 
             for(int line = firstInvalid; line <= lastInvalid; line++)




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@ante​lope.tigris.org
For additional commands, e-mail: cvs-help at antelope dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /antelope/src/ise/antelope/app/, /antelope/src/ise/antelope/app/jedit/ danson Dale Anson 2004-05-23 21:10:50 PDT
Messages per page: