10 |
10 |
|
11 |
11 |
package eu.etaxonomy.taxeditor.editor.handler.create;
|
12 |
12 |
|
13 |
|
import java.util.Collections;
|
14 |
|
|
15 |
13 |
import org.apache.log4j.Logger;
|
16 |
14 |
import org.eclipse.core.commands.AbstractHandler;
|
17 |
15 |
import org.eclipse.core.commands.ExecutionEvent;
|
18 |
16 |
import org.eclipse.core.commands.ExecutionException;
|
19 |
|
import org.eclipse.ui.PartInitException;
|
|
17 |
import org.eclipse.jface.wizard.WizardDialog;
|
|
18 |
import org.eclipse.ui.handlers.HandlerUtil;
|
20 |
19 |
|
21 |
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
22 |
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
|
23 |
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeFieldUnitCacheStrategy;
|
24 |
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
25 |
|
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
|
26 |
|
import eu.etaxonomy.cdm.model.occurrence.DerivationEventType;
|
27 |
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
28 |
|
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
29 |
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
30 |
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
31 |
|
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
|
32 |
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
|
20 |
import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
|
33 |
21 |
|
34 |
22 |
/**
|
35 |
23 |
* @author n.hoffmann
|
... | ... | |
43 |
31 |
/** {@inheritDoc} */
|
44 |
32 |
@Override
|
45 |
33 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
46 |
|
ConversationHolder conversation = CdmStore.createConversation();
|
47 |
|
conversation.bind();
|
48 |
|
FieldUnit fieldUnit = FieldUnit.NewInstance();
|
49 |
|
DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
|
50 |
|
DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.GATHERING_IN_SITU());
|
51 |
|
fieldUnit.setCacheStrategy(new DerivedUnitFacadeFieldUnitCacheStrategy());
|
52 |
|
derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
|
53 |
|
CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
|
54 |
|
CdmStore.getService(IOccurrenceService.class).save(derivedUnit);
|
55 |
|
conversation.commit();
|
56 |
|
DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singleton(fieldUnit.getUuid()));
|
57 |
|
try {
|
58 |
|
EditorUtil.open(input);
|
59 |
|
} catch (PartInitException e) {
|
60 |
|
// TODO Auto-generated catch block
|
61 |
|
e.printStackTrace();
|
62 |
|
}
|
63 |
|
// NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
|
64 |
|
// wizard.init(null, null);
|
65 |
|
// WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
|
66 |
|
// dialog.open();
|
|
34 |
//TODO: we need to discuss how specimens should be created and handled #5244
|
|
35 |
// ConversationHolder conversation = CdmStore.createConversation();
|
|
36 |
// conversation.bind();
|
|
37 |
// FieldUnit fieldUnit = FieldUnit.NewInstance();
|
|
38 |
// DerivedUnit derivedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
|
|
39 |
// DerivationEvent.NewSimpleInstance(fieldUnit, derivedUnit, DerivationEventType.GATHERING_IN_SITU());
|
|
40 |
// fieldUnit.setCacheStrategy(new DerivedUnitFacadeFieldUnitCacheStrategy());
|
|
41 |
// derivedUnit.setCacheStrategy(new DerivedUnitFacadeCacheStrategy());
|
|
42 |
// CdmStore.getService(IOccurrenceService.class).save(fieldUnit);
|
|
43 |
// CdmStore.getService(IOccurrenceService.class).save(derivedUnit);
|
|
44 |
// conversation.commit();
|
|
45 |
// DerivateViewEditorInput input = new DerivateViewEditorInput(Collections.singleton(fieldUnit.getUuid()));
|
|
46 |
// try {
|
|
47 |
// EditorUtil.open(input);
|
|
48 |
// } catch (PartInitException e) {
|
|
49 |
// // TODO Auto-generated catch block
|
|
50 |
// e.printStackTrace();
|
|
51 |
// }
|
|
52 |
NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard();
|
|
53 |
wizard.init(null, null);
|
|
54 |
WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
|
|
55 |
dialog.open();
|
67 |
56 |
return null;
|
68 |
57 |
}
|
69 |
58 |
}
|
Use wizard to create new specimen