svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / filterPanel / tableFilterQueryPanel / TableFilterQueryJPanel.java @ 40561
History | View | Annotate | Download (14.3 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.gui.beans.filterPanel.tableFilterQueryPanel; |
25 |
|
26 |
import java.awt.Dimension; |
27 |
import java.awt.GridBagConstraints; |
28 |
import java.awt.GridBagLayout; |
29 |
import java.io.Serializable; |
30 |
|
31 |
import javax.swing.BorderFactory; |
32 |
import javax.swing.DefaultListModel; |
33 |
import javax.swing.JPanel; |
34 |
import javax.swing.JScrollPane; |
35 |
import javax.swing.tree.DefaultMutableTreeNode; |
36 |
|
37 |
import org.gvsig.gui.beans.Messages; |
38 |
import org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel; |
39 |
|
40 |
|
41 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
42 |
*
|
43 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
44 |
*
|
45 |
* This program is free software; you can redistribute it and/or
|
46 |
* modify it under the terms of the GNU General Public License
|
47 |
* as published by the Free Software Foundation; either version 2
|
48 |
* of the License, or (at your option) any later version.
|
49 |
*
|
50 |
* This program is distributed in the hope that it will be useful,
|
51 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
52 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
53 |
* GNU General Public License for more details.
|
54 |
*
|
55 |
* You should have received a copy of the GNU General Public License
|
56 |
* along with this program; if not, write to the Free Software
|
57 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
58 |
*
|
59 |
* For more information, contact:
|
60 |
*
|
61 |
* Generalitat Valenciana
|
62 |
* Conselleria d'Infraestructures i Transport
|
63 |
* Av. Blasco Ib??ez, 50
|
64 |
* 46010 VALENCIA
|
65 |
* SPAIN
|
66 |
*
|
67 |
* +34 963862235
|
68 |
* gvsig@gva.es
|
69 |
* www.gvsig.gva.es
|
70 |
*
|
71 |
* or
|
72 |
*
|
73 |
* IVER T.I. S.A
|
74 |
* Salamanca 50
|
75 |
* 46005 Valencia
|
76 |
* Spain
|
77 |
*
|
78 |
* +34 963163400
|
79 |
* dac@iver.es
|
80 |
*/
|
81 |
|
82 |
/**
|
83 |
* This class is the graphical interface of the "FilterDialog" which was made by Fernando and is in 'appgvSIG' project.
|
84 |
* It's supposed that other classes will extend from this and will add the logic as is in the "FilterDialog" class.
|
85 |
*
|
86 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
87 |
*/
|
88 |
public class TableFilterQueryJPanel extends AbstractFilterQueryJPanel implements Serializable { |
89 |
private static final long serialVersionUID = 7215933791644769237L; |
90 |
|
91 |
protected JPanelML buttonsSetJPanel = null; |
92 |
protected JButtonML btnNewSet = null; |
93 |
protected JButtonML btnAddToCurrentSet = null; |
94 |
protected JButtonML btnFromSet = null; |
95 |
protected int defaultButtonsSetPanelWidth = 190; |
96 |
protected int defaultButtonsSetPanelHeight = 100; |
97 |
protected int filterJScrollPaneHeight = defaultBottomJPanelHeight - 10; |
98 |
protected int filterJScrollPanelWidth = defaultBottomJPanelWidth - 10 - defaultButtonsSetPanelWidth; |
99 |
protected int setButtonWidth = defaultButtonsSetPanelWidth - 5; |
100 |
protected int setButtonHeight = 25; |
101 |
|
102 |
protected DefaultMutableTreeNode jtreeRoot; |
103 |
|
104 |
/**
|
105 |
* @see AbstractFilterQueryJPanel#AbstractFilterQueryJPanel()
|
106 |
*/
|
107 |
public TableFilterQueryJPanel() {
|
108 |
super();
|
109 |
this.initialize();
|
110 |
} |
111 |
|
112 |
/**
|
113 |
* @see AbstractFilterQueryJPanel#AbstractFilterQueryJPanel(String)
|
114 |
*/
|
115 |
public TableFilterQueryJPanel(String _title) { |
116 |
super(_title);
|
117 |
this.initialize();
|
118 |
} |
119 |
|
120 |
/*
|
121 |
* (non-Javadoc)
|
122 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#initialize()
|
123 |
*/
|
124 |
protected void initialize() { |
125 |
super.initialize();
|
126 |
this.setBorder(BorderFactory.createTitledBorder(Messages.getText("filter_of_Table"))); |
127 |
jtreeRoot = new DefaultMutableTreeNode(fieldsJTree.getModel().getRoot()); |
128 |
} |
129 |
|
130 |
/*
|
131 |
* (non-Javadoc)
|
132 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFieldsJPanel()
|
133 |
*/
|
134 |
protected JPanel getFieldsJPanel() { |
135 |
if (fieldsJPanel == null) { |
136 |
fieldsJPanel = new JPanelML();
|
137 |
fieldsJPanel.setPreferredSize(new java.awt.Dimension(fieldsJPanelWidth, fieldsJPanelHeight));
|
138 |
fieldsJPanel.setLayout(new GridBagLayout()); |
139 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
140 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
141 |
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
142 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
143 |
fieldsJPanel.add(getFieldsJLabel(), gridBagConstraints); |
144 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
145 |
fieldsJPanel.add(getFieldsJScrollPane(), gridBagConstraints); |
146 |
} |
147 |
|
148 |
return fieldsJPanel;
|
149 |
} |
150 |
|
151 |
/**
|
152 |
* @see AbstractFilterQueryJPanel#getValuesJList()
|
153 |
*/
|
154 |
protected javax.swing.JList getValuesJList() {
|
155 |
if (valuesJList == null) { |
156 |
valuesJList = new JListML(new DefaultListModel()); |
157 |
valuesListModel = new DefaultListModel(); |
158 |
valuesJList.setModel(valuesListModel); |
159 |
valuesJList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
160 |
|
161 |
// valuesJList.addMouseListener(new MouseAdapter() {
|
162 |
// /*
|
163 |
// * (non-Javadoc)
|
164 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
165 |
// */
|
166 |
// public void mouseClicked(MouseEvent e) {
|
167 |
// if (e.getClickCount() == 2) {
|
168 |
// int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
|
169 |
//
|
170 |
// if (row > -1) {
|
171 |
// putSymbol(((DefaultListModel)valuesJList.getModel()).get(row).toString());
|
172 |
// }
|
173 |
// }
|
174 |
// }
|
175 |
// });
|
176 |
} |
177 |
|
178 |
return valuesJList;
|
179 |
} |
180 |
|
181 |
/*
|
182 |
* (non-Javadoc)
|
183 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFieldsJScrollPane()
|
184 |
*/
|
185 |
protected javax.swing.JScrollPane getFieldsJScrollPane() {
|
186 |
if (fieldsJScrollPane == null) { |
187 |
fieldsJScrollPane = new JScrollPaneML();
|
188 |
fieldsJScrollPane.setPreferredSize(new java.awt.Dimension(fieldsAndValuesJScrollPaneWidth, fieldsAndValuesJScrollPaneHeight));
|
189 |
fieldsJScrollPane.setViewportView(getFieldsJTree()); |
190 |
} |
191 |
|
192 |
return fieldsJScrollPane;
|
193 |
} |
194 |
|
195 |
/*
|
196 |
* (non-Javadoc)
|
197 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getValuesJPanel()
|
198 |
*/
|
199 |
protected JPanel getValuesJPanel() { |
200 |
if (valuesJPanel == null) { |
201 |
valuesJPanel = new JPanelML();
|
202 |
valuesJPanel.setPreferredSize(new java.awt.Dimension(valuesJPanelWidth, valuesJPanelHeight));
|
203 |
valuesJPanel.setLayout(new GridBagLayout()); |
204 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
205 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
206 |
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
207 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
208 |
valuesJPanel.add(getValuesJLabel(), gridBagConstraints); |
209 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
210 |
valuesJPanel.add(getValuesJScrollPane(), gridBagConstraints); |
211 |
} |
212 |
|
213 |
return valuesJPanel;
|
214 |
} |
215 |
|
216 |
/*
|
217 |
* (non-Javadoc)
|
218 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getValuesJScrollPane()
|
219 |
*/
|
220 |
protected javax.swing.JScrollPane getValuesJScrollPane() {
|
221 |
if (valuesJScrollPane == null) { |
222 |
valuesJScrollPane = new JScrollPaneML();
|
223 |
valuesJScrollPane.setPreferredSize(new Dimension(fieldsAndValuesJScrollPaneWidth, fieldsAndValuesJScrollPaneHeight)); |
224 |
valuesJScrollPane.setViewportView(getValuesJList()); |
225 |
} |
226 |
|
227 |
return valuesJScrollPane;
|
228 |
} |
229 |
|
230 |
/*
|
231 |
* (non-Javadoc)
|
232 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFilterJScrollPane()
|
233 |
*/
|
234 |
protected JScrollPane getFilterJScrollPane() { |
235 |
if (filterJScrollPane == null) { |
236 |
filterJScrollPane = new JScrollPaneML();
|
237 |
filterJScrollPane.setPreferredSize(new java.awt.Dimension(filterJScrollPanelWidth, filterJScrollPaneHeight));
|
238 |
filterJScrollPane.setViewportView(getTxtExpression()); |
239 |
filterJScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
240 |
} |
241 |
|
242 |
return filterJScrollPane;
|
243 |
} |
244 |
|
245 |
/**
|
246 |
* This method initializes buttonsSetJPanel
|
247 |
*
|
248 |
* @return javax.swing.JPanel
|
249 |
*/
|
250 |
protected javax.swing.JPanel getButtonsSetJPanel() {
|
251 |
if (buttonsSetJPanel == null) { |
252 |
buttonsSetJPanel = new JPanelML();
|
253 |
buttonsSetJPanel.setPreferredSize(new java.awt.Dimension(defaultButtonsSetPanelWidth, defaultButtonsSetPanelHeight));
|
254 |
buttonsSetJPanel.add(getBtnNewSet(), null);
|
255 |
buttonsSetJPanel.add(getBtnAddToCurrentSet(), null);
|
256 |
buttonsSetJPanel.add(getBtnFromSet(), null);
|
257 |
} |
258 |
|
259 |
return buttonsSetJPanel;
|
260 |
} |
261 |
|
262 |
/**
|
263 |
* This method initializes btnNewSet
|
264 |
*
|
265 |
* @return javax.swing.JButton
|
266 |
*/
|
267 |
protected javax.swing.JButton getBtnNewSet() {
|
268 |
if (btnNewSet == null) { |
269 |
btnNewSet = new JButtonML();
|
270 |
btnNewSet.setPreferredSize(new Dimension(this.setButtonWidth, this.setButtonHeight)); |
271 |
btnNewSet.setText(Messages.getText("Nuevo_conjunto"));
|
272 |
// btnNewSet.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
273 |
} |
274 |
|
275 |
return btnNewSet;
|
276 |
} |
277 |
|
278 |
/**
|
279 |
* This method initializes btnAddToCurrentSet
|
280 |
*
|
281 |
* @return javax.swing.JButton
|
282 |
*/
|
283 |
protected javax.swing.JButton getBtnAddToCurrentSet() {
|
284 |
if (btnAddToCurrentSet == null) { |
285 |
btnAddToCurrentSet = new JButtonML();
|
286 |
btnAddToCurrentSet.setPreferredSize(new Dimension(this.setButtonWidth, this.setButtonHeight)); |
287 |
btnAddToCurrentSet.setText(Messages.getText("Anadir_al_conjunto"));
|
288 |
// btnAddToCurrentSet.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
289 |
} |
290 |
|
291 |
return btnAddToCurrentSet;
|
292 |
} |
293 |
|
294 |
/**
|
295 |
* This method initializes btnFromSet
|
296 |
*
|
297 |
* @return javax.swing.JButton
|
298 |
*/
|
299 |
protected javax.swing.JButton getBtnFromSet() {
|
300 |
if (btnFromSet == null) { |
301 |
btnFromSet = new JButtonML();
|
302 |
btnFromSet.setPreferredSize(new Dimension(this.setButtonWidth, this.setButtonHeight)); |
303 |
btnFromSet.setText(Messages.getText( |
304 |
"Seleccionar_del_conjunto"));
|
305 |
// btnFromSet.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
306 |
} |
307 |
|
308 |
return btnFromSet;
|
309 |
} |
310 |
|
311 |
/*
|
312 |
* (non-Javadoc)
|
313 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getTxtExpression()
|
314 |
*/
|
315 |
protected javax.swing.JTextArea getTxtExpression() {
|
316 |
if (txtExpression == null) { |
317 |
txtExpression = new JEditableTextAreaML();
|
318 |
txtExpression.setLineWrap(true);
|
319 |
txtExpression.setToolTipText(Messages.getText("write_here_a_filter_expression"));
|
320 |
} |
321 |
|
322 |
return txtExpression;
|
323 |
} |
324 |
|
325 |
/*
|
326 |
* (non-Javadoc)
|
327 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getTopJPanel()
|
328 |
*/
|
329 |
protected JPanel getTopJPanel() { |
330 |
if (topJPanel == null) { |
331 |
topJPanel = new JPanelML();
|
332 |
|
333 |
topJPanel.setPreferredSize(new Dimension(defaultTopJPanelWidth, defaultTopJPanelHeight)); |
334 |
topJPanel.setLayout(new GridBagLayout()); |
335 |
|
336 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
337 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
338 |
|
339 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
340 |
topJPanel.add(getFieldsJPanel(), gridBagConstraints); |
341 |
|
342 |
gridBagConstraints.anchor = GridBagConstraints.CENTER;
|
343 |
topJPanel.add(getFilterButtonsJPanel(), gridBagConstraints); |
344 |
|
345 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
346 |
topJPanel.add(getValuesJPanel(), gridBagConstraints); |
347 |
} |
348 |
|
349 |
return topJPanel;
|
350 |
} |
351 |
|
352 |
/*
|
353 |
* (non-Javadoc)
|
354 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getBottomJPanel()
|
355 |
*/
|
356 |
protected JPanel getBottomJPanel() { |
357 |
if (bottomJPanel == null) { |
358 |
bottomJPanel = new JPanelML();
|
359 |
bottomJPanel.setPreferredSize(new Dimension(defaultBottomJPanelWidth, defaultBottomJPanelHeight)); |
360 |
bottomJPanel.add(getFilterJScrollPane(), null);
|
361 |
bottomJPanel.add(getButtonsSetJPanel(), null);
|
362 |
} |
363 |
|
364 |
return bottomJPanel;
|
365 |
} |
366 |
|
367 |
/*
|
368 |
* (non-Javadoc)
|
369 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#resizeWidth(int)
|
370 |
*/
|
371 |
public void resizeWidth(int new_Width) { |
372 |
int difference = new_Width - DefaultWidth;
|
373 |
|
374 |
if (difference != 0) { |
375 |
this.setPreferredSize(new Dimension(this.getPreferredSize().width + difference, this.getPreferredSize().height)); |
376 |
getTopJPanel().setPreferredSize(new Dimension(getTopJPanel().getPreferredSize().width + difference, getTopJPanel().getPreferredSize().height)); |
377 |
getBottomJPanel().setPreferredSize(new Dimension(getBottomJPanel().getPreferredSize().width + difference, getBottomJPanel().getPreferredSize().height)); |
378 |
int halfDifference = difference / 2; |
379 |
|
380 |
getFilterJScrollPane().setPreferredSize(new Dimension(getFilterJScrollPane().getPreferredSize().width + halfDifference, getFilterJScrollPane().getPreferredSize().height)); |
381 |
|
382 |
getButtonsSetJPanel().setPreferredSize(new Dimension(getButtonsSetJPanel().getPreferredSize().width + halfDifference, getButtonsSetJPanel().getPreferredSize().height)); |
383 |
getBtnNewSet().setPreferredSize(new Dimension(getBtnNewSet().getPreferredSize().width + halfDifference, getBtnNewSet().getPreferredSize().height)); |
384 |
getBtnAddToCurrentSet().setPreferredSize(new Dimension(getBtnAddToCurrentSet().getPreferredSize().width + halfDifference, getBtnAddToCurrentSet().getPreferredSize().height)); |
385 |
getBtnFromSet().setPreferredSize(new Dimension(getBtnFromSet().getPreferredSize().width + halfDifference, getBtnFromSet().getPreferredSize().height)); |
386 |
|
387 |
getFieldsJLabel().setPreferredSize(new Dimension(getFieldsJLabel().getPreferredSize().width + halfDifference, getFieldsJLabel().getPreferredSize().height)); |
388 |
getFieldsJPanel().setPreferredSize(new Dimension(getFieldsJPanel().getPreferredSize().width + halfDifference, getFieldsJPanel().getPreferredSize().height)); |
389 |
getFieldsJScrollPane().setPreferredSize(new Dimension(getFieldsJScrollPane().getPreferredSize().width + halfDifference, getFieldsJScrollPane().getPreferredSize().height)); |
390 |
|
391 |
getValuesJLabel().setPreferredSize(new Dimension(getValuesJLabel().getPreferredSize().width + halfDifference, getValuesJLabel().getPreferredSize().height)); |
392 |
getValuesJPanel().setPreferredSize(new Dimension(getValuesJPanel().getPreferredSize().width + halfDifference, getValuesJPanel().getPreferredSize().height)); |
393 |
getValuesJScrollPane().setPreferredSize(new Dimension(getValuesJScrollPane().getPreferredSize().width + halfDifference, getValuesJScrollPane().getPreferredSize().height)); |
394 |
} |
395 |
} |
396 |
} |