use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.
the class SecuritiesChart method chartConfigAboutToShow.
private void chartConfigAboutToShow(IMenuManager manager) {
for (ChartDetails detail : ChartDetails.values()) {
// $NON-NLS-1$
String buttonDescription = detail.toString().replaceAll(SEPERATOR, "");
Action action = new SimpleAction(buttonDescription, a -> {
boolean isActive = chartConfig.contains(detail);
if (isActive)
chartConfig.remove(detail);
else
chartConfig.add(detail);
client.setProperty(PREF_KEY, // $NON-NLS-1$
String.join(// $NON-NLS-1$
",", chartConfig.stream().map(ChartDetails::name).collect(Collectors.toList())));
updateChart();
});
action.setChecked(chartConfig.contains(detail));
manager.add(action);
if (detail.toString().endsWith(SEPERATOR))
manager.add(new Separator());
}
}
use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.
the class ReturnsVolatilityChartView method addConfigButton.
private void addConfigButton(ToolBar toolBar) {
Action save = new SimpleAction(Messages.MenuSaveChart, a -> configurator.showSaveMenu(getActiveShell()));
save.setImageDescriptor(Images.SAVE.descriptor());
save.setToolTipText(Messages.MenuSaveChart);
new ActionContributionItem(save).fill(toolBar, -1);
Action config = new SimpleAction(Messages.MenuConfigureChart, a -> configurator.showMenu(getActiveShell()));
config.setImageDescriptor(Images.CONFIG.descriptor());
config.setToolTipText(Messages.MenuConfigureChart);
new ActionContributionItem(config).fill(toolBar, -1);
}
use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.
the class AccountListView method addNewButton.
private void addNewButton(ToolBar toolBar) {
SimpleAction.Runnable newAccountAction = a -> {
Account account = new Account();
account.setName(Messages.LabelNoName);
account.setCurrencyCode(getClient().getBaseCurrency());
getClient().addAccount(account);
markDirty();
resetInput();
accounts.editElement(account, 0);
};
AbstractDropDown.create(toolBar, Messages.MenuCreateAccountOrTransaction, Images.PLUS.image(), SWT.NONE, (dd, manager) -> {
manager.add(new SimpleAction(Messages.AccountMenuAdd, newAccountAction));
manager.add(new Separator());
Account account = (Account) accounts.getStructuredSelection().getFirstElement();
new AccountContextMenu(AccountListView.this).menuAboutToShow(manager, account, null);
});
}
use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.
the class DashboardView method addButtons.
@Override
protected void addButtons(ToolBar toolBar) {
super.addButtons(toolBar);
AbstractDropDown.create(toolBar, Messages.MenuConfigureDashboards, Images.SAVE.image(), SWT.NONE, manager -> {
getClient().getDashboards().forEach(d -> {
Action action = new SimpleAction(d.getName(), a -> selectDashboard(d));
action.setChecked(d.equals(dashboard));
manager.add(action);
});
manager.add(new Separator());
manager.add(new SimpleAction(Messages.ConfigurationNew, a -> createNewDashboard(null)));
manager.add(new SimpleAction(Messages.ConfigurationDuplicate, a -> createNewDashboard(dashboard)));
manager.add(new SimpleAction(Messages.ConfigurationRename, a -> renameDashboard(dashboard)));
manager.add(new SimpleAction(Messages.ConfigurationDelete, a -> deleteDashboard(dashboard)));
});
AbstractDropDown.create(toolBar, Messages.MenuConfigureCurrentDashboard, Images.CONFIG.image(), SWT.NONE, manager -> manager.add(new SimpleAction(Messages.MenuNewDashboardColumn, a -> createNewColumn())));
}
use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.
the class DashboardView method buildColumn.
private Composite buildColumn(Composite composite, Dashboard.Column column) {
Composite columnControl = new Composite(composite, SWT.NONE);
columnControl.setBackground(composite.getBackground());
columnControl.setData(column);
GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 0).applyTo(columnControl);
GridDataFactory.fillDefaults().grab(true, true).applyTo(columnControl);
addDropListener(columnControl);
// Each column has an empty composite at the bottom to serve as target
// for the column context menu. A separate composite is needed because
// *all* context menus attached to nested composites are always shown.
Composite filler = new Composite(columnControl, SWT.NONE);
filler.setBackground(columnControl.getBackground());
GridDataFactory.fillDefaults().grab(true, true).applyTo(filler);
columnControl.setData(FILLER_KEY, filler);
new ContextMenu(filler, manager -> {
MenuManager subMenu = new MenuManager(Messages.MenuNewWidget);
for (WidgetFactory type : WidgetFactory.values()) subMenu.add(new SimpleAction(type.getLabel(), a -> addNewWidget(columnControl, type)));
manager.add(subMenu);
manager.add(new Separator());
manager.add(new SimpleAction(Messages.MenuAddNewDashboardColumnLeft, a -> createNewColumn(column, columnControl)));
manager.add(new SimpleAction(Messages.MenuDeleteDashboardColumn, a -> deleteColumn(columnControl)));
}).hook();
return columnControl;
}
Aggregations