svn-gvsig-desktop / trunk / libraries / libUI / src / org / gvsig / gui / beans / filterPanel / tableFilterQueryPanel / TableFilterQueryJPanel.java @ 8237
History | View | Annotate | Download (9.11 KB)
1 |
package org.gvsig.gui.beans.filterPanel.tableFilterQueryPanel; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.GridBagConstraints; |
5 |
import java.awt.GridBagLayout; |
6 |
import java.awt.event.MouseAdapter; |
7 |
import java.awt.event.MouseEvent; |
8 |
import java.io.Serializable; |
9 |
import java.util.Vector; |
10 |
|
11 |
import javax.swing.DefaultListModel; |
12 |
import javax.swing.JPanel; |
13 |
import javax.swing.JScrollPane; |
14 |
|
15 |
import org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel; |
16 |
|
17 |
import com.iver.andami.PluginServices; |
18 |
|
19 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
20 |
*
|
21 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
22 |
*
|
23 |
* This program is free software; you can redistribute it and/or
|
24 |
* modify it under the terms of the GNU General Public License
|
25 |
* as published by the Free Software Foundation; either version 2
|
26 |
* of the License, or (at your option) any later version.
|
27 |
*
|
28 |
* This program is distributed in the hope that it will be useful,
|
29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
31 |
* GNU General Public License for more details.
|
32 |
*
|
33 |
* You should have received a copy of the GNU General Public License
|
34 |
* along with this program; if not, write to the Free Software
|
35 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
36 |
*
|
37 |
* For more information, contact:
|
38 |
*
|
39 |
* Generalitat Valenciana
|
40 |
* Conselleria d'Infraestructures i Transport
|
41 |
* Av. Blasco Ib??ez, 50
|
42 |
* 46010 VALENCIA
|
43 |
* SPAIN
|
44 |
*
|
45 |
* +34 963862235
|
46 |
* gvsig@gva.es
|
47 |
* www.gvsig.gva.es
|
48 |
*
|
49 |
* or
|
50 |
*
|
51 |
* IVER T.I. S.A
|
52 |
* Salamanca 50
|
53 |
* 46005 Valencia
|
54 |
* Spain
|
55 |
*
|
56 |
* +34 963163400
|
57 |
* dac@iver.es
|
58 |
*/
|
59 |
|
60 |
/**
|
61 |
* This class is the graphical interface of the "FilterDialog" which was made by Fernando and is in 'appgvSIG' project.
|
62 |
* It's supposed that other classes will extend from this and will add the logic as is in the "FilterDialog" class.
|
63 |
*
|
64 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
65 |
*/
|
66 |
public class TableFilterQueryJPanel extends AbstractFilterQueryJPanel implements Serializable { |
67 |
private static final long serialVersionUID = -4758271351761958190L; |
68 |
|
69 |
protected javax.swing.JPanel setButtonsJPanel = null; |
70 |
protected javax.swing.JButton btnNuevo = null; |
71 |
protected javax.swing.JButton btnAdd = null; |
72 |
protected javax.swing.JButton btnFromSet = null; |
73 |
protected javax.swing.JScrollPane fieldsJScrollPane = null; |
74 |
protected javax.swing.JScrollPane valuesJScrollPane = null; |
75 |
protected int defaultSetButtonsPanelWidth = 170; |
76 |
protected int defaultSetButtonsPanelHeight = 100; |
77 |
protected int filterJScrollPaneHeight = defaultBottomJPanelHeight - 10; |
78 |
protected int filterJScrollPanelWidth = defaultBottomJPanelWidth - 10 - defaultSetButtonsPanelWidth; |
79 |
|
80 |
/**
|
81 |
* @see AbstractFilterQueryJPanel#AbstractFilterQueryJPanel()
|
82 |
*/
|
83 |
public TableFilterQueryJPanel() {
|
84 |
super();
|
85 |
this.initialize();
|
86 |
} |
87 |
|
88 |
/**
|
89 |
* @see AbstractFilterQueryJPanel#AbstractFilterQueryJPanel(String)
|
90 |
*/
|
91 |
public TableFilterQueryJPanel(String _title) { |
92 |
super(_title);
|
93 |
this.initialize();
|
94 |
} |
95 |
|
96 |
/*
|
97 |
* (non-Javadoc)
|
98 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#initialize()
|
99 |
*/
|
100 |
protected void initialize() { |
101 |
super.initialize();
|
102 |
|
103 |
fieldsJTree.addMouseListener(new MouseAdapter() { |
104 |
/*
|
105 |
* (non-Javadoc)
|
106 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
107 |
*/
|
108 |
public void mouseClicked(MouseEvent e) { |
109 |
int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
|
110 |
|
111 |
if (row > -1) { |
112 |
Vector values = layerFeaturesFields.getValues(row);
|
113 |
|
114 |
((DefaultListModel)valuesJList.getModel()).clear();
|
115 |
|
116 |
for (int i = 0; i < values.size(); i++) |
117 |
((DefaultListModel)valuesJList.getModel()).addElement(values.get(i).toString());
|
118 |
} |
119 |
} |
120 |
}); |
121 |
} |
122 |
|
123 |
/*
|
124 |
* (non-Javadoc)
|
125 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFieldsJPanel()
|
126 |
*/
|
127 |
protected JPanel getFieldsJPanel() { |
128 |
if (fieldsJPanel == null) { |
129 |
fieldsJPanel = new javax.swing.JPanel();
|
130 |
fieldsJPanel.setPreferredSize(new java.awt.Dimension(fieldsJPanelWidth, fieldsJPanelHeight));
|
131 |
fieldsJPanel.setLayout(new GridBagLayout()); |
132 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
133 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
134 |
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
135 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
136 |
fieldsJPanel.add(getFieldsJLabel(), gridBagConstraints); |
137 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
138 |
fieldsJPanel.add(getFieldsJScrollPane(), gridBagConstraints); |
139 |
} |
140 |
|
141 |
return fieldsJPanel;
|
142 |
} |
143 |
|
144 |
/**
|
145 |
* This method initializes jScrollPane
|
146 |
*
|
147 |
* @return javax.swing.JScrollPane
|
148 |
*/
|
149 |
private javax.swing.JScrollPane getFieldsJScrollPane() {
|
150 |
if (fieldsJScrollPane == null) { |
151 |
fieldsJScrollPane = new javax.swing.JScrollPane();
|
152 |
fieldsJScrollPane.setPreferredSize(new java.awt.Dimension(fieldsAndValuesJScrollPaneWidth, fieldsAndValuesJScrollPaneHeight));
|
153 |
fieldsJScrollPane.setViewportView(getFieldsJTree()); |
154 |
} |
155 |
|
156 |
return fieldsJScrollPane;
|
157 |
} |
158 |
|
159 |
/*
|
160 |
* (non-Javadoc)
|
161 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getValuesJPanel()
|
162 |
*/
|
163 |
protected JPanel getValuesJPanel() { |
164 |
if (valuesJPanel == null) { |
165 |
valuesJPanel = new javax.swing.JPanel();
|
166 |
valuesJPanel.setPreferredSize(new java.awt.Dimension(valuesJPanelWidth, valuesJPanelHeight));
|
167 |
valuesJPanel.setLayout(new GridBagLayout()); |
168 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
169 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
170 |
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
171 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
172 |
valuesJPanel.add(getValuesJLabel(), gridBagConstraints); |
173 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
174 |
valuesJPanel.add(getValuesJScrollPane(), gridBagConstraints); |
175 |
} |
176 |
|
177 |
return valuesJPanel;
|
178 |
} |
179 |
|
180 |
/**
|
181 |
* This method initializes jScrollPane1
|
182 |
*
|
183 |
* @return javax.swing.JScrollPane
|
184 |
*/
|
185 |
private javax.swing.JScrollPane getValuesJScrollPane() {
|
186 |
if (valuesJScrollPane == null) { |
187 |
valuesJScrollPane = new javax.swing.JScrollPane();
|
188 |
valuesJScrollPane.setPreferredSize(new Dimension(fieldsAndValuesJScrollPaneWidth, fieldsAndValuesJScrollPaneHeight)); |
189 |
valuesJScrollPane.setViewportView(getValuesJList()); |
190 |
} |
191 |
|
192 |
return valuesJScrollPane;
|
193 |
} |
194 |
|
195 |
/*
|
196 |
* (non-Javadoc)
|
197 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFilterJScrollPane()
|
198 |
*/
|
199 |
protected JScrollPane getFilterJScrollPane() { |
200 |
if (filterJScrollPane == null) { |
201 |
filterJScrollPane = new javax.swing.JScrollPane();
|
202 |
filterJScrollPane.setPreferredSize(new java.awt.Dimension(filterJScrollPanelWidth, filterJScrollPaneHeight));
|
203 |
filterJScrollPane.setViewportView(getTxtExpression()); |
204 |
filterJScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
205 |
} |
206 |
|
207 |
return filterJScrollPane;
|
208 |
} |
209 |
|
210 |
/**
|
211 |
* This method initializes setButtonsJPanel
|
212 |
*
|
213 |
* @return javax.swing.JPanel
|
214 |
*/
|
215 |
private javax.swing.JPanel getSetButtonsJPanel() {
|
216 |
if (setButtonsJPanel == null) { |
217 |
setButtonsJPanel = new javax.swing.JPanel();
|
218 |
setButtonsJPanel.setPreferredSize(new java.awt.Dimension(defaultSetButtonsPanelWidth, defaultSetButtonsPanelHeight));
|
219 |
setButtonsJPanel.add(getBtnNuevo(), null);
|
220 |
setButtonsJPanel.add(getBtnAdd(), null);
|
221 |
setButtonsJPanel.add(getBtnFromSet(), null);
|
222 |
} |
223 |
|
224 |
return setButtonsJPanel;
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* This method initializes btnNuevo
|
229 |
*
|
230 |
* @return javax.swing.JButton
|
231 |
*/
|
232 |
private javax.swing.JButton getBtnNuevo() {
|
233 |
if (btnNuevo == null) { |
234 |
btnNuevo = new javax.swing.JButton();
|
235 |
btnNuevo.setText(PluginServices.getText(this, "Nuevo_conjunto")); |
236 |
btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
237 |
} |
238 |
|
239 |
return btnNuevo;
|
240 |
} |
241 |
|
242 |
/**
|
243 |
* This method initializes btnAdd
|
244 |
*
|
245 |
* @return javax.swing.JButton
|
246 |
*/
|
247 |
private javax.swing.JButton getBtnAdd() {
|
248 |
if (btnAdd == null) { |
249 |
btnAdd = new javax.swing.JButton();
|
250 |
btnAdd.setText(PluginServices.getText(this, "Anadir_al_conjunto")); |
251 |
btnAdd.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
252 |
} |
253 |
|
254 |
return btnAdd;
|
255 |
} |
256 |
|
257 |
/**
|
258 |
* This method initializes btnFromSet
|
259 |
*
|
260 |
* @return javax.swing.JButton
|
261 |
*/
|
262 |
private javax.swing.JButton getBtnFromSet() {
|
263 |
if (btnFromSet == null) { |
264 |
btnFromSet = new javax.swing.JButton();
|
265 |
btnFromSet.setText(PluginServices.getText(this,
|
266 |
"Seleccionar_del_conjunto"));
|
267 |
btnFromSet.setMargin(new java.awt.Insets(2, 2, 2, 2)); |
268 |
} |
269 |
|
270 |
return btnFromSet;
|
271 |
} |
272 |
|
273 |
/**
|
274 |
* This method initializes txtExpression
|
275 |
*
|
276 |
* @return javax.swing.JTextArea
|
277 |
*/
|
278 |
private javax.swing.JTextArea getTxtExpression() {
|
279 |
if (txtExpression == null) { |
280 |
txtExpression = new javax.swing.JTextArea();
|
281 |
txtExpression.setLineWrap(true);
|
282 |
} |
283 |
|
284 |
return txtExpression;
|
285 |
} |
286 |
|
287 |
/*
|
288 |
* (non-Javadoc)
|
289 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getBottomJPanel()
|
290 |
*/
|
291 |
protected JPanel getBottomJPanel() { |
292 |
if (bottomJPanel == null) { |
293 |
bottomJPanel = new JPanel(); |
294 |
bottomJPanel.setPreferredSize(new Dimension(defaultBottomJPanelWidth, defaultBottomJPanelHeight)); |
295 |
bottomJPanel.add(getFilterJScrollPane(), null);
|
296 |
bottomJPanel.add(getSetButtonsJPanel(), null);
|
297 |
} |
298 |
|
299 |
return bottomJPanel;
|
300 |
} |
301 |
} |