1 package eu
.etaxonomy
.taxeditor
.editor
.view
.dataimport
;
3 import org
.eclipse
.core
.commands
.AbstractHandler
;
4 import org
.eclipse
.core
.commands
.ExecutionEvent
;
5 import org
.eclipse
.core
.commands
.ExecutionException
;
6 import org
.eclipse
.jface
.viewers
.ISelection
;
7 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
8 import org
.eclipse
.ui
.IWorkbenchPart
;
9 import org
.eclipse
.ui
.IWorkbenchWindow
;
10 import org
.eclipse
.ui
.PlatformUI
;
12 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
13 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
14 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
15 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
18 public class SaveSpecimenCommand
extends AbstractHandler
{
21 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
24 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
25 final IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
26 final ISelection selection
= window
.getActivePage().getSelection();
27 if(selection
instanceof StructuredSelection
){
28 StructuredSelection structuredSelection
= (StructuredSelection
)selection
;
29 Object firstElement
= structuredSelection
.getFirstElement();
30 if(firstElement
instanceof SpecimenOrObservationBase
){
31 IWorkbenchPart activePart
= AbstractUtility
.getActivePart();
32 if(activePart
instanceof DataImportEditor
){
33 DataImportEditor dataImportEditor
= (DataImportEditor
)activePart
;
34 CdmStore
.getService(IOccurrenceService
.class).saveOrUpdate((SpecimenOrObservationBase
) firstElement
);
35 dataImportEditor
.getConversationHolder().commit(true);