Revision 6da59e5d
Added by Patrick Plitzner about 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java | ||
---|---|---|
89 | 89 |
CdmFormFactory formFactory = selectionElement.getFormFactory(); |
90 | 90 |
CdmBase entity = (CdmBase) HibernateProxyHelper |
91 | 91 |
.deproxy(selectionElement.getEntity()); |
92 |
IService<CdmBase> service = CdmStore.getService(entity); |
|
93 |
rootElement = service.load(entity.getUuid()); |
|
92 |
//check if entity has already been persisted |
|
93 |
if(entity.getId()==0){ |
|
94 |
rootElement = entity; |
|
95 |
} |
|
96 |
else{ |
|
97 |
IService<CdmBase> service = CdmStore.getService(entity); |
|
98 |
rootElement = service.load(entity.getUuid()); |
|
99 |
} |
|
94 | 100 |
if (rootElement.isInstanceOf(Reference.class)) { |
95 | 101 |
addPage(new ReferenceWizardPage(formFactory, |
96 | 102 |
selectionElement.getConversationHolder(), |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElement.java | ||
---|---|---|
421 | 421 |
/** {@inheritDoc} */ |
422 | 422 |
@Override |
423 | 423 |
public void widgetSelected(SelectionEvent e) { |
424 |
|
|
425 |
IService<T> service = CdmStore.getService(entity); |
|
426 |
T loadedEntity = service.load(entity.getUuid()); |
|
427 |
if (loadedEntity==null){ |
|
428 |
MessageDialog.openInformation(null,"Save changes", "You have made changes that must be saved before this query can be executed"); |
|
429 |
return; |
|
430 |
} |
|
431 | 424 |
WizardDialog dialog = new WizardDialog(selectionElement.getShell(), |
432 | 425 |
new EditFromSelectionWizard(selectionElement)); |
433 | 426 |
if (dialog.open() == IStatus.OK) { |
434 |
|
|
435 | 427 |
selectionElement.updateFromWizard(); |
428 |
//if the edited entity has already been persisted |
|
429 |
//but the transient entity is still set in this |
|
430 |
//EntitySelectionElement, re-load it and set it |
|
431 |
IService<T> service = CdmStore.getService(entity); |
|
432 |
if(entity.getId()==0){ |
|
433 |
T loadedEntity = service.load(entity.getUuid()); |
|
434 |
if(loadedEntity!=null){ |
|
435 |
setEntity(loadedEntity); |
|
436 |
} |
|
437 |
} |
|
436 | 438 |
} |
437 | 439 |
} |
438 | 440 |
} |
Also available in: Unified diff
Fix editing of transient entities in EntitySelectionElement #5592