use of name.abuchen.portfolio.ui.util.ContextMenu in project portfolio by buchen.
the class DashboardView method buildDelegate.
private WidgetDelegate buildDelegate(Composite columnControl, WidgetFactory widgetType, Dashboard.Widget widget) {
WidgetDelegate delegate = widgetType.create(widget, dashboardData);
Composite element = delegate.createControl(columnControl, resources);
element.setData(widget);
element.setData(DELEGATE_KEY, delegate);
Composite filler = (Composite) columnControl.getData(FILLER_KEY);
element.moveAbove(filler);
new ContextMenu(delegate.getTitleControl(), manager -> widgetMenuAboutToShow(manager, delegate)).hook();
InfoToolTip.attach(delegate.getTitleControl(), () -> buildToolTip(delegate));
addDragListener(element);
addDropListener(element);
for (Control child : element.getChildren()) addDragListener(child);
GridDataFactory.fillDefaults().grab(true, false).applyTo(element);
return delegate;
}
use of name.abuchen.portfolio.ui.util.ContextMenu in project portfolio by buchen.
the class DashboardView method buildColumn.
private Composite buildColumn(Composite composite, Dashboard.Column column) {
Composite columnControl = new Composite(composite, SWT.NONE);
columnControl.setBackground(composite.getBackground());
columnControl.setData(column);
GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 0).applyTo(columnControl);
GridDataFactory.fillDefaults().grab(true, true).applyTo(columnControl);
addDropListener(columnControl);
// Each column has an empty composite at the bottom to serve as target
// for the column context menu. A separate composite is needed because
// *all* context menus attached to nested composites are always shown.
Composite filler = new Composite(columnControl, SWT.NONE);
filler.setBackground(columnControl.getBackground());
GridDataFactory.fillDefaults().grab(true, true).applyTo(filler);
columnControl.setData(FILLER_KEY, filler);
new ContextMenu(filler, manager -> {
MenuManager subMenu = new MenuManager(Messages.MenuNewWidget);
for (WidgetFactory type : WidgetFactory.values()) subMenu.add(new SimpleAction(type.getLabel(), a -> addNewWidget(columnControl, type)));
manager.add(subMenu);
manager.add(new Separator());
manager.add(new SimpleAction(Messages.MenuAddNewDashboardColumnLeft, a -> createNewColumn(column, columnControl)));
manager.add(new SimpleAction(Messages.MenuDeleteDashboardColumn, a -> deleteColumn(columnControl)));
}).hook();
return columnControl;
}
use of name.abuchen.portfolio.ui.util.ContextMenu in project portfolio by buchen.
the class BookmarksListTab method createTab.
@Override
public CTabItem createTab(CTabFolder folder) {
Composite container = new Composite(folder, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
bookmarks = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
ColumnEditingSupport.prepare(bookmarks);
ShowHideColumnHelper support = new // $NON-NLS-1$
ShowHideColumnHelper(// $NON-NLS-1$
BookmarksListTab.class.getSimpleName() + "@bottom", preferences, bookmarks, layout);
// Create Column for Bookmark
Column column = new Column(Messages.BookmarksListView_bookmark, SWT.None, 150);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Bookmark) element).getLabel();
}
@Override
public Image getImage(Object element) {
return Images.TEXT.image();
}
});
// $NON-NLS-1$
new StringEditingSupport(Bookmark.class, "label").addListener(this).attachTo(column);
support.addColumn(column);
// Create Column for URL
column = new Column(Messages.BookmarksListView_url, SWT.None, 500);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((Bookmark) element).getPattern();
}
});
// $NON-NLS-1$
new StringEditingSupport(Bookmark.class, "pattern").addListener(this).attachTo(column);
support.addColumn(column);
support.createColumns();
bookmarks.getTable().setHeaderVisible(true);
bookmarks.getTable().setLinesVisible(true);
bookmarks.setContentProvider(ArrayContentProvider.getInstance());
bookmarks.setInput(client.getSettings().getBookmarks());
bookmarks.refresh();
new ContextMenu(bookmarks.getTable(), this::fillContextMenu).hook();
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.BookmarksListView_title);
item.setControl(container);
return item;
}
use of name.abuchen.portfolio.ui.util.ContextMenu 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.util.ContextMenu in project portfolio by buchen.
the class EditReportingPeriodsDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
Composite tableArea = new Composite(container, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).minSize(SWT.DEFAULT, 200).applyTo(tableArea);
TableColumnLayout layout = new TableColumnLayout();
tableArea.setLayout(layout);
tableViewer = new TableViewer(tableArea, SWT.BORDER | SWT.MULTI | SWT.MULTI);
final Table table = tableViewer.getTable();
table.setHeaderVisible(false);
table.setLinesVisible(false);
TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.None);
layout.setColumnData(column.getColumn(), new ColumnWeightData(100));
tableViewer.setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
return Images.TEXT.image();
}
});
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.setInput(periods);
new ContextMenu(tableViewer.getTable(), m -> fillContextMenu(m)).hook();
return container;
}
Aggregations