1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.webphotos.gui.component;
17
18
19
20
21
22
23 import java.awt.event.MouseListener;
24 import java.io.Serializable;
25 import javax.swing.JPanel;
26 import net.sf.webphotos.action.AcaoPesquisa;
27
28
29
30
31
32
33
34 public class PainelPesquisa extends JPanel implements Serializable {
35
36 private AcaoPesquisa acaoPesquisa;
37
38
39
40
41
42 public PainelPesquisa() {
43 initComponents();
44
45
46
47
48
49
50 }
51
52 private void registerResearchActionComponent(AcaoPesquisa acaoPesquisa) {
53 btPesquisar.addActionListener(acaoPesquisa);
54 txtPesquisa.registerKeyboardAction(acaoPesquisa,
55 javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, 0),
56 javax.swing.JComponent.WHEN_FOCUSED);
57 }
58
59
60
61
62
63
64
65 private void initComponents() {
66
67 painelBusca = new javax.swing.JPanel();
68 lblPesquisar = new javax.swing.JLabel();
69 lstCategoriasPesquisa = new javax.swing.JComboBox();
70 lblPalavras = new javax.swing.JLabel();
71 txtPesquisa = new javax.swing.JTextField();
72 btPesquisar = new javax.swing.JButton();
73 painelSQL = new javax.swing.JPanel();
74 btFiltro = new javax.swing.JButton();
75
76 setMaximumSize(new java.awt.Dimension(65534, 35));
77 setMinimumSize(new java.awt.Dimension(780, 35));
78 setPreferredSize(new java.awt.Dimension(780, 35));
79 setLayout(new java.awt.BorderLayout());
80
81 painelBusca.setMaximumSize(new java.awt.Dimension(32767, 35));
82 painelBusca.setPreferredSize(new java.awt.Dimension(461, 35));
83 painelBusca.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
84
85 lblPesquisar.setText("Pesquisar em");
86 painelBusca.add(lblPesquisar);
87
88 lstCategoriasPesquisa.setName("lstCategoriasPesquisa");
89 painelBusca.add(lstCategoriasPesquisa);
90
91 lblPalavras.setText("palavra(s)");
92 painelBusca.add(lblPalavras);
93
94 txtPesquisa.setMinimumSize(new java.awt.Dimension(192, 19));
95 txtPesquisa.setPreferredSize(new java.awt.Dimension(192, 19));
96 painelBusca.add(txtPesquisa);
97
98 btPesquisar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/zoom16.gif")));
99 btPesquisar.setText("pesquisar");
100 painelBusca.add(btPesquisar);
101
102 add(painelBusca, java.awt.BorderLayout.CENTER);
103
104 painelSQL.setMaximumSize(new java.awt.Dimension(32767, 35));
105 painelSQL.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
106
107 btFiltro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/sql.gif")));
108 painelSQL.add(btFiltro);
109
110 add(painelSQL, java.awt.BorderLayout.EAST);
111 }
112
113 private javax.swing.JButton btFiltro;
114 private javax.swing.JButton btPesquisar;
115 private javax.swing.JLabel lblPalavras;
116 private javax.swing.JLabel lblPesquisar;
117 private javax.swing.JComboBox lstCategoriasPesquisa;
118 private javax.swing.JPanel painelBusca;
119 private javax.swing.JPanel painelSQL;
120 private javax.swing.JTextField txtPesquisa;
121
122
123 private javax.swing.ComboBoxModel categoriasPesquisaComboBoxModel;
124
125
126
127
128
129
130
131 public javax.swing.ComboBoxModel getCategoriasPesquisaComboBoxModel() {
132 return categoriasPesquisaComboBoxModel;
133 }
134
135
136
137
138
139
140
141
142 public void setCategoriasPesquisaComboBoxModel(javax.swing.ComboBoxModel lstCategoriasPesquisaModel) {
143 this.categoriasPesquisaComboBoxModel = lstCategoriasPesquisaModel;
144 lstCategoriasPesquisa.setModel(this.categoriasPesquisaComboBoxModel);
145 }
146
147
148
149
150 public void addPopupMouseListener(MouseListener popupAction) {
151 btFiltro.addMouseListener(popupAction);
152 }
153
154
155
156
157 public void removePopupMouseListener(MouseListener popupAction) {
158 btFiltro.removeMouseListener(popupAction);
159 }
160
161
162
163
164 public AcaoPesquisa getAcaoPesquisa() {
165 return acaoPesquisa;
166 }
167
168
169
170
171 public synchronized void setAcaoPesquisa(AcaoPesquisa acaoPesquisa) {
172 this.acaoPesquisa = acaoPesquisa;
173 registerResearchActionComponent(this.acaoPesquisa);
174 }
175 }