View Javadoc

1   /*
2    * Fsgrep is a simple Java application which allows a user to
3    * search all files in a directory structure for lines matching
4    * a given pattern.  Its functionality is a combination of the
5    * Unix 'find' and 'grep' utilities.
6    * Visit [http://fsgrep.sourceforge.net/] for more information.
7    * 
8    * Copyright (C) 2003-2006 Murali Krishnan [murali_ca_us@users.sourceforge.net]
9    * 
10   * Fsgrep is free software; you can redistribute it and/or modify
11   * it under the terms of version 2 of the GNU General Public
12   * License as published by the Free Software Foundation.
13   * 
14   * Fsgrep is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public License
20   * along with Fsgrep (see the file named LICENSE.txt); if not, write
21   * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22   * Boston, MA  02111-1307  USA
23   */
24  
25  package mk.fsgrep.gui;
26  
27  
28  import java.awt.*;
29  import java.awt.event.ActionEvent;
30  import java.awt.event.ActionListener;
31  import java.awt.event.WindowAdapter;
32  import java.awt.event.WindowEvent;
33  
34  import javax.swing.*;
35  
36  import mk.fsgrep.util.output.TextAreaOutput;
37  
38  
39  /***
40   * 
41   * 
42   * @author  Murali Krishnan
43   *
44   */
45  public class FilelistDisplay extends JFrame {
46  
47      //------------------------------------------------------------
48      //- Class Variables
49  
50  
51  
52      //------------------------------------------------------------
53      //- Class Functions
54  
55  
56  
57      //------------------------------------------------------------
58      //- Instance Variables
59  
60      private JTextArea _textArea = new JTextArea("", 30, 60);
61      private JButton _buttonOk = new JButton("OK");
62  
63  
64  
65      //------------------------------------------------------------
66      //- Constructors
67  
68      public FilelistDisplay() 
69      {
70          super("FileList");
71  
72          defineActions();
73          makeFrame();
74      }
75  
76  
77      //------------------------------------------------------------
78      //- Accessors
79  
80      protected JTextArea getTextArea() {return _textArea;}
81      protected JButton getButtonOk() {return _buttonOk;}
82  
83  
84  
85      //------------------------------------------------------------
86      //- Settors
87  
88  
89  
90      //------------------------------------------------------------
91      //- Private/Protected Utility Functions
92  
93      protected void defineActions() {
94          getTextArea().setEditable(false);
95  
96          getButtonOk().addActionListener(new ActionListener() {
97                  public void actionPerformed (ActionEvent aEvent) {
98                      setVisible(false);
99                  }
100             });
101 
102         addWindowListener(new WindowAdapter() {
103                 public void windowActivated(WindowEvent e) {
104                     getButtonOk().grabFocus();
105                 }
106             });
107     }
108 
109 
110     protected void makeFrame() {
111         getContentPane().setLayout(new BorderLayout());
112 
113         JScrollPane scrollPane = new JScrollPane();
114         scrollPane.setViewportView(getTextArea());
115 
116         JPanel buttonPanel = new JPanel();
117         {
118             buttonPanel.setLayout(new BorderLayout());
119             buttonPanel.add(getButtonOk(), BorderLayout.EAST);
120         }
121 
122         getContentPane().add(scrollPane, BorderLayout.CENTER);
123         getContentPane().add(buttonPanel, BorderLayout.SOUTH);
124 
125         pack();
126     }
127 
128 
129     //------------------------------------------------------------
130     //- Public Interface Functions
131 
132     public TextAreaOutput getOutput() {
133         TextAreaOutput result = new TextAreaOutput(getTextArea());
134 
135         return result;
136     }
137 
138 
139     public void clearText() {
140         getTextArea().setText("");
141     }
142 
143     //------------------------------------------------------------
144     //- Class Interface Functions
145 
146 
147 
148     //------------------------------------------------------------
149     //- Inner Classes
150 
151 
152 
153     //------------------------------------------------------------
154     //- Main
155 
156 
157 
158 }