1
|
package eu.etaxonomy.taxeditor.bulkeditor.command;
|
2
|
|
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.ui.IWorkbenchWindow;
|
8
|
import org.eclipse.ui.PlatformUI;
|
9
|
|
10
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
11
|
import eu.etaxonomy.taxeditor.model.LineSelection;
|
12
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
13
|
|
14
|
public class SaveSpecimenCommand extends AbstractHandler {
|
15
|
|
16
|
/* (non-Javadoc)
|
17
|
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
18
|
*/
|
19
|
@Override
|
20
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
21
|
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
22
|
final ISelection selection = window.getActivePage().getSelection();
|
23
|
if(selection instanceof LineSelection){
|
24
|
LineSelection line = (LineSelection)selection;
|
25
|
Object firstElement = line.getFirstElement();
|
26
|
if(firstElement instanceof SpecimenOrObservationBase){
|
27
|
CdmStore.getCurrentApplicationConfiguration().getOccurrenceService().saveOrUpdate((SpecimenOrObservationBase) firstElement);
|
28
|
}
|
29
|
}
|
30
|
return null;
|
31
|
}
|
32
|
|
33
|
}
|