Revision 45915
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/DefaultJFeaturesForm.java | ||
---|---|---|
154 | 154 |
private JPanel panel; |
155 | 155 |
private JDynFormSet formset; |
156 | 156 |
private FeatureStore store; |
157 |
private boolean needrefresh; |
|
157 | 158 |
private FeaturePagingHelper features; |
158 | 159 |
private DynFormDefinition definition = null; |
159 | 160 |
private FeatureQuery currentQuery; |
... | ... | |
202 | 203 |
} catch (Exception ex) { |
203 | 204 |
throw new RuntimeException("Can't update form", ex); |
204 | 205 |
} |
206 |
this.needrefresh = false; |
|
205 | 207 |
updateButtonEnabledStatus(); |
206 | 208 |
} |
207 | 209 |
|
... | ... | |
259 | 261 |
|
260 | 262 |
@Override |
261 | 263 |
public void dispose() { |
264 |
if( this.formset!=null ) { |
|
265 |
Action action = this.formset.getAction(FINISHEDITING_ACTION); |
|
266 |
if( action!=null ) { |
|
267 |
DisposeUtils.disposeQuietly(action); |
|
268 |
} |
|
269 |
action = this.formset.getAction(STARTEDITING_ACTION); |
|
270 |
if( action!=null ) { |
|
271 |
DisposeUtils.disposeQuietly(action); |
|
272 |
} |
|
273 |
} |
|
262 | 274 |
DisposeUtils.disposeQuietly(store); |
263 | 275 |
this.store = null; |
264 | 276 |
this.panel = null; |
... | ... | |
394 | 406 |
} |
395 | 407 |
} |
396 | 408 |
|
397 |
private class FinishEditingAction extends AbstractAction implements Observer { |
|
409 |
private class FinishEditingAction extends AbstractAction implements Observer, Disposable {
|
|
398 | 410 |
|
399 | 411 |
@SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) |
400 | 412 |
public FinishEditingAction() { |
... | ... | |
412 | 424 |
|
413 | 425 |
@Override |
414 | 426 |
public void actionPerformed(ActionEvent ae) { |
427 |
if (store == null || formset == null) { |
|
428 |
return; |
|
429 |
} |
|
415 | 430 |
if (store.isEditing()) { |
416 | 431 |
ThreadSafeDialogsManager dialogManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
417 | 432 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
... | ... | |
460 | 475 |
if (notification instanceof FeatureStoreNotification) { |
461 | 476 |
FeatureStoreNotification n = (FeatureStoreNotification) notification; |
462 | 477 |
switch (n.getType()) { |
478 |
case FeatureStoreNotification.AFTER_CANCELEDITING: |
|
479 |
needrefresh = true; |
|
463 | 480 |
case FeatureStoreNotification.AFTER_STARTEDITING: |
464 | 481 |
case FeatureStoreNotification.AFTER_FINISHEDITING: |
465 |
case FeatureStoreNotification.AFTER_CANCELEDITING: |
|
466 | 482 |
updateButtonEnabledStatus(); |
467 | 483 |
break; |
468 | 484 |
} |
469 | 485 |
} |
470 | 486 |
} |
471 | 487 |
|
488 |
@Override |
|
489 |
public void dispose() { |
|
490 |
store.deleteObserver(this); |
|
491 |
} |
|
492 |
|
|
472 | 493 |
} |
473 | 494 |
|
474 |
private class StartEditingAction extends AbstractAction implements Observer { |
|
495 |
private class StartEditingAction extends AbstractAction implements Observer, Disposable {
|
|
475 | 496 |
|
476 | 497 |
@SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) |
477 | 498 |
public StartEditingAction() { |
... | ... | |
489 | 510 |
|
490 | 511 |
@Override |
491 | 512 |
public void actionPerformed(ActionEvent ae) { |
513 |
if (store == null || formset == null) { |
|
514 |
return; |
|
515 |
} |
|
492 | 516 |
if (!store.isEditing()) { |
493 | 517 |
try { |
494 | 518 |
store.edit(); |
... | ... | |
507 | 531 |
if (notification instanceof FeatureStoreNotification) { |
508 | 532 |
FeatureStoreNotification n = (FeatureStoreNotification) notification; |
509 | 533 |
switch (n.getType()) { |
534 |
case FeatureStoreNotification.AFTER_CANCELEDITING: |
|
535 |
needrefresh = true; |
|
510 | 536 |
case FeatureStoreNotification.AFTER_STARTEDITING: |
511 | 537 |
case FeatureStoreNotification.AFTER_FINISHEDITING: |
512 |
case FeatureStoreNotification.AFTER_CANCELEDITING: |
|
513 | 538 |
updateButtonEnabledStatus(); |
514 | 539 |
break; |
515 | 540 |
} |
516 | 541 |
} |
517 | 542 |
} |
518 | 543 |
|
544 |
@Override |
|
545 |
public void dispose() { |
|
546 |
store.deleteObserver(this); |
|
547 |
} |
|
548 |
|
|
519 | 549 |
} |
520 | 550 |
|
521 | 551 |
@Override |
... | ... | |
658 | 688 |
formset.setActionEnabled(ACTION_NAVIGATION, false); |
659 | 689 |
return; |
660 | 690 |
} |
661 |
// setEnabledUniqueFields(false); |
|
691 |
if (this.needrefresh ) { |
|
692 |
this.formset.setReadOnly(true); |
|
693 |
// formset.setActionEnabled(STARTEDITING_ACTION, false); |
|
694 |
// formset.setActionEnabled(FINISHEDITING_ACTION, false); |
|
695 |
formset.setActionEnabled(ACTION_DELETE, false); |
|
696 |
formset.setActionEnabled(ACTION_NEW, false); |
|
697 |
formset.setActionEnabled(ACTION_CANCEL_NEW, false); |
|
698 |
formset.setActionEnabled(ACTION_SAVE, false); |
|
699 |
formset.setActionEnabled(ACTION_SEARCH, false); |
|
700 |
formset.setActionEnabled(ACTION_NAVIGATION, false); |
|
701 |
for (Action action : formset.getActions()) { |
|
702 |
formset.setActionEnabled((String) action.getValue(ACTION_COMMAND_KEY), false); |
|
703 |
} |
|
704 |
formset.setActionEnabled(REFRESHFORM_ACTION, true); |
|
705 |
return; |
|
706 |
} |
|
662 | 707 |
if (store.isEditing()) { |
663 | 708 |
this.formset.setReadOnly(false); |
664 | 709 |
formset.setActionVisible(STARTEDITING_ACTION, false); |
... | ... | |
930 | 975 |
@Override |
931 | 976 |
public void formAfterCancelNew(JDynFormSet dynformSet) throws AbortActionException { |
932 | 977 |
LOGGER.trace("formAfterCancelNew"); |
978 |
try { |
|
979 |
int index = formset.getCurrentIndex(); |
|
980 |
if( index<0 ) { |
|
981 |
formset.getForm().clear(); |
|
982 |
} else { |
|
983 |
formset.setCurrentIndex(index); |
|
984 |
} |
|
985 |
} catch (Exception ex) { |
|
986 |
LOGGER.warn("Can't reload form data after cancel new.", ex); |
|
987 |
} |
|
933 | 988 |
updateButtonEnabledStatus(); |
934 | 989 |
actionListeners.fireActionEvent(new ActionEvent(this, 1, "formAfterCancelNew")); |
935 | 990 |
} |
Also available in: Unified diff