1 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.handler
;
3 import org
.eclipse
.core
.commands
.AbstractHandler
;
4 import org
.eclipse
.core
.commands
.ExecutionEvent
;
5 import org
.eclipse
.core
.commands
.ExecutionException
;
7 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
8 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
9 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateView
;
10 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateViewEditorInput
;
11 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
12 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
13 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
15 public class CreateFieldUnitHandler
extends AbstractHandler
{
18 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
19 if(AbstractUtility
.getActivePart() instanceof DerivateView
){
20 DerivateView derivateView
= (DerivateView
)AbstractUtility
.getActivePart();
21 if(derivateView
.isDirty()){
22 MessagingUtils
.warningDialog(DerivateView
.VIEW_HAS_UNSAVED_CHANGES
, this, DerivateView
.YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION
);
25 FieldUnit fieldUnit
= FieldUnit
.NewInstance();
26 CdmStore
.getService(IOccurrenceService
.class).save(fieldUnit
);
27 derivateView
.getConversationHolder().commit();
28 DerivateViewEditorInput input
= (DerivateViewEditorInput
) derivateView
.getEditorInput();
29 input
.addRootUuid(fieldUnit
.getUuid());
30 derivateView
.refreshTree();