root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / filterPanel / filterQueryPanel / FilterQueryJPanel.java @ 13136
History | View | Annotate | Download (13.2 KB)
1 |
package org.gvsig.gui.beans.filterPanel.filterQueryPanel; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.GridBagConstraints; |
5 |
import java.awt.GridBagLayout; |
6 |
import java.awt.event.MouseEvent; |
7 |
import java.awt.event.MouseMotionListener; |
8 |
import java.awt.event.MouseWheelEvent; |
9 |
import java.awt.event.MouseWheelListener; |
10 |
import java.io.Serializable; |
11 |
|
12 |
import javax.swing.BorderFactory; |
13 |
import javax.swing.DefaultListCellRenderer; |
14 |
import javax.swing.DefaultListModel; |
15 |
import javax.swing.JCheckBox; |
16 |
import javax.swing.JLabel; |
17 |
import javax.swing.JList; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JScrollPane; |
20 |
|
21 |
import org.gvsig.gui.beans.Messages; |
22 |
import org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel; |
23 |
import org.gvsig.gui.beans.filterPanel.filterQueryPanel.jLabelAsCell.DefaultListModelForJLabelAsCell; |
24 |
import org.gvsig.gui.javax.swing.jLabelCellRenderer.JLabelCellRenderer; |
25 |
import org.gvsig.gui.javax.swing.jLabelCellRenderer.JLabelCellRendererWithTextAsToolTipText; |
26 |
|
27 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
28 |
*
|
29 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
30 |
*
|
31 |
* This program is free software; you can redistribute it and/or
|
32 |
* modify it under the terms of the GNU General Public License
|
33 |
* as published by the Free Software Foundation; either version 2
|
34 |
* of the License, or (at your option) any later version.
|
35 |
*
|
36 |
* This program is distributed in the hope that it will be useful,
|
37 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
38 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
39 |
* GNU General Public License for more details.
|
40 |
*
|
41 |
* You should have received a copy of the GNU General Public License
|
42 |
* along with this program; if not, write to the Free Software
|
43 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
44 |
*
|
45 |
* For more information, contact:
|
46 |
*
|
47 |
* Generalitat Valenciana
|
48 |
* Conselleria d'Infraestructures i Transport
|
49 |
* Av. Blasco Ib??ez, 50
|
50 |
* 46010 VALENCIA
|
51 |
* SPAIN
|
52 |
*
|
53 |
* +34 963862235
|
54 |
* gvsig@gva.es
|
55 |
* www.gvsig.gva.es
|
56 |
*
|
57 |
* or
|
58 |
*
|
59 |
* IVER T.I. S.A
|
60 |
* Salamanca 50
|
61 |
* 46005 Valencia
|
62 |
* Spain
|
63 |
*
|
64 |
* +34 963163400
|
65 |
* dac@iver.es
|
66 |
*/
|
67 |
|
68 |
/**
|
69 |
* This class is a version of the graphical interface of "FilterDialog" which was made by Fernando and is in 'appgvSIG' project.
|
70 |
* It's supposed that other classes will extend from this and will add the logic as is in the "FilterDialog" class.
|
71 |
*
|
72 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
73 |
*/
|
74 |
public class FilterQueryJPanel extends AbstractFilterQueryJPanel implements Serializable{ |
75 |
protected JPanel topCenterJPanel = null; |
76 |
protected JCheckBox validateFilterExpressionJCheckBox = null; |
77 |
|
78 |
protected int filterJScrollPaneHeight = defaultBottomJPanelHeight - 10; |
79 |
protected int filterJScrollPanelWidth = defaultBottomJPanelWidth; |
80 |
protected int validateFilterExpressionJCheckBoxHeight = 20; |
81 |
|
82 |
/**
|
83 |
* @see AbstractFilterQueryJPanel#AbstractFilterQueryJPanel()
|
84 |
*/
|
85 |
public FilterQueryJPanel() {
|
86 |
super();
|
87 |
this.initialize();
|
88 |
} |
89 |
|
90 |
/**
|
91 |
* @see AbstractFilterQueryJPanel#AbstractFilterQueryJPanel(String)
|
92 |
*/
|
93 |
public FilterQueryJPanel(String _title) { |
94 |
super(_title);
|
95 |
this.initialize();
|
96 |
} |
97 |
|
98 |
/*
|
99 |
* (non-Javadoc)
|
100 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#initialize()
|
101 |
*/
|
102 |
protected void initialize() { |
103 |
super.initialize();
|
104 |
this.setBorder(BorderFactory.createTitledBorder(Messages.getText("filterOnAWFSLayer"))); |
105 |
getValuesJList().setCellRenderer(new JLabelCellRendererWithTextAsToolTipText());
|
106 |
|
107 |
// /**
|
108 |
// * This listener allows show in the tool tip text the value of the item when
|
109 |
// * the wheel of the mouse is beeing moved
|
110 |
// */
|
111 |
// getValuesJScrollPane().addMouseWheelListener(new MouseWheelListener() {
|
112 |
// public void mouseWheelMoved(MouseWheelEvent e) {
|
113 |
// if (e.getSource() != null) {
|
114 |
// Object obj = ((JScrollPane)e.getSource()).getViewport().getComponent(0);
|
115 |
//
|
116 |
// if (obj instanceof JList) {
|
117 |
// int index = ((JList)obj).locationToIndex(e.getPoint());
|
118 |
//
|
119 |
// if (index >= 0)
|
120 |
// ((JList)obj).setToolTipText( ((JLabel) ((JList)obj).getModel().getElementAt(index)).getText() );
|
121 |
// }
|
122 |
// }
|
123 |
// }
|
124 |
//
|
125 |
// });
|
126 |
} |
127 |
|
128 |
/*
|
129 |
* (FilterQueryJPanel)
|
130 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFieldsJPanel()
|
131 |
*/
|
132 |
protected JPanel getFieldsJPanel() { |
133 |
if (fieldsJPanel == null) { |
134 |
fieldsJPanel = new javax.swing.JPanel();
|
135 |
fieldsJPanel.setPreferredSize(new java.awt.Dimension(fieldsJPanelWidth, fieldsJPanelHeight));
|
136 |
fieldsJPanel.setLayout(new GridBagLayout()); |
137 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
138 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
139 |
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
140 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
141 |
fieldsJPanel.add(getFieldsJLabel(), gridBagConstraints); |
142 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
143 |
fieldsJPanel.add(getFieldsJScrollPane(), gridBagConstraints); |
144 |
} |
145 |
|
146 |
return fieldsJPanel;
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* @see AbstractFilterQueryJPanel#getValuesJList()
|
151 |
*/
|
152 |
protected javax.swing.JList getValuesJList() {
|
153 |
if (valuesJList == null) { |
154 |
valuesJList = new javax.swing.JList(new DefaultListModel()); |
155 |
valuesListModel = new DefaultListModelForJLabelAsCell();
|
156 |
valuesJList.setModel(valuesListModel); |
157 |
valuesJList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
158 |
|
159 |
// valuesJList.addMouseListener(new MouseAdapter() {
|
160 |
// /*
|
161 |
// * (non-Javadoc)
|
162 |
// * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
163 |
// */
|
164 |
// public void mouseClicked(MouseEvent e) {
|
165 |
// if (e.getClickCount() == 2) {
|
166 |
// int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
|
167 |
//
|
168 |
// if (row > -1) {
|
169 |
// putSymbol(((DefaultListModel)valuesJList.getModel()).get(row).toString());
|
170 |
// }
|
171 |
// }
|
172 |
// }
|
173 |
// });
|
174 |
} |
175 |
|
176 |
return valuesJList;
|
177 |
} |
178 |
|
179 |
/*
|
180 |
* (non-Javadoc)
|
181 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFieldsJScrollPane()
|
182 |
*/
|
183 |
protected javax.swing.JScrollPane getFieldsJScrollPane() {
|
184 |
if (fieldsJScrollPane == null) { |
185 |
fieldsJScrollPane = new javax.swing.JScrollPane();
|
186 |
fieldsJScrollPane.setPreferredSize(new java.awt.Dimension(fieldsAndValuesJScrollPaneWidth, fieldsAndValuesJScrollPaneHeight));
|
187 |
fieldsJScrollPane.setViewportView(getFieldsJTree()); |
188 |
} |
189 |
|
190 |
return fieldsJScrollPane;
|
191 |
} |
192 |
|
193 |
/*
|
194 |
* (non-Javadoc)
|
195 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getValuesJPanel()
|
196 |
*/
|
197 |
protected JPanel getValuesJPanel() { |
198 |
if (valuesJPanel == null) { |
199 |
valuesJPanel = new javax.swing.JPanel();
|
200 |
valuesJPanel.setPreferredSize(new java.awt.Dimension(valuesJPanelWidth, valuesJPanelHeight));
|
201 |
valuesJPanel.setLayout(new GridBagLayout()); |
202 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
203 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
204 |
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
205 |
gridBagConstraints.anchor = GridBagConstraints.NORTH;
|
206 |
valuesJPanel.add(getValuesJLabel(), gridBagConstraints); |
207 |
gridBagConstraints.anchor = GridBagConstraints.SOUTH;
|
208 |
valuesJPanel.add(getValuesJScrollPane(), gridBagConstraints); |
209 |
} |
210 |
|
211 |
return valuesJPanel;
|
212 |
} |
213 |
|
214 |
/*
|
215 |
* (non-Javadoc)
|
216 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getValuesJScrollPane()
|
217 |
*/
|
218 |
protected javax.swing.JScrollPane getValuesJScrollPane() {
|
219 |
if (valuesJScrollPane == null) { |
220 |
valuesJScrollPane = new javax.swing.JScrollPane();
|
221 |
valuesJScrollPane.setPreferredSize(new Dimension(fieldsAndValuesJScrollPaneWidth, fieldsAndValuesJScrollPaneHeight)); |
222 |
valuesJScrollPane.setViewportView(getValuesJList()); |
223 |
} |
224 |
|
225 |
return valuesJScrollPane;
|
226 |
} |
227 |
|
228 |
/*
|
229 |
* (non-Javadoc)
|
230 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getFilterJScrollPane()
|
231 |
*/
|
232 |
protected JScrollPane getFilterJScrollPane() { |
233 |
if (filterJScrollPane == null) { |
234 |
filterJScrollPane = new javax.swing.JScrollPane();
|
235 |
filterJScrollPane.setPreferredSize(new java.awt.Dimension(filterJScrollPanelWidth, filterJScrollPaneHeight));
|
236 |
filterJScrollPane.setViewportView(getTxtExpression()); |
237 |
filterJScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
238 |
} |
239 |
|
240 |
return filterJScrollPane;
|
241 |
} |
242 |
|
243 |
/*
|
244 |
* (non-Javadoc)
|
245 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getTxtExpression()
|
246 |
*/
|
247 |
protected javax.swing.JTextArea getTxtExpression() {
|
248 |
if (txtExpression == null) { |
249 |
txtExpression = new javax.swing.JTextArea();
|
250 |
txtExpression.setLineWrap(true);
|
251 |
txtExpression.setToolTipText(Messages.getText("write_here_a_filter_expression"));
|
252 |
} |
253 |
|
254 |
return txtExpression;
|
255 |
} |
256 |
|
257 |
/*
|
258 |
* (non-Javadoc)
|
259 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getTopJPanel()
|
260 |
*/
|
261 |
protected JPanel getTopJPanel() { |
262 |
if (topJPanel == null) { |
263 |
topJPanel = new JPanel(); |
264 |
|
265 |
topJPanel.setPreferredSize(new Dimension(defaultTopJPanelWidth, defaultTopJPanelHeight)); |
266 |
topJPanel.setLayout(new GridBagLayout()); |
267 |
|
268 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
269 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
270 |
|
271 |
gridBagConstraints.anchor = GridBagConstraints.WEST;
|
272 |
topJPanel.add(getFieldsJPanel(), gridBagConstraints); |
273 |
|
274 |
gridBagConstraints.anchor = GridBagConstraints.CENTER;
|
275 |
// topJPanel.add(getFilterButtonsJPanel(), gridBagConstraints);
|
276 |
topJPanel.add(getTopCenterJPanel(), gridBagConstraints); |
277 |
// topJPanel.add(getValidateFilterExpressionJCheckBox(), gridBagConstraints);
|
278 |
|
279 |
gridBagConstraints.anchor = GridBagConstraints.EAST;
|
280 |
topJPanel.add(getValuesJPanel(), gridBagConstraints); |
281 |
} |
282 |
|
283 |
return topJPanel;
|
284 |
} |
285 |
|
286 |
/**
|
287 |
* This method initializes topCenterJPanel
|
288 |
*
|
289 |
* @return javax.swing.JPanel
|
290 |
*/
|
291 |
protected JPanel getTopCenterJPanel() { |
292 |
if (topCenterJPanel == null) { |
293 |
topCenterJPanel = new JPanel(); |
294 |
topCenterJPanel.setPreferredSize(new Dimension(getFilterButtonsJPanel().getPreferredSize().width, getFilterButtonsJPanel().getPreferredSize().height + validateFilterExpressionJCheckBoxHeight)); |
295 |
topCenterJPanel.setLayout(null);
|
296 |
|
297 |
getFilterButtonsJPanel().setBounds(0, 0, getFilterButtonsJPanel().getPreferredSize().width, getFilterButtonsJPanel().getPreferredSize().height); |
298 |
topCenterJPanel.add(getFilterButtonsJPanel()); |
299 |
topCenterJPanel.add(getValidateFilterExpressionJCheckBox()); |
300 |
} |
301 |
return topCenterJPanel;
|
302 |
} |
303 |
|
304 |
/**
|
305 |
* This method initializes validateFilterExpressionJCheckBox
|
306 |
*
|
307 |
* @return javax.swing.JCheckBox
|
308 |
*/
|
309 |
protected JCheckBox getValidateFilterExpressionJCheckBox() { |
310 |
if (validateFilterExpressionJCheckBox == null) { |
311 |
validateFilterExpressionJCheckBox = new JCheckBox(); |
312 |
validateFilterExpressionJCheckBox.setBounds(5, getFilterButtonsJPanel().getPreferredSize().height, getFilterButtonsJPanel().getWidth(), validateFilterExpressionJCheckBoxHeight);
|
313 |
validateFilterExpressionJCheckBox.setText(Messages.getText("validate_expression"));
|
314 |
validateFilterExpressionJCheckBox.setToolTipText(Messages.getText("validate_filter_expression_explanation"));
|
315 |
} |
316 |
return validateFilterExpressionJCheckBox;
|
317 |
} |
318 |
|
319 |
/*
|
320 |
* (non-Javadoc)
|
321 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#getBottomJPanel()
|
322 |
*/
|
323 |
protected JPanel getBottomJPanel() { |
324 |
if (bottomJPanel == null) { |
325 |
bottomJPanel = new JPanel(); |
326 |
bottomJPanel.setPreferredSize(new Dimension(defaultBottomJPanelWidth, defaultBottomJPanelHeight)); |
327 |
bottomJPanel.add(getFilterJScrollPane(), null);
|
328 |
} |
329 |
|
330 |
return bottomJPanel;
|
331 |
} |
332 |
|
333 |
/*
|
334 |
* (non-Javadoc)
|
335 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#resizeWidth(int)
|
336 |
*/
|
337 |
public void resizeWidth(int new_Width) { |
338 |
int difference = new_Width - DefaultWidth;
|
339 |
|
340 |
if (difference != 0) { |
341 |
this.setPreferredSize(new Dimension(this.getPreferredSize().width + difference, this.getPreferredSize().height)); |
342 |
getTopJPanel().setPreferredSize(new Dimension(getTopJPanel().getPreferredSize().width + difference, getTopJPanel().getPreferredSize().height)); |
343 |
getBottomJPanel().setPreferredSize(new Dimension(getBottomJPanel().getPreferredSize().width + difference, getBottomJPanel().getPreferredSize().height)); |
344 |
getFilterJScrollPane().setPreferredSize(new Dimension(getFilterJScrollPane().getPreferredSize().width + difference, getFilterJScrollPane().getPreferredSize().height)); |
345 |
|
346 |
int halfDifference = difference / 2; |
347 |
|
348 |
getFieldsJLabel().setPreferredSize(new Dimension(getFieldsJLabel().getPreferredSize().width + halfDifference, getFieldsJLabel().getPreferredSize().height)); |
349 |
getFieldsJPanel().setPreferredSize(new Dimension(getFieldsJPanel().getPreferredSize().width + halfDifference, getFieldsJPanel().getPreferredSize().height)); |
350 |
getFieldsJScrollPane().setPreferredSize(new Dimension(getFieldsJScrollPane().getPreferredSize().width + halfDifference, getFieldsJScrollPane().getPreferredSize().height)); |
351 |
|
352 |
getValuesJLabel().setPreferredSize(new Dimension(getValuesJLabel().getPreferredSize().width + halfDifference, getValuesJLabel().getPreferredSize().height)); |
353 |
getValuesJPanel().setPreferredSize(new Dimension(getValuesJPanel().getPreferredSize().width + halfDifference, getValuesJPanel().getPreferredSize().height)); |
354 |
getValuesJScrollPane().setPreferredSize(new Dimension(getValuesJScrollPane().getPreferredSize().width + halfDifference, getValuesJScrollPane().getPreferredSize().height)); |
355 |
} |
356 |
} |
357 |
} |
358 |
|