From f94b166b4aee8877c11e4057165dcfd8057a4f8e Mon Sep 17 00:00:00 2001 From: Patrick Plitzner Date: Wed, 19 Jul 2017 16:47:34 +0200 Subject: [PATCH] ref #6597 Avoid session errors and empty view for unaccepted selections --- .../view/e4/details/DetailsPartE4.java | 20 +++++++++++++++++-- .../view/e4/details/DetailsViewerE4.java | 5 +++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java index 6db8d125f..b9f28fe9e 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java @@ -25,9 +25,11 @@ import org.eclipse.ui.IEditorPart; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; +import eu.etaxonomy.cdm.model.description.Feature; import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; import eu.etaxonomy.taxeditor.l10n.Messages; import eu.etaxonomy.taxeditor.model.AbstractUtility; +import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; import eu.etaxonomy.taxeditor.model.IDirtyMarkable; import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility; @@ -75,14 +77,28 @@ public class DetailsPartE4 implements IConversationEnabled, IDirtyMarkable{ else{ structuredSelection = (IStructuredSelection) selection; } - if((partObject instanceof IEditorPart) || (partObject instanceof IPartContentHasDetails)) { + if((partObject instanceof IEditorPart) || (partObject instanceof IPartContentHasDetails) + && partObject instanceof IConversationEnabled) { + // do not show details for feature nodes TODO strange check to avoid having shown the distribution map for every FeatureNodeContainer + if(structuredSelection.getFirstElement() instanceof FeatureNodeContainer){ + // do show the map for distributions + Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature(); + if(!feature.equals(Feature.DISTRIBUTION())){ + showEmptyPage(); + return; + } + } showViewer(structuredSelection); selectionProvidingPart = activePart; } + else{ + showEmptyPage(); + } } public void showEmptyPage() { - viewer.setSelection(null); + viewer.showEmptyPage(); + selectionProvidingPart = null; } protected String getViewName(){ diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java index a0b80dc54..506e74446 100755 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java @@ -163,6 +163,11 @@ public class DetailsViewerE4 extends AbstractCdmDataViewerE4 { super.setInput(input); } + public void showEmptyPage(){ + destroySections(); + createEmptySection(rootElement); + } + /** {@inheritDoc} */ @Override -- 2.34.1