import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
import eu.etaxonomy.cdm.model.media.Media;
import eu.etaxonomy.cdm.model.name.TaxonName;
+import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
+import eu.etaxonomy.taxeditor.bulkeditor.input.MediaEditorInput;
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.IBulkEditor;
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
private BulkEditorQuery lastQuery = null;
private BulkEditorComposite bulkEditorComposite;
-
+
private Set<AbstractPostOperation> operations = new HashSet<>();
@Inject
}
public void save(IProgressMonitor monitor, boolean resetMerge) {
+ IStructuredSelection selection = getLastSelection();
for(AbstractPostOperation<?> entry:operations){
IStatus status = Status.CANCEL_STATUS;
final IAdaptable uiInfoAdapter = WorkspaceUndoUtil
String operationlabel = entry.getLabel();
try {
entry.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
-
+
status = entry.execute(new NullProgressMonitor(), uiInfoAdapter);
} catch (ExecutionException e) {
MessagingUtils.operationDialog(AbstractUtility.class, e, TaxeditorStorePlugin.PLUGIN_ID, operationlabel, null);
}
input.saveModel(resetMerge);
- IStructuredSelection selection = getSelection();
+// IStructuredSelection selection = getSelection();
dirty.setDirty(false);
input.dispose();
if (lastQuery != null){
bulkEditorComposite.performSearch(lastQuery, selection);
}
+
}
- @Focus
+ private IStructuredSelection getLastSelection() {
+ return new StructuredSelection(this.bulkEditorComposite.getLastSelectedObject());
+ }
+
+ @Override
+ @Focus
public void setFocus() {
//make sure to bind again if maybe in another view the conversation was unbound
if(conversation!=null && !conversation.isBound()){
return bulkEditorComposite.getCellSelection();
}
+ @Override
public void setSelection(IStructuredSelection selection){
bulkEditorComposite.setSelection(selection);
}
getEditorInput().addSaveCandidate(changedSpecimen);
input.replaceInModel(changedSpecimen);
}
- }else if (element instanceof Media){
+ }else if (element instanceof Media && input instanceof MediaEditorInput){
+ getEditorInput().addSaveCandidate((Media)element);
+ input.replaceInModel((Media)element);
+ }else if (element instanceof Media ) {
IStructuredSelection sel = getSelection();
Object firstElement = sel.getFirstElement();
if (firstElement instanceof TaxonBase){
SpecimenOrObservationBase changedSpecimen = (SpecimenOrObservationBase)sel.getFirstElement();
getEditorInput().addSaveCandidate(changedSpecimen);
input.replaceInModel(changedSpecimen);
- } else if (firstElement instanceof Media){
- getEditorInput().addSaveCandidate((Media)element);
- input.replaceInModel((Media)element);
}
}else if(element instanceof Group){
Group oldGroup = ((GroupEditorInput)input).getEntityFromModel((Group)element);
getEditorInput().addSaveCandidate(taxonBase);
input.replaceInModel( taxonBase);
- }else{
+ }else if(element instanceof TypeDesignationBase ){
+ IStructuredSelection sel = this.getSelection();
+ TaxonName name = null;
+ TaxonBase taxon = null;
+ if (sel.getFirstElement() instanceof TaxonName){
+ name = HibernateProxyHelper.deproxy(sel.getFirstElement(), TaxonName.class);
+ }else if (sel.getFirstElement() instanceof TaxonBase) {
+ taxon = HibernateProxyHelper.deproxy(sel.getFirstElement(), TaxonBase.class);
+ }
+ if (name != null) {
+ getEditorInput().addSaveCandidate(name);
+ input.replaceInModel( name);
+ }else {
+ getEditorInput().addSaveCandidate(taxon);
+ input.replaceInModel(taxon);
+ }
+
+ }
+ else{
getEditorInput().addSaveCandidate((CdmBase)element);
input.replaceInModel((CdmBase) element);
}