Search in sources :

Example 1 with DataSeriesLabelProvider

use of name.abuchen.portfolio.ui.views.dataseries.DataSeriesLabelProvider in project portfolio by buchen.

the class DataSeriesConfig method doAddSeries.

private void doAddSeries(boolean showOnlyBenchmark) {
    List<DataSeries> list = delegate.getDashboardData().getDataSeriesSet().getAvailableSeries().stream().filter(ds -> ds.isBenchmark() == showOnlyBenchmark).collect(Collectors.toList());
    ListSelectionDialog dialog = new ListSelectionDialog(Display.getDefault().getActiveShell(), new DataSeriesLabelProvider());
    dialog.setTitle(Messages.ChartSeriesPickerTitle);
    dialog.setMessage(Messages.ChartSeriesPickerTitle);
    dialog.setElements(list);
    dialog.setMultiSelection(false);
    if (dialog.open() != ListSelectionDialog.OK)
        return;
    Object[] result = dialog.getResult();
    if (result == null || result.length == 0)
        return;
    dataSeries = (DataSeries) result[0];
    delegate.getWidget().getConfiguration().put(Dashboard.Config.DATA_SERIES.name(), dataSeries.getUUID());
    // construct label to indicate the data series (user can manually change
    // the label later)
    // $NON-NLS-1$
    String label = WidgetFactory.valueOf(delegate.getWidget().getType()).getLabel() + ", " + dataSeries.getLabel();
    delegate.getWidget().setLabel(label);
    delegate.getClient().markDirty();
}
Also used : Separator(org.eclipse.jface.action.Separator) Dashboard(name.abuchen.portfolio.model.Dashboard) MenuManager(org.eclipse.jface.action.MenuManager) DataSeries(name.abuchen.portfolio.ui.views.dataseries.DataSeries) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) List(java.util.List) IMenuManager(org.eclipse.jface.action.IMenuManager) Messages(name.abuchen.portfolio.ui.Messages) ListSelectionDialog(name.abuchen.portfolio.ui.dialogs.ListSelectionDialog) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) DataSeriesLabelProvider(name.abuchen.portfolio.ui.views.dataseries.DataSeriesLabelProvider) DataSeries(name.abuchen.portfolio.ui.views.dataseries.DataSeries) ListSelectionDialog(name.abuchen.portfolio.ui.dialogs.ListSelectionDialog) DataSeriesLabelProvider(name.abuchen.portfolio.ui.views.dataseries.DataSeriesLabelProvider)

Aggregations

List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Dashboard (name.abuchen.portfolio.model.Dashboard)1 Messages (name.abuchen.portfolio.ui.Messages)1 ListSelectionDialog (name.abuchen.portfolio.ui.dialogs.ListSelectionDialog)1 LabelOnly (name.abuchen.portfolio.ui.util.LabelOnly)1 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)1 DataSeries (name.abuchen.portfolio.ui.views.dataseries.DataSeries)1 DataSeriesLabelProvider (name.abuchen.portfolio.ui.views.dataseries.DataSeriesLabelProvider)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 Display (org.eclipse.swt.widgets.Display)1