Search in sources :

Example 6 with Entry

use of name.abuchen.portfolio.ui.Sidebar.Entry in project portfolio by buchen.

the class ClientEditorSidebar method createWatchlistEntry.

private void createWatchlistEntry(Entry section, final Watchlist watchlist) {
    Entry entry = new Entry(section, watchlist.getName());
    entry.setAction(new // $NON-NLS-1$
    ActivateViewAction(// $NON-NLS-1$
    watchlist.getName(), // $NON-NLS-1$
    "SecurityList", // $NON-NLS-1$
    watchlist, Images.WATCHLIST.descriptor()));
    entry.setContextMenu((e, m) -> watchlistContextMenuAboutToShow(watchlist, e, m));
    entry.addDropSupport(DND.DROP_MOVE, new Transfer[] { SecurityTransfer.getTransfer() }, new DropTargetAdapter() {

        @Override
        public void drop(DropTargetEvent event) {
            if (SecurityTransfer.getTransfer().isSupportedType(event.currentDataType)) {
                Security security = SecurityTransfer.getTransfer().getSecurity();
                if (security != null) {
                    // a deep copy to the client's securities list
                    if (!editor.getClient().getSecurities().contains(security)) {
                        security = security.deepCopy();
                        editor.getClient().addSecurity(security);
                    }
                    if (!watchlist.getSecurities().contains(security))
                        watchlist.addSecurity(security);
                    editor.markDirty();
                    editor.notifyModelUpdated();
                }
            }
        }
    });
}
Also used : DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Entry(name.abuchen.portfolio.ui.Sidebar.Entry) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) Security(name.abuchen.portfolio.model.Security)

Example 7 with Entry

use of name.abuchen.portfolio.ui.Sidebar.Entry in project portfolio by buchen.

the class ClientEditorSidebar method createMiscSection.

private void createMiscSection(Sidebar sidebar) {
    Entry section = new Entry(sidebar, Messages.ClientEditorLabelGeneralData);
    // $NON-NLS-1$
    new Entry(section, new ActivateViewAction(Messages.LabelConsumerPriceIndex, "ConsumerPriceIndexList")).setContextMenu(setAsStartPage);
    // $NON-NLS-1$
    new Entry(section, new ActivateViewAction(Messages.LabelCurrencies, "ExchangeRatesList")).setContextMenu(setAsStartPage);
    // $NON-NLS-1$
    new Entry(section, new ActivateViewAction(Messages.LabelSettings, "settings.Settings")).setContextMenu(setAsStartPage);
    if (// $NON-NLS-1$ //$NON-NLS-2$
    "yes".equals(System.getProperty("name.abuchen.portfolio.debug")))
        // $NON-NLS-1$ //$NON-NLS-2$
        new Entry(section, new ActivateViewAction("Browser Test", "BrowserTest"));
}
Also used : Entry(name.abuchen.portfolio.ui.Sidebar.Entry)

Example 8 with Entry

use of name.abuchen.portfolio.ui.Sidebar.Entry in project portfolio by buchen.

the class ClientEditorSidebar method createPerformanceSection.

private void createPerformanceSection(Sidebar sidebar) {
    Entry section = new Entry(sidebar, Messages.ClientEditorLabelReports);
    statementOfAssets = new Entry(section, // $NON-NLS-1$
    new ActivateViewAction(Messages.LabelStatementOfAssets, "StatementOfAssets"));
    statementOfAssets.setContextMenu(setAsStartPage);
    new Entry(statementOfAssets, // $NON-NLS-1$
    new ActivateViewAction(Messages.ClientEditorLabelChart, "StatementOfAssetsHistory")).setContextMenu(setAsStartPage);
    // $NON-NLS-1$
    new Entry(statementOfAssets, new ActivateViewAction(Messages.ClientEditorLabelHoldings, "HoldingsPieChart")).setContextMenu(setAsStartPage);
    Entry performance = new Entry(section, // $NON-NLS-1$
    new ActivateViewAction(Messages.ClientEditorLabelPerformance, "dashboard.Dashboard"));
    performance.setContextMenu(setAsStartPage);
    // $NON-NLS-1$
    new Entry(performance, new ActivateViewAction(Messages.ClientEditorPerformanceCalculation, "Performance")).setContextMenu(setAsStartPage);
    // $NON-NLS-1$
    new Entry(performance, new ActivateViewAction(Messages.ClientEditorLabelChart, "PerformanceChart")).setContextMenu(setAsStartPage);
    new Entry(performance, // $NON-NLS-1$
    new ActivateViewAction(Messages.ClientEditorLabelReturnsVolatility, "ReturnsVolatilityChart")).setContextMenu(setAsStartPage);
    // $NON-NLS-1$
    new Entry(performance, new ActivateViewAction(Messages.LabelSecurities, "SecuritiesPerformance")).setContextMenu(setAsStartPage);
    // $NON-NLS-1$
    new Entry(performance, new ActivateViewAction(Messages.LabelDividends, "dividends.Dividends")).setContextMenu(setAsStartPage);
}
Also used : Entry(name.abuchen.portfolio.ui.Sidebar.Entry)

Example 9 with Entry

use of name.abuchen.portfolio.ui.Sidebar.Entry in project portfolio by buchen.

the class ClientEditorSidebar method menuAboutToShow.

public void menuAboutToShow(IMenuManager menuManager) {
    // entries is a flat list of all entries
    MenuManager subMenu = null;
    for (Entry entry : sidebar.getEntries()) {
        int indent = entry.getIndent();
        Action action = entry.getAction();
        if (indent == 0) {
            subMenu = new MenuManager(entry.getLabel());
            menuManager.add(subMenu);
        } else {
            if (subMenu == null || action == null)
                continue;
            // cannot use the original action b/c it will not highlight the selected entry
            // in the sidebar
            // $NON-NLS-1$
            String text = indent > Sidebar.STEP ? "- " + action.getText() : action.getText();
            SimpleAction menuAction = new SimpleAction(text, a -> sidebar.select(entry));
            menuAction.setImageDescriptor(action.getImageDescriptor());
            subMenu.add(menuAction);
        }
    }
}
Also used : Entry(name.abuchen.portfolio.ui.Sidebar.Entry) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Aggregations

Entry (name.abuchen.portfolio.ui.Sidebar.Entry)9 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)3 Action (org.eclipse.jface.action.Action)3 Security (name.abuchen.portfolio.model.Security)1 Taxonomy (name.abuchen.portfolio.model.Taxonomy)1 Watchlist (name.abuchen.portfolio.model.Watchlist)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 DropTargetAdapter (org.eclipse.swt.dnd.DropTargetAdapter)1 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)1