svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / featureform / swing / impl / dynformset / FeatureTableJDynFormSet.java @ 44202
History | View | Annotate | Download (9.61 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 modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.featureform.swing.impl.dynformset; |
24 |
|
25 |
import java.awt.Dimension; |
26 |
import java.awt.GridBagConstraints; |
27 |
import java.awt.GridBagLayout; |
28 |
import java.awt.event.ActionEvent; |
29 |
import java.util.List; |
30 |
import javax.swing.Action; |
31 |
import javax.swing.Box.Filler; |
32 |
import javax.swing.JButton; |
33 |
|
34 |
import javax.swing.JComponent; |
35 |
import javax.swing.JPanel; |
36 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
37 |
import org.gvsig.fmap.dal.swing.FeatureTableModel; |
38 |
import org.gvsig.fmap.dal.swing.JFeatureTable; |
39 |
import org.gvsig.tools.dynform.DynFormDefinition; |
40 |
import org.gvsig.tools.dynform.spi.AbstractJDynFormSet; |
41 |
import org.gvsig.tools.dynobject.DynObjectSet; |
42 |
import org.gvsig.tools.service.ServiceException; |
43 |
import org.gvsig.tools.service.spi.ServiceManager; |
44 |
import org.slf4j.Logger; |
45 |
import org.slf4j.LoggerFactory; |
46 |
|
47 |
public class FeatureTableJDynFormSet extends AbstractJDynFormSet { |
48 |
|
49 |
private static final Logger logger = LoggerFactory.getLogger(FeatureTableJDynFormSet.class); |
50 |
|
51 |
private int current = 0; |
52 |
|
53 |
private JButton btnModify; |
54 |
private JButton btnNew; |
55 |
private JButton btnRemove; |
56 |
private JButton btnSelect; |
57 |
private JButton btnShow; |
58 |
private Filler filler1;
|
59 |
private Filler filler2;
|
60 |
private JFeatureTable table = null; |
61 |
private FeatureTableModel tableModel = null; |
62 |
|
63 |
public FeatureTableJDynFormSet(ServiceManager manager, DynFormDefinition definition) throws ServiceException { |
64 |
super(manager, definition);
|
65 |
} |
66 |
|
67 |
@Override
|
68 |
public JComponent asJComponent() { |
69 |
if (this.contents == null) { |
70 |
try {
|
71 |
this.initComponents();
|
72 |
} catch (ServiceException e) {
|
73 |
throw new RuntimeException(e.getLocalizedMessage(), e); |
74 |
} |
75 |
} |
76 |
this.fireFormMovedToEvent(current);
|
77 |
return this.contents; |
78 |
} |
79 |
|
80 |
private void initComponents() throws ServiceException { |
81 |
JPanel panel = new JPanel(); |
82 |
GridBagConstraints gridBagConstraints;
|
83 |
|
84 |
filler1 = new Filler(new Dimension(5, 5), new Dimension(5, 5), new Dimension(5, 5)); |
85 |
this.tableModel = DALSwingLocator.getSwingManager().createEmptyFeatureTableModel(this.definition.getElementsType()); |
86 |
this.table = DALSwingLocator.getSwingManager().createJFeatureTable(tableModel);
|
87 |
btnNew = new JButton(); |
88 |
btnShow = new JButton(); |
89 |
btnModify = new JButton(); |
90 |
btnRemove = new JButton(); |
91 |
btnSelect = new JButton(); |
92 |
filler2 = new Filler(new Dimension(5, 5), new Dimension(5, 5), new Dimension(5, 5)); |
93 |
|
94 |
|
95 |
GridBagLayout layout = new GridBagLayout(); |
96 |
layout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0}; |
97 |
layout.rowHeights = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0}; |
98 |
panel.setLayout(layout); |
99 |
|
100 |
gridBagConstraints = new GridBagConstraints(); |
101 |
gridBagConstraints.gridx = 2;
|
102 |
gridBagConstraints.gridy = 2;
|
103 |
gridBagConstraints.gridheight = 11;
|
104 |
gridBagConstraints.fill = GridBagConstraints.BOTH;
|
105 |
gridBagConstraints.weightx = 1.0;
|
106 |
gridBagConstraints.weighty = 1.0;
|
107 |
panel.add(table.asJComponent(), gridBagConstraints); |
108 |
|
109 |
btnNew.setText("_nuevo");
|
110 |
btnNew.addActionListener(new java.awt.event.ActionListener() {
|
111 |
@Override
|
112 |
public void actionPerformed(ActionEvent evt) { |
113 |
btnNewActionPerformed(evt); |
114 |
} |
115 |
}); |
116 |
gridBagConstraints = new GridBagConstraints(); |
117 |
gridBagConstraints.gridx = 4;
|
118 |
gridBagConstraints.gridy = 2;
|
119 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
120 |
panel.add(btnNew, gridBagConstraints); |
121 |
|
122 |
btnShow.setText("_mostrar");
|
123 |
btnShow.addActionListener(new java.awt.event.ActionListener() {
|
124 |
@Override
|
125 |
public void actionPerformed(ActionEvent evt) { |
126 |
btnShowActionPerformed(evt); |
127 |
} |
128 |
}); |
129 |
gridBagConstraints = new GridBagConstraints(); |
130 |
gridBagConstraints.gridx = 4;
|
131 |
gridBagConstraints.gridy = 4;
|
132 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
133 |
panel.add(btnShow, gridBagConstraints); |
134 |
|
135 |
btnModify.setText("_modificar");
|
136 |
btnModify.addActionListener(new java.awt.event.ActionListener() {
|
137 |
@Override
|
138 |
public void actionPerformed(ActionEvent evt) { |
139 |
btnModifyActionPerformed(evt); |
140 |
} |
141 |
}); |
142 |
gridBagConstraints = new GridBagConstraints(); |
143 |
gridBagConstraints.gridx = 4;
|
144 |
gridBagConstraints.gridy = 6;
|
145 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
146 |
panel.add(btnModify, gridBagConstraints); |
147 |
|
148 |
btnRemove.setText("_eliminar");
|
149 |
btnRemove.addActionListener(new java.awt.event.ActionListener() {
|
150 |
@Override
|
151 |
public void actionPerformed(ActionEvent evt) { |
152 |
btnRemoveActionPerformed(evt); |
153 |
} |
154 |
}); |
155 |
gridBagConstraints = new GridBagConstraints(); |
156 |
gridBagConstraints.gridx = 4;
|
157 |
gridBagConstraints.gridy = 8;
|
158 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
159 |
panel.add(btnRemove, gridBagConstraints); |
160 |
gridBagConstraints = new GridBagConstraints(); |
161 |
gridBagConstraints.gridx = 6;
|
162 |
gridBagConstraints.gridy = 14;
|
163 |
panel.add(filler1, gridBagConstraints); |
164 |
|
165 |
btnSelect.setText("_seleccionar");
|
166 |
btnSelect.addActionListener(new java.awt.event.ActionListener() {
|
167 |
@Override
|
168 |
public void actionPerformed(ActionEvent evt) { |
169 |
btnSelectActionPerformed(evt); |
170 |
} |
171 |
}); |
172 |
gridBagConstraints = new GridBagConstraints(); |
173 |
gridBagConstraints.gridx = 4;
|
174 |
gridBagConstraints.gridy = 10;
|
175 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
176 |
panel.add(btnSelect, gridBagConstraints); |
177 |
gridBagConstraints = new GridBagConstraints(); |
178 |
gridBagConstraints.gridx = 0;
|
179 |
gridBagConstraints.gridy = 0;
|
180 |
panel.add(filler2, gridBagConstraints); |
181 |
} |
182 |
|
183 |
private void btnShowActionPerformed(ActionEvent evt) { |
184 |
|
185 |
} |
186 |
|
187 |
private void btnNewActionPerformed(ActionEvent evt) { |
188 |
|
189 |
} |
190 |
|
191 |
private void btnModifyActionPerformed(ActionEvent evt) { |
192 |
|
193 |
} |
194 |
|
195 |
private void btnRemoveActionPerformed(ActionEvent evt) { |
196 |
|
197 |
} |
198 |
|
199 |
private void btnSelectActionPerformed(ActionEvent evt) { |
200 |
|
201 |
} |
202 |
|
203 |
@Override
|
204 |
public void setValues(List values) throws ServiceException { |
205 |
super.setValues(values);
|
206 |
if (this.contents != null) { |
207 |
doChangeValues(); |
208 |
} |
209 |
} |
210 |
|
211 |
@Override
|
212 |
public void setValues(DynObjectSet values) throws ServiceException { |
213 |
super.setValues(values);
|
214 |
if (this.contents != null) { |
215 |
doChangeValues(); |
216 |
} |
217 |
} |
218 |
|
219 |
@Override
|
220 |
public void setReadOnly(boolean readOnly) { |
221 |
super.setReadOnly(readOnly);
|
222 |
} |
223 |
|
224 |
|
225 |
@Override
|
226 |
public void setFormSize(int width, int height) { |
227 |
super.setFormSize(width, height);
|
228 |
} |
229 |
|
230 |
@Override
|
231 |
public int getCurrentIndex() { |
232 |
return this.current; |
233 |
} |
234 |
|
235 |
@Override
|
236 |
public void setCurrentIndex(int index) { |
237 |
if (index < 0 || index > countValues()) { |
238 |
throw new IllegalArgumentException("Index (" + index + ") out of range [0.." + countValues() + "]."); |
239 |
} |
240 |
this.table.setCurrent(this.current); |
241 |
} |
242 |
|
243 |
|
244 |
@Override
|
245 |
public void addAction(Action action) { |
246 |
|
247 |
} |
248 |
|
249 |
@Override
|
250 |
public void setActionEnabled(String action, boolean enabled) { |
251 |
logger.info("setActionEnabled not implemented over SimpleTableJDynFormSet.");
|
252 |
} |
253 |
|
254 |
@Override
|
255 |
public void setActionVisible(String action, boolean visible) { |
256 |
logger.info("setActionVisible not implemented over SimpleTableJDynFormSet.");
|
257 |
} |
258 |
|
259 |
@Override
|
260 |
public boolean isActionEnabled(String action) { |
261 |
logger.info("isActionEnabled not implemented over SimpleTableJDynFormSet.");
|
262 |
return true; |
263 |
} |
264 |
|
265 |
@Override
|
266 |
public boolean isActionVisible(String action) { |
267 |
logger.info("isActionVisible not implemented over SimpleTableJDynFormSet.");
|
268 |
return true; |
269 |
} |
270 |
|
271 |
|
272 |
private void doChangeValues() { |
273 |
|
274 |
} |
275 |
|
276 |
@Override
|
277 |
public boolean hasValidValues() { |
278 |
return true; |
279 |
} |
280 |
|
281 |
@Override
|
282 |
public boolean hasValidValues(List<String> fieldsName) { |
283 |
return true; |
284 |
} |
285 |
|
286 |
@Override
|
287 |
public List getValues() { |
288 |
return this.values; |
289 |
} |
290 |
|
291 |
|
292 |
} |