root / 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 / FastFilterButtonsPanel.java @ 37585
History | View | Annotate | Download (3.54 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; |
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 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
36 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
37 |
import org.gvsig.installer.swing.impl.execution.panel.filters.NameDescriptionOrCodeFilter; |
38 |
|
39 |
/**
|
40 |
* @author gvSIG Team
|
41 |
* @version $Id$
|
42 |
*
|
43 |
*/
|
44 |
public class FastFilterButtonsPanel extends JPanel implements ActionListener { |
45 |
|
46 |
private static final long serialVersionUID = 3767011079359743742L; |
47 |
|
48 |
private PackagesTablePanel panel;
|
49 |
private SwingInstallerManager swingInstallerManager;
|
50 |
|
51 |
private JButton searchButton; |
52 |
private JButton resetButton; |
53 |
private JTextField textField; |
54 |
private NameDescriptionOrCodeFilter filter = null; |
55 |
|
56 |
public FastFilterButtonsPanel(PackagesTablePanel panel) {
|
57 |
this.panel = panel;
|
58 |
swingInstallerManager = SwingInstallerLocator |
59 |
.getSwingInstallerManager(); |
60 |
initComponents(); |
61 |
} |
62 |
|
63 |
private void initComponents() { |
64 |
|
65 |
filter = new NameDescriptionOrCodeFilter(""); |
66 |
|
67 |
JLabel fastFilterLabel = new JLabel(swingInstallerManager |
68 |
.getText("_fast_filter"));
|
69 |
|
70 |
textField = new JTextField(20); |
71 |
|
72 |
MyKeyListener l = new MyKeyListener();
|
73 |
|
74 |
textField.addKeyListener(l); |
75 |
|
76 |
searchButton = new JButton(swingInstallerManager.getText("_search")); |
77 |
searchButton.setActionCommand("search");
|
78 |
searchButton.addActionListener(this);
|
79 |
|
80 |
resetButton = new JButton(swingInstallerManager.getText("_reset_filters")); |
81 |
resetButton.setActionCommand("reset");
|
82 |
resetButton.addActionListener(this);
|
83 |
|
84 |
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); |
85 |
|
86 |
add(fastFilterLabel); |
87 |
add(textField); |
88 |
// add(searchButton);
|
89 |
add(resetButton); |
90 |
|
91 |
} |
92 |
|
93 |
public void actionPerformed(ActionEvent e) { |
94 |
if ("search".equals(e.getActionCommand())) { |
95 |
searchAction(); |
96 |
} else {
|
97 |
if ("reset".equals(e.getActionCommand())) { |
98 |
resetAction(); |
99 |
} |
100 |
} |
101 |
} |
102 |
|
103 |
private void searchAction() { |
104 |
filter.setFilter(textField.getText()); |
105 |
panel.setFilter(filter); |
106 |
} |
107 |
|
108 |
private void resetAction() { |
109 |
this.resetPanel();
|
110 |
} |
111 |
|
112 |
public void resetPanel() { |
113 |
textField.setText("");
|
114 |
filter.setFilter("");
|
115 |
panel.setFilter(filter); |
116 |
panel.resetPanel(); |
117 |
} |
118 |
|
119 |
private class MyKeyListener implements KeyListener { |
120 |
|
121 |
public void keyTyped(KeyEvent e) { |
122 |
} |
123 |
|
124 |
public void keyReleased(KeyEvent e) { |
125 |
searchAction(); |
126 |
textField.requestFocus(); |
127 |
textField.setCaretPosition(textField.getDocument().getLength()); |
128 |
} |
129 |
|
130 |
public void keyPressed(KeyEvent e) { |
131 |
} |
132 |
} |
133 |
|
134 |
} |