Search in sources :

Example 6 with Bookmark

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

the class BookmarkMenu method addDefaultPages.

private void addDefaultPages() {
    for (Bookmark bookmark : client.getSettings().getBookmarks()) {
        if (bookmark.isSeparator()) {
            add(new Separator());
        } else {
            add(new SimpleAction(bookmark.getLabel(), a -> DesktopAPI.browse(bookmark.constructURL(client, security))));
        }
    }
    add(new Separator());
    add(new SimpleAction(Messages.BookmarkMenu_EditBookmarks, // $NON-NLS-1$
    a -> editor.activateView("settings.Settings", Integer.valueOf(0))));
}
Also used : Separator(org.eclipse.jface.action.Separator) Client(name.abuchen.portfolio.model.Client) Bookmark(name.abuchen.portfolio.model.Bookmark) Messages(name.abuchen.portfolio.ui.Messages) MenuManager(org.eclipse.jface.action.MenuManager) Security(name.abuchen.portfolio.model.Security) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) Bookmark(name.abuchen.portfolio.model.Bookmark) Separator(org.eclipse.jface.action.Separator)

Example 7 with Bookmark

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

the class OpenBookmarksHandler method execute.

@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, ESelectionService selectionService) {
    Object object = selectionService.getSelection();
    if (!(object instanceof SecuritySelection))
        return;
    SecuritySelection selection = (SecuritySelection) object;
    if (selection.getClient().getSettings().getBookmarks().isEmpty())
        return;
    List<Bookmark> bookmarks = selection.getClient().getSettings().getBookmarks().stream().filter(b -> !b.isSeparator()).collect(Collectors.toList());
    BookmarkPopup<Bookmark> popup = new // 
    BookmarkPopup<>(// 
    shell, // 
    selection.getSecurity().getName(), // 
    bookmarks, // 
    Bookmark::getLabel, bm -> DesktopAPI.browse(bm.constructURL(selection.getClient(), selection.getSecurity())));
    popup.open();
}
Also used : IServiceConstants(org.eclipse.e4.ui.services.IServiceConstants) TableViewer(org.eclipse.jface.viewers.TableViewer) Execute(org.eclipse.e4.core.di.annotations.Execute) Function(java.util.function.Function) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) Named(javax.inject.Named) Shell(org.eclipse.swt.widgets.Shell) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) DesktopAPI(name.abuchen.portfolio.ui.util.DesktopAPI) Collectors(java.util.stream.Collectors) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) Consumer(java.util.function.Consumer) PopupDialog(org.eclipse.jface.dialogs.PopupDialog) List(java.util.List) Bookmark(name.abuchen.portfolio.model.Bookmark) SWT(org.eclipse.swt.SWT) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Control(org.eclipse.swt.widgets.Control) SelectionListener(org.eclipse.swt.events.SelectionListener) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) Bookmark(name.abuchen.portfolio.model.Bookmark) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 8 with Bookmark

use of name.abuchen.portfolio.model.Bookmark 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 9 with Bookmark

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

the class BookmarksListTab method addTestMenu.

private void addTestMenu(IMenuManager manager, Bookmark bookmark) {
    MenuManager securities = new MenuManager(Messages.MenuOpenSecurityOnSite);
    for (Security security : client.getSecurities()) {
        securities.add(new SimpleAction(security.getName(), a -> DesktopAPI.browse(bookmark.constructURL(client, security))));
    }
    manager.add(securities);
    manager.add(new Separator());
}
Also used : ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) Arrays(java.util.Arrays) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Inject(javax.inject.Inject) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Separator(org.eclipse.jface.action.Separator) Shell(org.eclipse.swt.widgets.Shell) CTabFolder(org.eclipse.swt.custom.CTabFolder) MenuManager(org.eclipse.jface.action.MenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) Action(org.eclipse.jface.action.Action) Security(name.abuchen.portfolio.model.Security) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) DesktopAPI(name.abuchen.portfolio.ui.util.DesktopAPI) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) CTabItem(org.eclipse.swt.custom.CTabItem) List(java.util.List) Bookmark(name.abuchen.portfolio.model.Bookmark) IMenuManager(org.eclipse.jface.action.IMenuManager) SWT(org.eclipse.swt.SWT) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ClientSettings(name.abuchen.portfolio.model.ClientSettings) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Security(name.abuchen.portfolio.model.Security) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Example 10 with Bookmark

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

the class BookmarksListTab method showAddMenu.

@Override
public void showAddMenu(Shell shell) {
    Bookmark wl = new Bookmark(Messages.BookmarksListView_NewBookmark, DEFAULT_URL);
    client.getSettings().getBookmarks().add(wl);
    client.markDirty();
    bookmarks.setInput(client.getSettings().getBookmarks());
    bookmarks.editElement(wl, 0);
}
Also used : Bookmark(name.abuchen.portfolio.model.Bookmark)

Aggregations

Bookmark (name.abuchen.portfolio.model.Bookmark)13 Client (name.abuchen.portfolio.model.Client)10 Security (name.abuchen.portfolio.model.Security)10 Test (org.junit.Test)8 Separator (org.eclipse.jface.action.Separator)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 List (java.util.List)2 ClientSettings (name.abuchen.portfolio.model.ClientSettings)2 Messages (name.abuchen.portfolio.ui.Messages)2 DesktopAPI (name.abuchen.portfolio.ui.util.DesktopAPI)2 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)2 Action (org.eclipse.jface.action.Action)2 MenuManager (org.eclipse.jface.action.MenuManager)2 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 SWT (org.eclipse.swt.SWT)2 Composite (org.eclipse.swt.widgets.Composite)2 Shell (org.eclipse.swt.widgets.Shell)2