From: Katja Luther Date: Mon, 29 Jun 2020 11:21:56 +0000 (+0200) Subject: set selection after facts creation X-Git-Tag: 5.16.0^2~14 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/b3860b273a8fe42cfad08d3ff18b4519d39bc9d7 set selection after facts creation --- diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java index 450540c7a..723d1668e 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java @@ -23,6 +23,7 @@ import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.ui.di.UIEventTopic; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.services.EMenuService; +import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.StructuredSelection; @@ -55,6 +56,7 @@ import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewerSorter; import eu.etaxonomy.taxeditor.editor.view.descriptive.NameDescriptionFilter; import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4; import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants; +import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree; import eu.etaxonomy.taxeditor.model.IPartContentHasDetails; import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData; @@ -199,26 +201,21 @@ public class FactualDataPartE4 extends AbstractCdmEditorPartE4 if (featureNodeContainerCache.isEmpty()){ // return; } -// if(object instanceof DescriptionElementBase){ -// DescriptionElementBase descriptionElement = (DescriptionElementBase) object; -// DescriptionBase description = descriptionElement.getInDescription(); -//// FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description); -// -//// FeatureNodeContainer featureNodeContainer = containerTree.getFeatureNodeContainerForDescriptionElement(descriptionElement); -//// ((AbstractTreeViewer) viewer).expandToLevel(featureNodeContainer, 1); -// -// } - - viewer.refresh(); + super.changed(object); ((TreeViewer) viewer).setExpandedElements(expandedObjects); - - if(object != null){ + if(object instanceof DescriptionElementBase){ + DescriptionElementBase descriptionElement = (DescriptionElementBase) object; + DescriptionBase description = descriptionElement.getInDescription(); + FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description); + FeatureNodeContainer featureNodeContainer = containerTree.getFeatureNodeContainerForDescriptionElement(descriptionElement); + ((AbstractTreeViewer) viewer).expandToLevel(featureNodeContainer, 2); StructuredSelection selection = new StructuredSelection(object); viewer.setSelection(selection, true); } -// selectionProvidingPart.setDirty(true); - super.changed(object); + + + } @Inject @@ -234,6 +231,22 @@ public class FactualDataPartE4 extends AbstractCdmEditorPartE4 } } + @Inject + @Optional + private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_FACTS)Object element){ + + Object[] expandedObjects = ((TreeViewer)viewer).getExpandedElements(); + + + viewer.refresh(); + ((TreeViewer)viewer).collapseAll(); + if (expandedObjects.length>0){ + ((TreeViewer)viewer).setExpandedElements(expandedObjects); + } + ((TreeViewer)viewer).setExpandedState(element, true); + + } + @Inject @Optional private void updateView(@UIEventTopic(WorkbenchEventConstants.CURRENT_ACTIVE_EDITOR)ITaxonEditor editor){