use of name.abuchen.portfolio.model.Dashboard 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.model.Dashboard in project portfolio by buchen.
the class DashboardView method createBody.
@Override
protected Control createBody(Composite parent) {
resources = new DashboardResources(parent);
dashboardData = make(DashboardData.class);
dashboardData.setDefaultReportingPeriods(getReportingPeriods());
dashboardData.setDefaultReportingPeriod(getReportingPeriod());
int indexOfSelectedDashboard = Math.max(0, preferences.getInt(SELECTED_DASHBOARD_KEY));
dashboard = //
getClient().getDashboards().skip(//
indexOfSelectedDashboard).findFirst().orElseGet(() -> {
Dashboard newDashboard = createDefaultDashboard();
getClient().addDashboard(newDashboard);
markDirty();
return newDashboard;
});
container = new Composite(parent, SWT.NONE);
container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
selectDashboard(dashboard);
container.addDisposeListener(e -> preferences.setValue(SELECTED_DASHBOARD_KEY, getClient().getDashboards().collect(Collectors.toList()).indexOf(dashboard)));
return container;
}
use of name.abuchen.portfolio.model.Dashboard in project portfolio by buchen.
the class DashboardView method createNewDashboard.
private void createNewDashboard(Dashboard template) {
Dashboard newDashboard = template != null ? template.copy() : createDefaultDashboard();
InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.MenuRenameDashboard, Messages.ColumnName, newDashboard.getName(), null);
if (dialog.open() != InputDialog.OK)
return;
newDashboard.setName(dialog.getValue());
getClient().addDashboard(newDashboard);
markDirty();
selectDashboard(newDashboard);
}
use of name.abuchen.portfolio.model.Dashboard in project portfolio by buchen.
the class DashboardView method createDefaultDashboard.
private Dashboard createDefaultDashboard() {
Dashboard newDashboard = new Dashboard();
newDashboard.setName(Messages.LabelDashboard);
// $NON-NLS-1$
newDashboard.getConfiguration().put(Dashboard.Config.REPORTING_PERIOD.name(), "L1Y0");
Dashboard.Column column = new Dashboard.Column();
newDashboard.getColumns().add(column);
Dashboard.Widget widget = new Dashboard.Widget();
widget.setType(WidgetFactory.HEADING.name());
widget.setLabel(Messages.LabelKeyIndicators);
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.TTWROR.name());
widget.setLabel(WidgetFactory.TTWROR.getLabel());
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.IRR.name());
widget.setLabel(WidgetFactory.IRR.getLabel());
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.ABSOLUTE_CHANGE.name());
widget.setLabel(WidgetFactory.ABSOLUTE_CHANGE.getLabel());
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.DELTA.name());
widget.setLabel(WidgetFactory.DELTA.getLabel());
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.HEADING.name());
widget.setLabel(Messages.LabelTTWROROneDay);
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.TTWROR.name());
widget.setLabel(WidgetFactory.TTWROR.getLabel());
// $NON-NLS-1$
widget.getConfiguration().put(Dashboard.Config.REPORTING_PERIOD.name(), "T1");
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.ABSOLUTE_CHANGE.name());
widget.setLabel(WidgetFactory.ABSOLUTE_CHANGE.getLabel());
// $NON-NLS-1$
widget.getConfiguration().put(Dashboard.Config.REPORTING_PERIOD.name(), "T1");
column.getWidgets().add(widget);
column = new Dashboard.Column();
newDashboard.getColumns().add(column);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.HEADING.name());
widget.setLabel(Messages.LabelRiskIndicators);
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.MAXDRAWDOWN.name());
widget.setLabel(WidgetFactory.MAXDRAWDOWN.getLabel());
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.MAXDRAWDOWNDURATION.name());
widget.setLabel(WidgetFactory.MAXDRAWDOWNDURATION.getLabel());
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.VOLATILITY.name());
widget.setLabel(WidgetFactory.VOLATILITY.getLabel());
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.SEMIVOLATILITY.name());
widget.setLabel(WidgetFactory.SEMIVOLATILITY.getLabel());
column.getWidgets().add(widget);
column = new Dashboard.Column();
newDashboard.getColumns().add(column);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.HEADING.name());
widget.setLabel(Messages.PerformanceTabCalculation);
column.getWidgets().add(widget);
widget = new Dashboard.Widget();
widget.setType(WidgetFactory.CALCULATION.name());
widget.setLabel(WidgetFactory.CALCULATION.getLabel());
column.getWidgets().add(widget);
return newDashboard;
}
Aggregations