Search in sources :

Example 1 with Watchlist

use of name.abuchen.portfolio.model.Watchlist in project portfolio by buchen.

the class ClientEditorSidebar method addMoveUpAndDownActions.

private void addMoveUpAndDownActions(Watchlist watchlist, Entry entry, IMenuManager manager) {
    List<Watchlist> list = editor.getClient().getWatchlists();
    int size = list.size();
    int index = list.indexOf(watchlist);
    if (index > 0) {
        manager.add(new Action(Messages.MenuMoveUp) {

            @Override
            public void run() {
                Client client = editor.getClient();
                List<Watchlist> watchlists = client.getWatchlists();
                watchlists.remove(watchlist);
                watchlists.add(index - 1, watchlist);
                client.markDirty();
                entry.moveUp();
                sidebar.layout();
            }
        });
    }
    if (index < size - 1 && size > 1) {
        manager.add(new Action(Messages.MenuMoveDown) {

            @Override
            public void run() {
                Client client = editor.getClient();
                List<Watchlist> watchlists = client.getWatchlists();
                watchlists.remove(watchlist);
                watchlists.add(index + 1, watchlist);
                client.markDirty();
                entry.findNeighbor(SWT.ARROW_DOWN).moveUp();
                sidebar.layout();
            }
        });
    }
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) List(java.util.List) Client(name.abuchen.portfolio.model.Client) Watchlist(name.abuchen.portfolio.model.Watchlist)

Example 2 with Watchlist

use of name.abuchen.portfolio.model.Watchlist in project portfolio by buchen.

the class ClientEditorSidebar method createGeneralDataSection.

private void createGeneralDataSection(final Sidebar sidebar) {
    final Entry section = new Entry(sidebar, Messages.LabelSecurities);
    section.setAction(new Action(Messages.LabelSecurities, Images.PLUS.descriptor()) {

        @Override
        public void run() {
            String name = askWatchlistName(Messages.WatchlistNewLabel);
            if (name == null)
                return;
            Watchlist watchlist = new Watchlist();
            watchlist.setName(name);
            editor.getClient().getWatchlists().add(watchlist);
            editor.markDirty();
            createWatchlistEntry(section, watchlist);
            sidebar.layout();
            scrolledComposite.setMinSize(sidebar.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    });
    allSecurities = new Entry(section, new // $NON-NLS-1$
    ActivateViewAction(// $NON-NLS-1$
    Messages.LabelAllSecurities, // $NON-NLS-1$
    "SecurityList", Images.SECURITY.descriptor()));
    allSecurities.setContextMenu(setAsStartPage);
    for (Watchlist watchlist : editor.getClient().getWatchlists()) createWatchlistEntry(section, watchlist);
}
Also used : Entry(name.abuchen.portfolio.ui.Sidebar.Entry) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Watchlist(name.abuchen.portfolio.model.Watchlist)

Aggregations

Watchlist (name.abuchen.portfolio.model.Watchlist)2 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)2 Action (org.eclipse.jface.action.Action)2 List (java.util.List)1 Client (name.abuchen.portfolio.model.Client)1 Entry (name.abuchen.portfolio.ui.Sidebar.Entry)1