use of name.abuchen.portfolio.ui.selection.SecuritySelection 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.ui.selection.SecuritySelection in project portfolio by buchen.
the class TransactionsTab method createControl.
@Override
public Control createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
tableViewer = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
TransactionsTab.class.getSimpleName() + "@v2", preferences, tableViewer, layout);
addColumns(support);
support.createColumns();
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLinesVisible(true);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.addSelectionChangedListener(event -> {
TransactionPair<?> tx = ((TransactionPair<?>) ((IStructuredSelection) event.getSelection()).getFirstElement());
if (tx != null && tx.getTransaction().getSecurity() != null)
selectionService.setSelection(new SecuritySelection(model.getClient(), tx.getTransaction().getSecurity()));
});
tableViewer.setInput(model.getTransactions());
model.addUpdateListener(() -> tableViewer.setInput(model.getTransactions()));
return container;
}
use of name.abuchen.portfolio.ui.selection.SecuritySelection in project portfolio by buchen.
the class AbstractNodeTreeViewer method createControl.
@Override
public final Control createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
TreeColumnLayout layout = new TreeColumnLayout();
container.setLayout(layout);
nodeViewer = new TreeViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
ColumnEditingSupport.prepare(nodeViewer);
ColumnViewerToolTipSupport.enableFor(nodeViewer, ToolTip.NO_RECREATE);
support = new ShowHideColumnHelper(getClass().getSimpleName() + '-' + getModel().getTaxonomy().getId(), getPreferenceStore(), nodeViewer, layout);
addColumns(support);
support.createColumns();
nodeViewer.getTree().setHeaderVisible(true);
nodeViewer.getTree().setLinesVisible(true);
nodeViewer.setContentProvider(new ItemContentProvider());
nodeViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { TaxonomyNodeTransfer.getTransfer(), SecurityTransfer.getTransfer() }, new NodeDragListener(nodeViewer));
nodeViewer.addDropSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { TaxonomyNodeTransfer.getTransfer() }, new NodeDropListener(this));
nodeViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
TaxonomyNode node = (TaxonomyNode) element;
for (Predicate<TaxonomyNode> predicate : getModel().getNodeFilters()) if (!predicate.test(node))
return false;
return true;
}
});
nodeViewer.addSelectionChangedListener(event -> {
TaxonomyNode node = ((TaxonomyNode) ((IStructuredSelection) event.getSelection()).getFirstElement());
if (node != null && node.getBackingSecurity() != null)
selectionService.setSelection(new SecuritySelection(getModel().getClient(), node.getBackingSecurity()));
});
nodeViewer.setInput(getModel());
new ContextMenu(nodeViewer.getControl(), this::fillContextMenu).hook();
return container;
}
use of name.abuchen.portfolio.ui.selection.SecuritySelection in project portfolio by buchen.
the class DividendsMatrixTab method createControl.
@Override
public Control createControl(Composite parent) {
LocalResourceManager resources = new LocalResourceManager(JFaceResources.getResources(), parent);
boldFont = resources.createFont(FontDescriptor.createFrom(parent.getFont()).setStyle(SWT.BOLD));
Composite container = new Composite(parent, SWT.NONE);
tableLayout = new TableColumnLayout();
container.setLayout(tableLayout);
tableViewer = new TableViewer(container, SWT.FULL_SELECTION);
ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);
createColumns(tableViewer, tableLayout);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLinesVisible(true);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.addSelectionChangedListener(event -> {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) ((IStructuredSelection) event.getSelection()).getFirstElement()).getVehicle();
if (vehicle != null && vehicle instanceof Security)
selectionService.setSelection(new SecuritySelection(model.getClient(), (Security) vehicle));
});
tableViewer.setInput(model.getAllLines());
for (TableColumn c : tableViewer.getTable().getColumns()) c.pack();
model.addUpdateListener(() -> updateColumns(tableViewer, tableLayout));
return container;
}
Aggregations