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