Search in sources :

Example 1 with Dashboard

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())));
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) DND(org.eclipse.swt.dnd.DND) ToolBar(org.eclipse.swt.widgets.ToolBar) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Inject(javax.inject.Inject) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) AbstractHistoricView(name.abuchen.portfolio.ui.views.AbstractHistoricView) DragSource(org.eclipse.swt.dnd.DragSource) InfoToolTip(name.abuchen.portfolio.ui.util.InfoToolTip) DropTarget(org.eclipse.swt.dnd.DropTarget) Separator(org.eclipse.jface.action.Separator) Dashboard(name.abuchen.portfolio.model.Dashboard) MenuManager(org.eclipse.jface.action.MenuManager) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) Transfer(org.eclipse.swt.dnd.Transfer) Consumer(java.util.function.Consumer) IMenuManager(org.eclipse.jface.action.IMenuManager) StringJoiner(java.util.StringJoiner) SWT(org.eclipse.swt.SWT) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) Control(org.eclipse.swt.widgets.Control) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Example 2 with Dashboard

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Dashboard(name.abuchen.portfolio.model.Dashboard) Point(org.eclipse.swt.graphics.Point)

Example 3 with Dashboard

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);
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) Dashboard(name.abuchen.portfolio.model.Dashboard)

Example 4 with Dashboard

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;
}
Also used : Dashboard(name.abuchen.portfolio.model.Dashboard)

Aggregations

Dashboard (name.abuchen.portfolio.model.Dashboard)4 InputDialog (org.eclipse.jface.dialogs.InputDialog)2 Point (org.eclipse.swt.graphics.Point)2 Composite (org.eclipse.swt.widgets.Composite)2 StringJoiner (java.util.StringJoiner)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Images (name.abuchen.portfolio.ui.Images)1 Messages (name.abuchen.portfolio.ui.Messages)1 AbstractDropDown (name.abuchen.portfolio.ui.util.AbstractDropDown)1 ContextMenu (name.abuchen.portfolio.ui.util.ContextMenu)1 InfoToolTip (name.abuchen.portfolio.ui.util.InfoToolTip)1 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)1 AbstractHistoricView (name.abuchen.portfolio.ui.views.AbstractHistoricView)1 Action (org.eclipse.jface.action.Action)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 GridDataFactory (org.eclipse.jface.layout.GridDataFactory)1