use of name.abuchen.portfolio.ui.util.LabelOnly in project portfolio by buchen.
the class ReviewExtractedItemsPage method showContextMenu.
private void showContextMenu(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
boolean atLeastOneImported = false;
boolean atLeastOneNotImported = false;
for (Object element : selection.toList()) {
ExtractedEntry entry = (ExtractedEntry) element;
// an entry will be imported if it is marked as to be
// imported *and* not a duplicate
atLeastOneImported = atLeastOneImported || entry.isImported();
// an entry will not be imported if it marked as not to be
// imported *or* if it is marked as duplicate
atLeastOneNotImported = atLeastOneNotImported || !entry.isImported();
}
// provide a hint to the user why the entry is struck out
if (selection.size() == 1) {
ExtractedEntry entry = (ExtractedEntry) selection.getFirstElement();
//
entry.getStatus().filter(//
s -> s.getCode() != ImportAction.Status.Code.OK).forEach(s -> {
Images image = //
s.getCode() == ImportAction.Status.Code.WARNING ? Images.WARNING : Images.ERROR;
manager.add(new LabelOnly(s.getMessage(), image.descriptor()));
});
}
if (atLeastOneImported) {
manager.add(new Action(Messages.LabelDoNotImport) {
@Override
public void run() {
for (Object element : ((IStructuredSelection) tableViewer.getSelection()).toList()) ((ExtractedEntry) element).setImported(false);
tableViewer.refresh();
}
});
}
if (atLeastOneNotImported) {
manager.add(new Action(Messages.LabelDoImport) {
@Override
public void run() {
for (Object element : ((IStructuredSelection) tableViewer.getSelection()).toList()) ((ExtractedEntry) element).setImported(true);
tableViewer.refresh();
}
});
}
}
use of name.abuchen.portfolio.ui.util.LabelOnly in project portfolio by buchen.
the class StatementOfAssetsView method addCalendarButton.
private void addCalendarButton(ToolBar toolBar) {
AbstractDropDown.create(toolBar, Messages.LabelPortfolioTimeMachine, Images.CALENDAR_OFF.image(), SWT.NONE, (dropDown, manager) -> {
manager.add(new LabelOnly(Values.Date.format(snapshotDate)));
manager.add(new Separator());
SimpleAction action = new SimpleAction(Messages.LabelToday, a -> {
snapshotDate = LocalDate.now();
notifyModelUpdated();
dropDown.getToolItem().setImage(Images.CALENDAR_OFF.image());
});
action.setEnabled(!snapshotDate.equals(LocalDate.now()));
manager.add(action);
manager.add(new SimpleAction(Messages.MenuPickOtherDate, a -> {
DateSelectionDialog dialog = new DateSelectionDialog(getActiveShell());
dialog.setSelection(snapshotDate);
if (dialog.open() != DateSelectionDialog.OK)
return;
if (snapshotDate.equals(dialog.getSelection()))
return;
snapshotDate = dialog.getSelection();
notifyModelUpdated();
dropDown.getToolItem().setImage(LocalDate.now().equals(snapshotDate) ? Images.CALENDAR_OFF.image() : Images.CALENDAR_ON.image());
}));
});
}
use of name.abuchen.portfolio.ui.util.LabelOnly in project portfolio by buchen.
the class ExchangeRateSeriesConfig method menuAboutToShow.
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(getLabel()));
MenuManager subMenu = new MenuManager(Messages.LabelExchangeRate);
available.stream().forEach(ts -> {
SimpleAction action = new SimpleAction(ts.getLabel(), a -> {
series = ts;
String code = ts.getBaseCurrency() + '/' + ts.getTermCurrency();
delegate.getWidget().getConfiguration().put(Dashboard.Config.EXCHANGE_RATE_SERIES.name(), code);
delegate.getClient().markDirty();
});
action.setChecked(series.equals(ts));
subMenu.add(action);
});
manager.add(subMenu);
}
use of name.abuchen.portfolio.ui.util.LabelOnly in project portfolio by buchen.
the class LabelConfig method menuAboutToShow.
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(delegate.getWidget().getLabel()));
manager.add(new SimpleAction(Messages.MenuRenameLabel, a -> {
InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.MenuRenameLabel, Messages.ColumnLable, delegate.getWidget().getLabel(), null);
if (dialog.open() != InputDialog.OK)
return;
delegate.getWidget().setLabel(dialog.getValue());
delegate.getClient().markDirty();
}));
}
use of name.abuchen.portfolio.ui.util.LabelOnly in project portfolio by buchen.
the class ReportingPeriodConfig method menuAboutToShow.
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(getReportingPeriod().toString()));
MenuManager subMenu = new MenuManager(Messages.LabelReportingPeriod);
subMenu.add(new LabelOnly(reportingPeriod != null ? getReportingPeriod().toString() : Messages.LabelUsingDashboardDefaultReportingPeriod));
subMenu.add(new Separator());
subMenu.add(new SimpleAction(Messages.MenuUseDashboardDefaultReportingPeriod, a -> {
reportingPeriod = null;
delegate.getWidget().getConfiguration().remove(Dashboard.Config.REPORTING_PERIOD.name());
delegate.getClient().markDirty();
}));
delegate.getDashboardData().getDefaultReportingPeriods().stream().forEach(p -> subMenu.add(new SimpleAction(p.toString(), a -> {
reportingPeriod = p;
delegate.getWidget().getConfiguration().put(Dashboard.Config.REPORTING_PERIOD.name(), p.getCode());
delegate.getClient().markDirty();
})));
subMenu.add(new Separator());
subMenu.add(new SimpleAction(Messages.LabelReportingAddPeriod, a -> {
ReportingPeriodDialog dialog = new ReportingPeriodDialog(Display.getDefault().getActiveShell(), getReportingPeriod());
if (dialog.open() == ReportingPeriodDialog.OK) {
reportingPeriod = dialog.getReportingPeriod();
if (!delegate.getDashboardData().getDefaultReportingPeriods().contains(reportingPeriod))
delegate.getDashboardData().getDefaultReportingPeriods().add(reportingPeriod);
delegate.getWidget().getConfiguration().put(Dashboard.Config.REPORTING_PERIOD.name(), reportingPeriod.getCode());
delegate.getClient().markDirty();
}
}));
manager.add(subMenu);
}
Aggregations