1 package eu
.etaxonomy
.taxeditor
.editor
.view
.dataimport
;
3 import java
.util
.Iterator
;
5 import org
.eclipse
.core
.commands
.AbstractHandler
;
6 import org
.eclipse
.core
.commands
.ExecutionEvent
;
7 import org
.eclipse
.core
.commands
.ExecutionException
;
8 import org
.eclipse
.jface
.viewers
.ISelection
;
9 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
10 import org
.eclipse
.ui
.IWorkbenchPart
;
11 import org
.eclipse
.ui
.IWorkbenchWindow
;
12 import org
.eclipse
.ui
.PlatformUI
;
14 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
15 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
16 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
17 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
20 public class SaveSpecimenCommand
extends AbstractHandler
{
23 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
26 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
27 final IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
28 final ISelection selection
= window
.getActivePage().getSelection();
29 if(selection
instanceof StructuredSelection
){
30 StructuredSelection structuredSelection
= (StructuredSelection
)selection
;
31 Iterator
<?
> iterator
= structuredSelection
.iterator();
32 while(iterator
.hasNext()){
33 Object next
= iterator
.next();
34 if(next
instanceof SpecimenOrObservationBase
){
35 IWorkbenchPart activePart
= AbstractUtility
.getActivePart();
36 if(activePart
instanceof DataImportEditor
){
37 DataImportEditor dataImportEditor
= (DataImportEditor
)activePart
;
38 CdmStore
.getService(IOccurrenceService
.class).saveOrUpdate((SpecimenOrObservationBase
<?
>) next
);
39 dataImportEditor
.getConversationHolder().commit(true);