diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/DonutChartBuilder.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/DonutChartBuilder.java index c25be4001c..6f0942fe51 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/DonutChartBuilder.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/DonutChartBuilder.java @@ -74,22 +74,29 @@ public List> computeNodeList(TaxonomyModel mode // classified nodes TaxonomyNode node = model.getClassificationRootNode(); - addChildren(answer, node, node.getChildren()); + addChildren(answer, node, node.getChildren(), model.isSecuritiesInPieChartExcluded()); // add unclassified if included if (!model.isUnassignedCategoryInChartsExcluded()) { TaxonomyNode unassigned = model.getUnassignedNode(); - List children = new ArrayList<>(unassigned.getChildren()); - Collections.sort(children, (r, l) -> l.getActual().compareTo(r.getActual())); - addChildren(answer, unassigned, children); + if (model.isSecuritiesInPieChartExcluded()) + { + answer.add(new Pair<>(unassigned, unassigned)); + } + else + { + List children = new ArrayList<>(unassigned.getChildren()); + Collections.sort(children, (r, l) -> l.getActual().compareTo(r.getActual())); + addChildren(answer, unassigned, children, model.isSecuritiesInPieChartExcluded()); + } } return answer; } private void addChildren(List> answer, TaxonomyNode parent, - List children) + List children, boolean firstLevelOnly) { for (TaxonomyNode child : children) { @@ -100,6 +107,10 @@ private void addChildren(List> answer, Taxonomy { answer.add(new Pair<>(parent, child)); } + else if (child.isClassification() && firstLevelOnly) + { + answer.add(new Pair<>(child, child)); + } else if (child.isClassification()) { List grandchildren = new ArrayList<>(); diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/DonutViewer.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/DonutViewer.java index f54556ed1f..027120d66e 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/DonutViewer.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/DonutViewer.java @@ -3,12 +3,16 @@ import jakarta.inject.Inject; import org.eclipse.e4.core.di.extensions.Preference; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import name.abuchen.portfolio.ui.Messages; import name.abuchen.portfolio.ui.UIConstants; import name.abuchen.portfolio.ui.editor.AbstractFinanceView; import name.abuchen.portfolio.ui.util.EmbeddedBrowser; +import name.abuchen.portfolio.ui.util.SimpleAction; import name.abuchen.portfolio.ui.views.IPieChart; /* package */class DonutViewer extends AbstractChartPage @@ -28,6 +32,20 @@ public DonutViewer(AbstractFinanceView view, TaxonomyModel model, TaxonomyNodeRe this.view = view; } + @Override + public void configMenuAboutToShow(IMenuManager manager) + { + super.configMenuAboutToShow(manager); + + Action action = new SimpleAction(Messages.LabelIncludeSecuritiesInPieChart, a -> { + getModel().setExcludeSecuritiesInPieChart(!getModel().isSecuritiesInPieChartExcluded()); + getModel().fireTaxonomyModelChange(getModel().getVirtualRootNode()); + chart.refresh(null); + }); + action.setChecked(!getModel().isSecuritiesInPieChartExcluded()); + manager.add(action); + } + @Override public Control createControl(Composite container) { diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/PieChartViewer.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/PieChartViewer.java index 6c4eee74be..49789d72c7 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/PieChartViewer.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/taxonomy/PieChartViewer.java @@ -39,6 +39,7 @@ public void configMenuAboutToShow(IMenuManager manager) Action action = new SimpleAction(Messages.LabelIncludeSecuritiesInPieChart, a -> { getModel().setExcludeSecuritiesInPieChart(!getModel().isSecuritiesInPieChartExcluded()); + getModel().fireTaxonomyModelChange(getModel().getVirtualRootNode()); chart.refresh(null); }); action.setChecked(!getModel().isSecuritiesInPieChartExcluded());