KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ca > directory > jxplorer > search > TextFilterPanel


1 package com.ca.directory.jxplorer.search;
2
3 import javax.swing.*;
4 import java.awt.Color JavaDoc;
5
6 import com.ca.commons.cbutil.*;
7
8
9
10 /**
11 * A basic panel that has a text area which the value can be set and
12 * retreived. Currently used in the search dialog for the text input
13 * of LDAP filters.
14 * .
15 */

16     
17 class TextFilterPanel extends CBPanel
18 {
19     JTextArea area;
20     
21     
22     
23    /**
24     * Constructs a panel with a text area that is currently used by the search dialog.
25     * .
26     */

27             
28     public TextFilterPanel()
29     {
30         addln(new JLabel(" ")); //TE: padding at top.
31
makeHeavy();
32         area = new JTextArea();
33         area.setLineWrap(true); //TE: allows line wrapping.
34
add(new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER),1,1); //TE: scroll pane that scrolls vertically on need and never scrolls horizontally.
35
}
36     
37     
38     
39    /**
40     * Returns the value from the text area.
41     * @return the string value (hopefully a valid filter) from the text area.
42     * .
43     */

44         
45     public String JavaDoc getFilter()
46     {
47         return area.getText();
48     }
49     
50     
51     
52    /**
53     * Displays the given string filter in the text area.
54     * @param filter the string filter to display in the text area.
55     * .
56     */

57         
58     public void displayFilter(String JavaDoc filter)
59     {
60         area.setText(filter);
61     }
62             
63     
64     
65    /**
66     * This basically only checks if there is a value in the text area. It doesn't
67     * do a syntax check of the LDAP filter...we leave that up to the dsa.
68     * @return true if there is a value (if after a string trim the length is greater than zero),
69     * false otherwise.
70     * .
71     */

72     
73     public boolean isFilterValid()
74     {
75         String JavaDoc filter = area.getText();
76         
77         if (filter.trim().length() <=0)
78             return false;
79     
80         return true;
81     }
82 }
Popular Tags