use of org.csstudio.ui.util.dnd.ControlSystemDragSource in project org.csstudio.display.builder by kasemir.
the class SearchView method configureActions.
/**
* React to selections, button presses, ...
*/
private void configureActions() {
// Start a channel search
search.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
searchForChannels();
}
});
// Channel Table: Allow dragging of PVs with archive
final Table table = channel_table.getTable();
new ControlSystemDragSource(table) {
@Override
public Object getSelection() {
final IStructuredSelection selection = (IStructuredSelection) channel_table.getSelection();
// To allow transfer of array, the data must be
// of the actual array type, not Object[]
final Object[] objs = selection.toArray();
final ChannelInfo[] channels = Arrays.copyOf(objs, objs.length, ChannelInfo[].class);
return channels;
}
};
// Double-clicks should have the same effect as context menu -> Data Browser
getSite().setSelectionProvider(channel_table);
channel_table.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
// casting is needed for RAP
IHandlerService handlerService = getSite().getService(IHandlerService.class);
try {
handlerService.executeCommand("org.csstudio.trends.databrowser3.OpenDataBrowserPopup", null);
} catch (CommandException ex) {
// $NON-NLS-1$
Activator.getLogger().log(Level.WARNING, "Failed to open data browser", ex);
}
}
});
// Add context menu for object contributions
final MenuManager menu = new MenuManager();
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
table.setMenu(menu.createContextMenu(table));
getSite().registerContextMenu(menu, channel_table);
}
use of org.csstudio.ui.util.dnd.ControlSystemDragSource in project org.csstudio.display.builder by kasemir.
the class DataBrowserPropertySheetPage method createTracesTabItemPanel.
/**
* Within SashForm of the "Traces" tab, create the Model Item table
* @param sashform
*/
private void createTracesTabItemPanel(final SashForm sashform) {
// TableColumnLayout requires the TableViewer to be in its own Composite!
final Composite model_item_top = new Composite(sashform, SWT.BORDER);
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
model_item_top.setLayout(table_layout);
// Would like to _not_ use FULL_SELECTION so that only the currently selected
// cell gets highlighted, allowing the 'color' to still be visible
// -> On Linux, you only get FULL_SELECTION behavior.
// -> On Windows, editing is really odd, need to select a column before anything
// can be edited, plus color still invisible
// ---> Using FULL_SELECTION
trace_table = new TableViewer(model_item_top, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = trace_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
final TraceTableHandler tth = new TraceTableHandler();
tth.createColumns(table_layout, operations_manager, trace_table);
trace_table.setContentProvider(tth);
trace_table.setInput(model);
new ControlSystemDragSource(trace_table.getControl()) {
@Override
public Object getSelection() {
final IStructuredSelection selection = (IStructuredSelection) trace_table.getSelection();
final Object[] objs = selection.toArray();
final ModelItem[] items = Arrays.copyOf(objs, objs.length, ModelItem[].class);
return items;
}
};
}
Aggregations