use of name.abuchen.portfolio.ui.dialogs.ListSelectionDialog in project portfolio by buchen.
the class ClientFilterMenu method createCustomFilter.
private void createCustomFilter() {
LabelProvider labelProvider = new LabelProvider() {
@Override
public Image getImage(Object element) {
return element instanceof Account ? Images.ACCOUNT.image() : Images.PORTFOLIO.image();
}
};
ListSelectionDialog dialog = new ListSelectionDialog(Display.getDefault().getActiveShell(), labelProvider);
dialog.setTitle(Messages.LabelClientFilterDialogTitle);
dialog.setMessage(Messages.LabelClientFilterDialogMessage);
List<Object> elements = new ArrayList<>();
elements.addAll(client.getPortfolios());
elements.addAll(client.getAccounts());
dialog.setElements(elements);
if (dialog.open() == ListSelectionDialog.OK) {
Object[] selected = dialog.getResult();
if (selected.length > 0) {
Item newItem = buildItem(selected);
selectedItem = newItem;
customItems.addFirst(newItem);
if (customItems.size() > MAXIMUM_NO_CUSTOM_ITEMS)
customItems.removeLast();
preferences.putValue(ClientFilterDropDown.class.getSimpleName(), // $NON-NLS-1$
String.join(// $NON-NLS-1$
";", customItems.stream().map(i -> i.uuids).collect(Collectors.toList())));
listeners.forEach(l -> l.accept(newItem.filter));
}
}
}
use of name.abuchen.portfolio.ui.dialogs.ListSelectionDialog 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();
}
use of name.abuchen.portfolio.ui.dialogs.ListSelectionDialog in project portfolio by buchen.
the class DataSeriesConfigurator method doAddSeries.
private void doAddSeries(boolean showOnlyBenchmark) {
List<DataSeries> list = new ArrayList<>(dataSeriesSet.getAvailableSeries());
// remove items if that do not match the benchmark flag
Iterator<DataSeries> iter = list.iterator();
while (iter.hasNext()) if (iter.next().isBenchmark() != showOnlyBenchmark)
iter.remove();
// remove already selected items
for (DataSeries s : selectedSeries) list.remove(s);
ListSelectionDialog dialog = new ListSelectionDialog(Display.getDefault().getActiveShell(), new DataSeriesLabelProvider());
dialog.setTitle(Messages.ChartSeriesPickerTitle);
dialog.setMessage(Messages.ChartSeriesPickerTitle);
dialog.setElements(list);
if (dialog.open() != ListSelectionDialog.OK)
return;
Object[] result = dialog.getResult();
if (result == null || result.length == 0)
return;
for (Object object : result) selectedSeries.add((DataSeries) object);
fireUpdate();
}
Aggregations