import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.description.Distribution;
+import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.editor.IDistributionEditor;
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4;
import eu.etaxonomy.taxeditor.view.e4.details.DetailsViewerE4;
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
import eu.etaxonomy.taxeditor.workbench.part.ISelectionElementEditingPart;
protected Object previousSelection;
- public Object getPreviousSelection() {
- return previousSelection;
- }
-
- public void setPreviousSelection(Object previousSelection) {
- this.previousSelection = previousSelection;
- }
-
protected ISelectionChangedListener selectionChangedListener;
public ISelectionChangedListener getSelectionChangedListener() {
showEmptyPage();
return;
}
+ // no active editor found
if(activePart==thisPart && WorkbenchUtility.getActiveEditorPart(partService)==null){
showEmptyPage();
return;
}
-
- if(previousSelection==null ||
- previousSelection!=selection){//skip redundant rendering of details view
- if(delaySelection==null){
- delaySelection = new DelaySelection(selection, activePart, thisPart);
- }
- delaySelection.setSelection(selection);
- delaySelection.setActivePart(activePart);
- delaySelection.setThisPart(thisPart);
- if(!isInDelay){
- isInDelay = true;
- sync.asyncExec(delaySelection);
- previousSelection = selection;
- }
+ if((previousSelection!=null && selection!=null) && activePart.equals(selectionProvidingPart) &&
+ (previousSelection==selection
+ || previousSelection.equals(selection)
+ || new StructuredSelection(selection).equals(previousSelection))
+ ) {
+ return;
+ }
+ if(delaySelection==null){
+ delaySelection = new DelaySelection(selection, activePart, thisPart);
+ }
+ delaySelection.setSelection(selection);
+ delaySelection.setActivePart(activePart);
+ delaySelection.setThisPart(thisPart);
+ if(!isInDelay){
+ isInDelay = true;
+ sync.asyncExec(delaySelection);
+ previousSelection = selection;
}
}
if(selection.getFirstElement()!=null){
if (element instanceof Taxon){
Taxon taxon = HibernateProxyHelper.deproxy(element, Taxon.class);
- if (taxon.isMisapplication() || taxon.isProparteSynonym()){
+ if (taxon.isMisapplication() || taxon.isProparteSynonym() || taxon.isInvalidDesignation()){
if(part instanceof ITaxonEditor){
Taxon accepted = ((ITaxonEditor) part).getTaxon();
if (rels != null && rels.iterator().hasNext() && !taxon.equals(accepted)){
TaxonRelationship rel = rels.iterator().next();
- if ((rel.getType().isAnyMisappliedName() || rel.getType().isAnySynonym())&& !rel.getFromTaxon().equals(((ITaxonEditor) part).getTaxon())){
+ if ((rel.getType().isMisappliedNameOrInvalidDesignation() || rel.getType().isAnySynonym()) && !rel.getFromTaxon().equals(((ITaxonEditor) part).getTaxon())){
viewer.setInput(rel);
selectionProvidingPart = activePart;
return;
}
}
- if (element instanceof Distribution && part instanceof IDistributionEditor){
+ //unwrap term DTOs
+ if(element instanceof TermDto){
+ element = CdmStore.getService(ITermService.class).load(((TermDto) element).getUuid());
+ }
+ else if(element instanceof TermVocabularyDto){
+ element = CdmStore.getService(IVocabularyService.class).load(((TermVocabularyDto) element).getUuid());
+ }
+
+ selectionProvidingPart = activePart;
+ if (viewer instanceof DetailsViewerE4){
((DetailsViewerE4)viewer).setInput(element, part);
- }else{
- viewer.setInput(element);
- if (viewer instanceof DetailsViewerE4){
- ((DetailsViewerE4)viewer).setDetailsEnabled(true);
+ ((DetailsViewerE4)viewer).setDetailsEnabled(true);
+
+ }
+
+ else{
+ if (activePart.getObject() instanceof DetailsPartE4 && element instanceof TaxonName){
+ selectionProvidingPart = ((DetailsPartE4)activePart.getObject()).getSelectionProvidingPart();
}
+ viewer.setInput(element);
}
- selectionProvidingPart = activePart;
}
}
}
* {@inheritDoc}
*/
@Override
- public boolean postOperation(CdmBase objectAffectedByOperation) {
+ public boolean postOperation(Object objectAffectedByOperation) {
changed(objectAffectedByOperation);
return true;
}