svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / panel / FastFilterButtonsPanel.java @ 40560
History | View | Annotate | Download (3.63 KB)
1 | 40560 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40560 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40560 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40560 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.installer.swing.impl.execution.panel; |
||
25 | |||
26 | import java.awt.FlowLayout; |
||
27 | import java.awt.event.ActionEvent; |
||
28 | import java.awt.event.ActionListener; |
||
29 | import java.awt.event.KeyEvent; |
||
30 | import java.awt.event.KeyListener; |
||
31 | |||
32 | import javax.swing.JButton; |
||
33 | import javax.swing.JLabel; |
||
34 | import javax.swing.JPanel; |
||
35 | import javax.swing.JTextField; |
||
36 | |||
37 | import org.gvsig.installer.swing.api.SwingInstallerLocator; |
||
38 | import org.gvsig.installer.swing.api.SwingInstallerManager; |
||
39 | import org.gvsig.installer.swing.impl.execution.panel.filters.NameDescriptionOrCodeFilter; |
||
40 | |||
41 | /**
|
||
42 | * @author gvSIG Team
|
||
43 | * @version $Id$
|
||
44 | *
|
||
45 | */
|
||
46 | public class FastFilterButtonsPanel extends JPanel implements ActionListener { |
||
47 | |||
48 | private static final long serialVersionUID = 3767011079359743742L; |
||
49 | |||
50 | private PackagesTablePanel panel;
|
||
51 | private SwingInstallerManager swingInstallerManager;
|
||
52 | |||
53 | private JButton searchButton; |
||
54 | private JButton resetButton; |
||
55 | private JTextField textField; |
||
56 | private NameDescriptionOrCodeFilter filter = null; |
||
57 | |||
58 | public FastFilterButtonsPanel(PackagesTablePanel panel) {
|
||
59 | this.panel = panel;
|
||
60 | swingInstallerManager = SwingInstallerLocator |
||
61 | .getSwingInstallerManager(); |
||
62 | initComponents(); |
||
63 | } |
||
64 | |||
65 | private void initComponents() { |
||
66 | |||
67 | filter = new NameDescriptionOrCodeFilter(""); |
||
68 | |||
69 | JLabel fastFilterLabel = new JLabel(swingInstallerManager |
||
70 | .getText("_fast_filter"));
|
||
71 | |||
72 | textField = new JTextField(20); |
||
73 | |||
74 | MyKeyListener l = new MyKeyListener();
|
||
75 | |||
76 | textField.addKeyListener(l); |
||
77 | |||
78 | searchButton = new JButton(swingInstallerManager.getText("_search")); |
||
79 | searchButton.setActionCommand("search");
|
||
80 | searchButton.addActionListener(this);
|
||
81 | |||
82 | resetButton = new JButton(swingInstallerManager |
||
83 | .getText("_reset_filters"));
|
||
84 | resetButton.setActionCommand("reset");
|
||
85 | resetButton.addActionListener(this);
|
||
86 | |||
87 | setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); |
||
88 | |||
89 | add(fastFilterLabel); |
||
90 | add(textField); |
||
91 | // search button not needed with key listener
|
||
92 | // add(searchButton);
|
||
93 | add(resetButton); |
||
94 | |||
95 | } |
||
96 | |||
97 | public void actionPerformed(ActionEvent e) { |
||
98 | if ("search".equals(e.getActionCommand())) { |
||
99 | searchAction(); |
||
100 | } else if ("reset".equals(e.getActionCommand())) { |
||
101 | resetAction(); |
||
102 | } |
||
103 | } |
||
104 | |||
105 | private void searchAction() { |
||
106 | filter.setFilter(textField.getText()); |
||
107 | panel.setFilter(filter); |
||
108 | } |
||
109 | |||
110 | private void resetAction() { |
||
111 | this.resetPanel();
|
||
112 | } |
||
113 | |||
114 | public void resetPanel() { |
||
115 | textField.setText("");
|
||
116 | filter.setFilter("");
|
||
117 | panel.setFilter(filter); |
||
118 | panel.resetPanel(); |
||
119 | } |
||
120 | |||
121 | private class MyKeyListener implements KeyListener { |
||
122 | |||
123 | public void keyTyped(KeyEvent e) { |
||
124 | } |
||
125 | |||
126 | public void keyReleased(KeyEvent e) { |
||
127 | searchAction(); |
||
128 | textField.requestFocus(); |
||
129 | textField.setCaretPosition(textField.getDocument().getLength()); |
||
130 | } |
||
131 | |||
132 | public void keyPressed(KeyEvent e) { |
||
133 | } |
||
134 | } |
||
135 | |||
136 | } |