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))));
}
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();
}
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());
}
});
}
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());
}
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);
}
Aggregations