Search in sources :

Example 1 with ConfigurationSet

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();
            }));
        });
    }
}
Also used : Separator(org.eclipse.jface.action.Separator) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Shell(org.eclipse.swt.widgets.Shell) Client(name.abuchen.portfolio.model.Client) Iterator(java.util.Iterator) ConfigurationStore(name.abuchen.portfolio.ui.util.ConfigurationStore) MenuManager(org.eclipse.jface.action.MenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Display(org.eclipse.swt.widgets.Display) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) IMenuManager(org.eclipse.jface.action.IMenuManager) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) Messages(name.abuchen.portfolio.ui.Messages) ConfigurationStoreOwner(name.abuchen.portfolio.ui.util.ConfigurationStore.ConfigurationStoreOwner) ConfigurationSet(name.abuchen.portfolio.model.ConfigurationSet) ListSelectionDialog(name.abuchen.portfolio.ui.dialogs.ListSelectionDialog) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener) ConfigurationSet(name.abuchen.portfolio.model.ConfigurationSet) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ArrayList(java.util.ArrayList) List(java.util.List) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Aggregations

ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Objects (java.util.Objects)1 Client (name.abuchen.portfolio.model.Client)1 ConfigurationSet (name.abuchen.portfolio.model.ConfigurationSet)1 AbstractFinanceView (name.abuchen.portfolio.ui.AbstractFinanceView)1 Messages (name.abuchen.portfolio.ui.Messages)1 ListSelectionDialog (name.abuchen.portfolio.ui.dialogs.ListSelectionDialog)1 ConfigurationStore (name.abuchen.portfolio.ui.util.ConfigurationStore)1 ConfigurationStoreOwner (name.abuchen.portfolio.ui.util.ConfigurationStore.ConfigurationStoreOwner)1 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)1 Action (org.eclipse.jface.action.Action)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 Display (org.eclipse.swt.widgets.Display)1 Menu (org.eclipse.swt.widgets.Menu)1