gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.dynform / org.gvsig.tools.dynform.services / src / main / java / org / gvsig / tools / dynform / services / dynformset / subform / SubformJDynFormSet.java @ 1862
History | View | Annotate | Download (23.6 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.tools.dynform.services.dynformset.subform; |
24 |
|
25 |
import java.awt.BorderLayout; |
26 |
import java.awt.Color; |
27 |
import java.awt.Component; |
28 |
import java.awt.event.MouseAdapter; |
29 |
import java.awt.event.MouseEvent; |
30 |
import java.util.ArrayList; |
31 |
import java.util.Iterator; |
32 |
import java.util.List; |
33 |
import javax.swing.Action; |
34 |
import javax.swing.BorderFactory; |
35 |
import javax.swing.BoxLayout; |
36 |
|
37 |
import javax.swing.JComponent; |
38 |
import javax.swing.JLabel; |
39 |
import javax.swing.JOptionPane; |
40 |
import javax.swing.JPanel; |
41 |
import org.gvsig.tools.ToolsLocator; |
42 |
|
43 |
import org.gvsig.tools.dynform.AbortActionException; |
44 |
import org.gvsig.tools.dynform.DynFormDefinition; |
45 |
import org.gvsig.tools.dynform.JDynForm; |
46 |
import org.gvsig.tools.dynform.JDynForm.JDynFormListener; |
47 |
import org.gvsig.tools.dynform.JDynFormField; |
48 |
import org.gvsig.tools.dynform.services.dynformset.subform.FormSetButtonBar.FormSetListener; |
49 |
import org.gvsig.tools.dynform.spi.AbstractJDynFormSet; |
50 |
import org.gvsig.tools.dynform.spi.ActionStore; |
51 |
import org.gvsig.tools.dynobject.DynObject; |
52 |
import org.gvsig.tools.dynobject.DynObjectSet; |
53 |
import org.gvsig.tools.exception.BaseException; |
54 |
import org.gvsig.tools.service.ServiceException; |
55 |
import org.gvsig.tools.service.spi.ServiceManager; |
56 |
import org.gvsig.tools.visitor.VisitCanceledException; |
57 |
import org.gvsig.tools.visitor.Visitor; |
58 |
import org.slf4j.Logger; |
59 |
import org.slf4j.LoggerFactory; |
60 |
|
61 |
public class SubformJDynFormSet extends AbstractJDynFormSet implements FormSetListener, JDynFormListener { |
62 |
|
63 |
private static final Logger logger = LoggerFactory.getLogger(SubformJDynFormSet.class); |
64 |
|
65 |
private JLabel jlabel_messages = null; |
66 |
private JDynForm form = null; |
67 |
private FormSetButtonBar buttonBar = null; |
68 |
private int current = 0; |
69 |
|
70 |
public SubformJDynFormSet(ServiceManager manager, DynFormDefinition definition) throws ServiceException { |
71 |
super(manager, definition);
|
72 |
} |
73 |
|
74 |
@Override
|
75 |
public JComponent asJComponent() { |
76 |
if (this.contents == null) { |
77 |
try {
|
78 |
this.initComponents();
|
79 |
if (this.buttonBar != null) { |
80 |
this.buttonBar.setReadOnly(this.isReadOnly()); |
81 |
} |
82 |
if (this.form != null) { |
83 |
this.form.setReadOnly(this.isReadOnly()); |
84 |
} |
85 |
} catch (ServiceException e) {
|
86 |
throw new RuntimeException(e.getLocalizedMessage(), e); |
87 |
} |
88 |
} |
89 |
this.fireFormMovedToEvent(current);
|
90 |
return this.contents; |
91 |
} |
92 |
|
93 |
public JLabel getMessagesJLabel() { |
94 |
if (this.jlabel_messages == null) { |
95 |
this.jlabel_messages = new JLabel(); |
96 |
// this.jlabel_messages.setBorder( BorderFactory.createLoweredBevelBorder());
|
97 |
this.jlabel_messages.setText(" "); |
98 |
this.jlabel_messages.addMouseListener(new MouseAdapter() { |
99 |
@Override
|
100 |
public void mouseClicked(MouseEvent evt) { |
101 |
int count = evt.getClickCount();
|
102 |
if (count == 2) { |
103 |
JOptionPane.showMessageDialog(contents, jlabel_messages.getText(), "Status", JOptionPane.INFORMATION_MESSAGE); |
104 |
} |
105 |
} |
106 |
}); |
107 |
} |
108 |
return this.jlabel_messages; |
109 |
} |
110 |
|
111 |
@Override
|
112 |
public void message() { |
113 |
this.getMessagesJLabel().setText(" "); |
114 |
} |
115 |
|
116 |
@Override
|
117 |
public void message(String msg) { |
118 |
this.getMessagesJLabel().setText(msg);
|
119 |
} |
120 |
|
121 |
private FormSetButtonBar getButtonBar() throws ServiceException { |
122 |
if (this.buttonBar == null) { |
123 |
initComponents(); |
124 |
} |
125 |
return this.buttonBar; |
126 |
} |
127 |
|
128 |
private void initComponents() throws ServiceException { |
129 |
this.contents = new JPanel(); |
130 |
this.contents.setBorder(BorderFactory.createLineBorder(Color.GRAY)); |
131 |
this.contents.setLayout(new BorderLayout()); |
132 |
|
133 |
this.form = this.manager.getDynFormManager().createJDynForm(definition); |
134 |
this.form.setReadOnly(this.isReadOnly()); |
135 |
this.form.setLayoutMode(this.getLayoutMode()); |
136 |
this.form.setUseScrollBars(this.getUseScrollBars()); |
137 |
this.form.addListener(this); |
138 |
|
139 |
if (!actionsBuffer.isEmpty()) {
|
140 |
for (ActionStore actStore : actionsBuffer) {
|
141 |
if (actStore.isSeparator()) {
|
142 |
form.addSeparatorToPopupMenu( |
143 |
actStore.getDataType()); |
144 |
} else {
|
145 |
form.addActionToPopupMenu( |
146 |
actStore.getDataType(), |
147 |
actStore.getActionName(), |
148 |
actStore.getAction()); |
149 |
} |
150 |
} |
151 |
} |
152 |
if (this.getUseScrollBars()) { |
153 |
if (this.formHeight > -1 && this.formWidth > -1) { |
154 |
this.setFormSize(this.formWidth, this.formHeight); |
155 |
} |
156 |
} |
157 |
this.form.setShowMessageStatus(false); |
158 |
//this.form.setLayoutMode(this.layoutMode);
|
159 |
this.form.addListener(this); |
160 |
|
161 |
this.buttonBar = new FormSetButtonBar(); |
162 |
this.buttonBar.addListener(this); |
163 |
this.buttonBar.setActionActive(FormSetButtonBar.ActionDelete, this.allowDelete()); |
164 |
this.buttonBar.setActionActive(FormSetButtonBar.ActionNew, this.allowNew()); |
165 |
this.buttonBar.setActionActive(FormSetButtonBar.ActionCancelNew, this.allowNew()); |
166 |
this.buttonBar.setActionActive(FormSetButtonBar.ActionSave, this.allowUpdate()); |
167 |
this.buttonBar.setActionActive(FormSetButtonBar.ActionSearch, this.allowSearch()); |
168 |
this.buttonBar.setActionActive(FormSetButtonBar.ActionClose, this.allowClose()); |
169 |
this.buttonBar.setVisible(FormSetButtonBar.ActionCancelNew, false); |
170 |
this.buttonBar.setReadOnly(this.isReadOnly()); |
171 |
this.contents.add(this.form.asJComponent(), BorderLayout.CENTER); |
172 |
|
173 |
JPanel p = new JPanel(); |
174 |
p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); |
175 |
this.buttonBar.asJComponent().setAlignmentX(Component.LEFT_ALIGNMENT); |
176 |
this.getMessagesJLabel().setAlignmentX(Component.LEFT_ALIGNMENT); |
177 |
p.add(this.buttonBar.asJComponent());
|
178 |
p.add(this.getMessagesJLabel());
|
179 |
this.contents.add(p, BorderLayout.SOUTH); |
180 |
|
181 |
doChangeValues(); |
182 |
} |
183 |
|
184 |
@Override
|
185 |
public void setAllowDelete(boolean allowDelete) { |
186 |
super.setAllowDelete(allowDelete);
|
187 |
if( this.buttonBar!=null ) { |
188 |
this.buttonBar.setActionActive(FormSetButtonBar.ActionDelete, this.allowDelete()); |
189 |
} |
190 |
} |
191 |
|
192 |
@Override
|
193 |
public void setAllowNew(boolean allowNew) { |
194 |
super.setAllowNew(allowNew);
|
195 |
if( this.buttonBar!=null ) { |
196 |
this.buttonBar.setActionActive(FormSetButtonBar.ActionNew, this.allowNew()); |
197 |
} |
198 |
} |
199 |
|
200 |
private void doChangeValues() throws ServiceException { |
201 |
this.current = 0; |
202 |
if (this.values == null || this.values.isEmpty()) { |
203 |
this.form.setReadOnly(true); |
204 |
this.getButtonBar().setEnabled(FormSetButtonBar.ActionDelete, false); |
205 |
this.getButtonBar().setEnabled(FormSetButtonBar.ActionSave, false); |
206 |
this.getButtonBar().setEnabled(FormSetButtonBar.ActionNew,
|
207 |
this.allowNew() && !this.isReadOnly()); |
208 |
this.getButtonBar().setNumrecords(0); |
209 |
this.form.clear();
|
210 |
} else {
|
211 |
this.form.setValues((DynObject) this.values.get(this.current)); |
212 |
this.getButtonBar().setEnabled(FormSetButtonBar.ActionDelete,
|
213 |
this.allowDelete() && !this.isReadOnly()); |
214 |
this.getButtonBar().setEnabled(FormSetButtonBar.ActionSave,
|
215 |
this.allowUpdate() && !this.isReadOnly()); |
216 |
this.getButtonBar().setNumrecords(this.values.size()); |
217 |
} |
218 |
this.getButtonBar().setCurrent(this.current); |
219 |
} |
220 |
|
221 |
@Override
|
222 |
public void setValues(List values) throws ServiceException { |
223 |
super.setValues(values);
|
224 |
if (this.contents != null) { |
225 |
doChangeValues(); |
226 |
} |
227 |
} |
228 |
|
229 |
@Override
|
230 |
public void setValues(DynObjectSet values) throws ServiceException { |
231 |
super.setValues(values);
|
232 |
if (this.contents != null) { |
233 |
doChangeValues(); |
234 |
} |
235 |
} |
236 |
|
237 |
@Override
|
238 |
public void setReadOnly(boolean readOnly) { |
239 |
// if( this.isReadOnly() == readOnly ) {
|
240 |
// return;
|
241 |
// }
|
242 |
super.setReadOnly(readOnly);
|
243 |
if (this.buttonBar != null) { |
244 |
this.buttonBar.setReadOnly(readOnly);
|
245 |
} |
246 |
if (this.form != null) { |
247 |
this.form.setReadOnly(readOnly);
|
248 |
} |
249 |
} |
250 |
|
251 |
@Override
|
252 |
public boolean doActionFirst() { |
253 |
if (this.values.isEmpty()) { |
254 |
return false; |
255 |
} |
256 |
|
257 |
if (autosave) {
|
258 |
if (this.form.isModified() || this.isInNewState() ) { |
259 |
if (!doActionSave()) {
|
260 |
return false; |
261 |
} |
262 |
} |
263 |
} |
264 |
this.current = 0; |
265 |
this.form.setValues((DynObject) this.values.get(this.current)); |
266 |
this.buttonBar.setCurrent(this.current); |
267 |
try {
|
268 |
this.getButtonBar().setEnabled(FormSetButtonBar.ActionDelete,
|
269 |
this.allowDelete() && !this.isReadOnly()); |
270 |
this.getButtonBar().setEnabled(FormSetButtonBar.ActionSave,
|
271 |
this.allowUpdate() && !this.isReadOnly()); |
272 |
} catch (Exception ex) { |
273 |
logger.warn("Can't enable/disable delete and save buttons",ex);
|
274 |
} |
275 |
this.fireFormMovedToEvent(this.current); |
276 |
return true; |
277 |
} |
278 |
|
279 |
@Override
|
280 |
public boolean doActionPrevious() { |
281 |
if (this.values.isEmpty()) { |
282 |
return false; |
283 |
} |
284 |
|
285 |
if (autosave) {
|
286 |
if (this.form.isModified() || this.isInNewState() ) { |
287 |
if (!doActionSave()) {
|
288 |
return false; |
289 |
} |
290 |
} |
291 |
} |
292 |
if (this.current > 0) { |
293 |
this.current--;
|
294 |
} |
295 |
this.form.setValues((DynObject) this.values.get(this.current)); |
296 |
this.buttonBar.setCurrent(this.current); |
297 |
this.fireFormMovedToEvent(this.current); |
298 |
return true; |
299 |
} |
300 |
|
301 |
@Override
|
302 |
public boolean doActionNext() { |
303 |
if (this.values.isEmpty()) { |
304 |
return false; |
305 |
} |
306 |
|
307 |
if (autosave) {
|
308 |
if (this.form.isModified() || this.isInNewState() ) { |
309 |
if (!doActionSave()) {
|
310 |
return false; |
311 |
} |
312 |
} |
313 |
} |
314 |
if (this.current < this.values.size() - 1) { |
315 |
this.current++;
|
316 |
} |
317 |
this.form.setValues((DynObject) this.values.get(this.current)); |
318 |
this.buttonBar.setCurrent(this.current); |
319 |
this.fireFormMovedToEvent(this.current); |
320 |
return true; |
321 |
} |
322 |
|
323 |
@Override
|
324 |
public boolean doActionLast() { |
325 |
if (this.values.isEmpty()) { |
326 |
return false; |
327 |
} |
328 |
|
329 |
if (autosave) {
|
330 |
if (this.form.isModified() || this.isInNewState() ) { |
331 |
if (!doActionSave()) {
|
332 |
return false; |
333 |
} |
334 |
} |
335 |
} |
336 |
this.current = this.values.size() - 1; |
337 |
this.form.setValues((DynObject) this.values.get(this.current)); |
338 |
this.buttonBar.setCurrent(this.current); |
339 |
this.fireFormMovedToEvent(this.current); |
340 |
return true; |
341 |
} |
342 |
|
343 |
@Override
|
344 |
public boolean doActionSave() { |
345 |
if ( !this.isInNewState() && this.values.isEmpty()) { |
346 |
return false; |
347 |
} |
348 |
try {
|
349 |
this.listeners.accept(new Visitor() { |
350 |
@Override
|
351 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
352 |
((JDynFormSetListener) listener).formBeforeSave(SubformJDynFormSet.this); |
353 |
} |
354 |
}); |
355 |
} catch (AbortActionException e) {
|
356 |
return false; |
357 |
} catch (BaseException e) {
|
358 |
logger.warn("Can't notify to listeners before save.",e);
|
359 |
return false; |
360 |
} |
361 |
|
362 |
List<String> fieldsName = new ArrayList<>(); |
363 |
if (!this.form.hasValidValues(fieldsName)) { |
364 |
String errores = ""; |
365 |
Iterator<String> it = fieldsName.iterator(); |
366 |
while (it.hasNext()) {
|
367 |
String name = (String) it.next(); |
368 |
errores = errores + " - " + name + "\n"; |
369 |
} |
370 |
int r = confirmDialog(
|
371 |
"There are incorrect data in the following fields:\n" + errores + "\nContinuing the incorrect values โwill not be saved. Do you want to continue?", "warning", |
372 |
JOptionPane.WARNING_MESSAGE,
|
373 |
JOptionPane.YES_NO_OPTION);
|
374 |
if (r != JOptionPane.YES_OPTION) { |
375 |
return false; |
376 |
} |
377 |
} |
378 |
if( !this.isInNewState() ) { |
379 |
if (this.current >= 0 && this.current < this.values.size()) { |
380 |
this.form.getValues((DynObject) this.values.get(this.current)); |
381 |
} else {
|
382 |
logger.warn("current out of range.");
|
383 |
} |
384 |
} |
385 |
try {
|
386 |
this.listeners.accept(new Visitor() { |
387 |
@Override
|
388 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
389 |
((JDynFormSetListener) listener).formAfterSave(SubformJDynFormSet.this); |
390 |
} |
391 |
}); |
392 |
} catch (AbortActionException e) {
|
393 |
return false; |
394 |
} catch (BaseException e) {
|
395 |
logger.warn("Can't notify to listeners after save.",e);
|
396 |
return false; |
397 |
} |
398 |
this.leaveTheNewState();
|
399 |
return true; |
400 |
} |
401 |
|
402 |
@Override
|
403 |
public boolean doActionNew() { |
404 |
try {
|
405 |
this.listeners.accept(new Visitor() { |
406 |
@Override
|
407 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
408 |
((JDynFormSetListener) listener).formBeforeNew(SubformJDynFormSet.this); |
409 |
} |
410 |
}); |
411 |
} catch (BaseException e) {
|
412 |
return true; |
413 |
} |
414 |
this.enterStateNew();
|
415 |
try {
|
416 |
this.listeners.accept(new Visitor() { |
417 |
@Override
|
418 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
419 |
((JDynFormSetListener) listener).formAfterNew(SubformJDynFormSet.this); |
420 |
} |
421 |
}); |
422 |
} catch (BaseException e) {
|
423 |
return true; |
424 |
} |
425 |
return true; |
426 |
} |
427 |
|
428 |
@Override
|
429 |
public boolean doActionCancelNew() { |
430 |
try {
|
431 |
this.listeners.accept(new Visitor() { |
432 |
@Override
|
433 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
434 |
((JDynFormSetListener) listener).formBeforeCancelNew(SubformJDynFormSet.this); |
435 |
} |
436 |
}); |
437 |
} catch (BaseException e) {
|
438 |
return true; |
439 |
} |
440 |
this.leaveTheNewState();
|
441 |
try {
|
442 |
this.listeners.accept(new Visitor() { |
443 |
@Override
|
444 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
445 |
((JDynFormSetListener) listener).formAfterCancelNew(SubformJDynFormSet.this); |
446 |
} |
447 |
}); |
448 |
} catch (BaseException e) {
|
449 |
return true; |
450 |
} |
451 |
return true; |
452 |
} |
453 |
|
454 |
@Override
|
455 |
protected void enterStateNew() { |
456 |
if( this.isInNewState() ) { |
457 |
return;
|
458 |
} |
459 |
try {
|
460 |
FormSetButtonBar bar = this.getButtonBar();
|
461 |
super.enterStateNew();
|
462 |
bar.setCurrentLabel(ToolsLocator.getI18nManager().getTranslation("nuevo"));
|
463 |
bar.setNumrecords(this.countValues());
|
464 |
|
465 |
bar.setVisible(FormSetButtonBar.ActionCancelNew, true);
|
466 |
bar.setVisible(FormSetButtonBar.ActionNew, false);
|
467 |
|
468 |
bar.setEnabled(FormSetButtonBar.ActionSave,true);
|
469 |
bar.setEnabled(FormSetButtonBar.ActionCancelNew,true);
|
470 |
bar.setEnabled(FormSetButtonBar.ActionDelete,false);
|
471 |
bar.setEnabled(FormSetButtonBar.ActionFirst,false);
|
472 |
bar.setEnabled(FormSetButtonBar.ActionNext,false);
|
473 |
bar.setEnabled(FormSetButtonBar.ActionPrevious,false);
|
474 |
bar.setEnabled(FormSetButtonBar.ActionLast,false);
|
475 |
bar.setEnabled(FormSetButtonBar.ActionSearch,false);
|
476 |
} catch (Exception ex) { |
477 |
logger.warn("Can't enable/disable delete and save buttons",ex);
|
478 |
} |
479 |
} |
480 |
|
481 |
@Override
|
482 |
protected void leaveTheNewState() { |
483 |
if( !(this.isInNewState()) ) { |
484 |
return;
|
485 |
} |
486 |
super.leaveTheNewState();
|
487 |
try {
|
488 |
FormSetButtonBar bar = this.getButtonBar();
|
489 |
|
490 |
bar.setVisible(FormSetButtonBar.ActionCancelNew, false);
|
491 |
bar.setVisible(FormSetButtonBar.ActionNew, true);
|
492 |
|
493 |
bar.setEnabled(FormSetButtonBar.ActionSave,true);
|
494 |
bar.setEnabled(FormSetButtonBar.ActionNew,true);
|
495 |
bar.setEnabled(FormSetButtonBar.ActionDelete,true);
|
496 |
bar.setEnabled(FormSetButtonBar.ActionSearch,true);
|
497 |
|
498 |
bar.setCurrentLabel(null);
|
499 |
bar.setNumrecords(this.countValues());
|
500 |
bar.setCurrent(this.current);
|
501 |
} catch (Exception ex) { |
502 |
logger.warn("Can't enable/disable delete and save buttons",ex);
|
503 |
} |
504 |
} |
505 |
|
506 |
@Override
|
507 |
public boolean doActionDelete() { |
508 |
if (this.values.isEmpty()) { |
509 |
return false; |
510 |
} |
511 |
|
512 |
if (this.countValues() < 1) { |
513 |
return true; |
514 |
} |
515 |
try {
|
516 |
this.listeners.accept(new Visitor() { |
517 |
@Override
|
518 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
519 |
((JDynFormSetListener) listener).formBeforeDelete(SubformJDynFormSet.this); |
520 |
} |
521 |
}); |
522 |
} catch (BaseException e) {
|
523 |
return true; |
524 |
} |
525 |
|
526 |
if (this.current >= countValues()) { |
527 |
this.current = countValues() - 1; |
528 |
} |
529 |
if (this.current > -1) { |
530 |
this.form.setValues((DynObject) this.values.get(this.current)); |
531 |
} |
532 |
this.buttonBar.setNumrecords(this.countValues()); |
533 |
this.buttonBar.setCurrent(this.current); |
534 |
|
535 |
try {
|
536 |
this.listeners.accept(new Visitor() { |
537 |
@Override
|
538 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
539 |
((JDynFormSetListener) listener).formAfterDelete(SubformJDynFormSet.this); |
540 |
} |
541 |
}); |
542 |
} catch (BaseException e) {
|
543 |
return true; |
544 |
} |
545 |
return true; |
546 |
} |
547 |
|
548 |
@Override
|
549 |
public boolean doActionSearch() { |
550 |
if (this.values.isEmpty()) { |
551 |
return false; |
552 |
} |
553 |
|
554 |
try {
|
555 |
this.listeners.accept(new Visitor() { |
556 |
@Override
|
557 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
558 |
((JDynFormSetListener) listener).formBeforeSearch(SubformJDynFormSet.this); |
559 |
} |
560 |
}); |
561 |
} catch (BaseException e) {
|
562 |
return true; |
563 |
} |
564 |
// Do search
|
565 |
try {
|
566 |
this.listeners.accept(new Visitor() { |
567 |
@Override
|
568 |
public void visit(Object listener) throws VisitCanceledException, BaseException { |
569 |
((JDynFormSetListener) listener).formAfterSearch(SubformJDynFormSet.this); |
570 |
} |
571 |
}); |
572 |
} catch (BaseException e) {
|
573 |
return true; |
574 |
} |
575 |
return true; |
576 |
} |
577 |
|
578 |
@Override
|
579 |
public boolean doActionClose() { |
580 |
fireCloseEvent(); |
581 |
return true; |
582 |
} |
583 |
|
584 |
@Override
|
585 |
public void doSetCurrentRecord(int index) { |
586 |
this.setCurrentIndex(index);
|
587 |
} |
588 |
|
589 |
@Override
|
590 |
public void setFormSize(int width, int height) { |
591 |
super.setFormSize(width, height);
|
592 |
if (this.form != null) { |
593 |
this.form.setFormSize(width, height);
|
594 |
} |
595 |
} |
596 |
|
597 |
@Override
|
598 |
public int getCurrentIndex() { |
599 |
return this.current; |
600 |
} |
601 |
|
602 |
@Override
|
603 |
public void setCurrentIndex(int index) { |
604 |
if (index < 0 || index > countValues()) { |
605 |
throw new IllegalArgumentException("Index (" + index + ") out of range [0.." + countValues() + "]."); |
606 |
} |
607 |
this.current = index;
|
608 |
this.form.setValues((DynObject) this.values.get(this.current)); |
609 |
this.buttonBar.setCurrent(this.current); |
610 |
this.fireFormMovedToEvent(this.current); |
611 |
} |
612 |
|
613 |
@Override
|
614 |
public void fieldChanged(JDynFormField field) { |
615 |
logger.debug("Ha cambiado el field: " + field.getName() + " con el valor => " + field.getValue()); |
616 |
} |
617 |
|
618 |
@Override
|
619 |
public DynObject get(int position) { |
620 |
logger.debug("Recojo el field: " + position);
|
621 |
return (DynObject) this.values.get(position); |
622 |
} |
623 |
|
624 |
@Override
|
625 |
public List getValues() { |
626 |
if (this.current >= 0 && this.current < this.values.size()) { |
627 |
this.form.getValues((DynObject) this.values.get(this.current)); |
628 |
} |
629 |
return this.values; |
630 |
} |
631 |
|
632 |
@Override
|
633 |
public boolean hasValidValues() { |
634 |
return this.form.hasValidValues(); |
635 |
} |
636 |
|
637 |
@Override
|
638 |
public boolean hasValidValues(List<String> fieldsName) { |
639 |
return this.form.hasValidValues(fieldsName); |
640 |
} |
641 |
|
642 |
public void clear() { |
643 |
if (this.form != null) { |
644 |
this.form.clear();
|
645 |
} |
646 |
} |
647 |
|
648 |
@Override
|
649 |
public void getFormValues(DynObject values) { |
650 |
this.form.getValues(values);
|
651 |
} |
652 |
|
653 |
@Override
|
654 |
public void addAction(Action action) { |
655 |
try {
|
656 |
this.getButtonBar().addAction(action);
|
657 |
} catch (ServiceException ex) {
|
658 |
throw new RuntimeException("Can't add action to JDymFormSet", ex); |
659 |
} |
660 |
} |
661 |
|
662 |
@Override
|
663 |
public void setActionVisible(String action, boolean visible) { |
664 |
try {
|
665 |
this.getButtonBar().setVisible(action, visible);
|
666 |
} catch (Exception ex) { |
667 |
throw new RuntimeException("Can't action visible in JDymFormSet", ex); |
668 |
} |
669 |
} |
670 |
|
671 |
@Override
|
672 |
public void setActionEnabled(String action, boolean enabled) { |
673 |
try {
|
674 |
this.getButtonBar().setEnabled(action, enabled);
|
675 |
} catch (Exception ex) { |
676 |
throw new RuntimeException("Can't action enable in JDymFormSet", ex); |
677 |
} |
678 |
} |
679 |
|
680 |
@Override
|
681 |
public boolean isActionEnabled(String action) { |
682 |
try {
|
683 |
return this.getButtonBar().isEnabled(action); |
684 |
} catch (Exception ex) { |
685 |
throw new RuntimeException("Can't get action enable in JDymFormSet", ex); |
686 |
} |
687 |
} |
688 |
|
689 |
@Override
|
690 |
public boolean isActionVisible(String action) { |
691 |
try {
|
692 |
return this.getButtonBar().isVisible(action); |
693 |
} catch (Exception ex) { |
694 |
throw new RuntimeException("Can't get action visible in JDymFormSet", ex); |
695 |
} |
696 |
} |
697 |
|
698 |
|
699 |
} |