use of name.abuchen.portfolio.model.ConfigurationSet in project portfolio by buchen.
the class DataSeriesConfigurator method addCopyFromOtherChartsMenu.
private void addCopyFromOtherChartsMenu(IMenuManager manager) {
String[] charts = new String[] { // $NON-NLS-1$
"StatementOfAssetsHistoryView", // $NON-NLS-1$
Messages.LabelStatementOfAssetsHistory, // $NON-NLS-1$
"PerformanceChartView", // $NON-NLS-1$
Messages.LabelPerformanceChart, "ReturnsVolatilityChartView", // $NON-NLS-1$
Messages.LabelHistoricalReturnsAndVolatiltity };
MenuManager copyFromOthers = new MenuManager(Messages.ChartSeriesCopySeriesFromOtherChart);
manager.add(copyFromOthers);
MenuManager replaceByOthers = new MenuManager(Messages.ChartSeriesReplaceSeriesByOtherChart);
manager.add(replaceByOthers);
String currentConfigUUID = store.getActiveUUID();
for (int ii = 0; ii < charts.length; ii += 2) {
ConfigurationSet set = client.getSettings().getConfigurationSet(charts[ii] + IDENTIFIER_POSTFIX);
MenuManager menuCopy = new MenuManager(charts[ii + 1]);
copyFromOthers.add(menuCopy);
MenuManager menuReplace = new MenuManager(charts[ii + 1]);
replaceByOthers.add(menuReplace);
set.getConfigurations().forEach(config -> {
if (Objects.equals(currentConfigUUID, config.getUUID()))
return;
menuCopy.add(new SimpleAction(config.getName(), a -> {
List<DataSeries> list = new DataSeriesSerializer().fromString(dataSeriesSet, config.getData());
list.stream().filter(s -> !selectedSeries.contains(s)).forEach(s -> selectedSeries.add(s));
fireUpdate();
}));
menuReplace.add(new SimpleAction(config.getName(), a -> {
List<DataSeries> list = new DataSeriesSerializer().fromString(dataSeriesSet, config.getData());
selectedSeries.clear();
list.stream().forEach(s -> selectedSeries.add(s));
fireUpdate();
}));
});
}
}
Aggregations