Search in sources :

Example 1 with ClientSettings

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

the class BookmarksListTab method fillContextMenu.

private void fillContextMenu(IMenuManager manager) {
    Bookmark bookmark = (Bookmark) ((IStructuredSelection) bookmarks.getSelection()).getFirstElement();
    if (bookmark == null)
        return;
    if (!bookmark.isSeparator())
        addTestMenu(manager, bookmark);
    addMoveUpAndDownActions(manager, bookmark);
    manager.add(new Separator());
    manager.add(new Action(Messages.BookmarksListView_insertBefore) {

        @Override
        public void run() {
            Bookmark index = (Bookmark) ((IStructuredSelection) bookmarks.getSelection()).getFirstElement();
            Bookmark wl = new Bookmark(Messages.BookmarksListView_NewBookmark, DEFAULT_URL);
            client.getSettings().insertBookmark(index, wl);
            client.markDirty();
            bookmarks.setInput(client.getSettings().getBookmarks());
            bookmarks.editElement(wl, 0);
        }
    });
    manager.add(new Action(Messages.BookmarksListView_insertAfter) {

        @Override
        public void run() {
            Bookmark index = (Bookmark) ((IStructuredSelection) bookmarks.getSelection()).getFirstElement();
            Bookmark wl = new Bookmark(Messages.BookmarksListView_NewBookmark, DEFAULT_URL);
            client.getSettings().insertBookmarkAfter(index, wl);
            client.markDirty();
            bookmarks.setInput(client.getSettings().getBookmarks());
            bookmarks.editElement(wl, 0);
        }
    });
    manager.add(new Action(Messages.BookmarksListView_addSeparator) {

        @Override
        public void run() {
            Bookmark index = (Bookmark) ((IStructuredSelection) bookmarks.getSelection()).getFirstElement();
            // $NON-NLS-1$ //$NON-NLS-2$
            Bookmark wl = new Bookmark("-", "");
            client.getSettings().insertBookmarkAfter(index, wl);
            client.markDirty();
            bookmarks.setInput(client.getSettings().getBookmarks());
        }
    });
    manager.add(new Separator());
    addSubmenuWithPlaceholders(manager);
    manager.add(new Separator());
    manager.add(new Action(Messages.BookmarksListView_delete) {

        @Override
        public void run() {
            ClientSettings settings = client.getSettings();
            for (Object element : ((IStructuredSelection) bookmarks.getSelection()).toArray()) settings.removeBookmark((Bookmark) element);
            client.markDirty();
            bookmarks.setInput(settings.getBookmarks());
        }
    });
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Bookmark(name.abuchen.portfolio.model.Bookmark) ClientSettings(name.abuchen.portfolio.model.ClientSettings) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator)

Example 2 with ClientSettings

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

the class AttributeListTab method addDeleteActions.

private void addDeleteActions(IMenuManager manager, IStructuredSelection selection) {
    manager.add(new Separator());
    manager.add(new Action(Messages.BookmarksListView_delete) {

        @Override
        public void run() {
            ClientSettings settings = client.getSettings();
            for (Object element : selection.toArray()) {
                AttributeType attribute = (AttributeType) element;
                // remove any existing attribute values from securities
                for (Security security : client.getSecurities()) security.getAttributes().remove(attribute);
                settings.removeAttributeType(attribute);
            }
            client.markDirty();
            tableViewer.setInput(settings.getAttributeTypes().toArray());
        }
    });
}
Also used : Action(org.eclipse.jface.action.Action) AttributeType(name.abuchen.portfolio.model.AttributeType) ClientSettings(name.abuchen.portfolio.model.ClientSettings) Security(name.abuchen.portfolio.model.Security) Separator(org.eclipse.jface.action.Separator)

Aggregations

ClientSettings (name.abuchen.portfolio.model.ClientSettings)2 Action (org.eclipse.jface.action.Action)2 Separator (org.eclipse.jface.action.Separator)2 AttributeType (name.abuchen.portfolio.model.AttributeType)1 Bookmark (name.abuchen.portfolio.model.Bookmark)1 Security (name.abuchen.portfolio.model.Security)1 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1