Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / panel / selectPackages2 / FastFilterButtonsPanel.java @ 37538

History | View | Annotate | Download (3.2 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.installer.swing.impl.execution.panel.selectPackages2;
23

    
24
import java.awt.FlowLayout;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27
import java.awt.event.KeyEvent;
28
import java.awt.event.KeyListener;
29

    
30
import javax.swing.JButton;
31
import javax.swing.JLabel;
32
import javax.swing.JPanel;
33
import javax.swing.JTextField;
34

    
35
/**
36
 * @author gvSIG Team
37
 * @version $Id$
38
 * 
39
 */
40
public class FastFilterButtonsPanel extends JPanel implements ActionListener {
41

    
42
    private static final long serialVersionUID = 3767011079359743742L;
43

    
44
    private PackagesTablePanel panel;
45

    
46
    private JButton searchButton;
47
    private JButton resetButton;
48
    private JTextField textField;
49

    
50
    public FastFilterButtonsPanel(PackagesTablePanel panel) {
51
        this.panel = panel;
52
        initComponents();
53
    }
54

    
55
    private void initComponents() {
56

    
57
        JLabel fastFilterLabel = new JLabel("fast_filter");
58

    
59
        textField = new JTextField(20);
60

    
61
        KeyListener l = new KeyListener() {
62

    
63
            public void keyTyped(KeyEvent e) {
64
            }
65

    
66
            public void keyReleased(KeyEvent e) {
67
                if (e.getKeyChar() == '\n') {
68
                    searchAction();
69
                }
70
            }
71

    
72
            public void keyPressed(KeyEvent e) {
73
            }
74
        };
75

    
76
        textField.addKeyListener(l);
77

    
78
        searchButton = new JButton("search");
79
        searchButton.setActionCommand("search");
80
        searchButton.addActionListener(this);
81

    
82
        resetButton = new JButton("reset");
83
        resetButton.setActionCommand("reset");
84
        resetButton.addActionListener(this);
85

    
86
        setLayout(new FlowLayout(FlowLayout.LEFT));
87

    
88
        add(fastFilterLabel);
89
        add(textField);
90
        add(searchButton);
91
        add(resetButton);
92

    
93
    }
94

    
95
    public void actionPerformed(ActionEvent e) {
96
        if ("search".equals(e.getActionCommand())) {
97
            searchAction();
98
        } else
99
            if ("reset".equals(e.getActionCommand())) {
100
                resetAction();
101
            }
102
    }
103

    
104
    private void searchAction() {
105
        if (textField.equals("")) {
106
            panel.setFilter(null);
107
        } else {
108
            panel.setFilter(new NameAndDescriptionFilter(textField.getText()));
109
        }
110
    }
111

    
112
    private void resetAction() {
113
        panel.setFilter(null);
114
        textField.setText("");
115
    }
116

    
117
}