use of org.eclipse.jface.viewers.ColumnPixelData in project yamcs-studio by yamcs.
the class PVTupleTableEditor method createPVTupleListTableViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createPVTupleListTableViewer(Composite parent, TableColumnLayout tcl) {
var viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
var numColumn = new TableViewerColumn(viewer, SWT.NONE);
numColumn.getColumn().setText("#");
tcl.setColumnData(numColumn.getColumn(), new ColumnPixelData(50));
var pvColumn = new TableViewerColumn(viewer, SWT.NONE);
pvColumn.getColumn().setText("PV Name");
tcl.setColumnData(pvColumn.getColumn(), new ColumnWeightData(50));
pvColumn.setEditingSupport(new PVColumnEditingSupport(viewer, viewer.getTable()));
var trigColumn = new TableViewerColumn(viewer, SWT.NONE);
trigColumn.getColumn().setText("Trigger");
tcl.setColumnData(trigColumn.getColumn(), new ColumnPixelData(50));
trigColumn.setEditingSupport(new TriggerColumnEditingSupport(viewer, viewer.getTable()));
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new PVTupleLabelProvider(pvTupleList));
viewer.addSelectionChangedListener(event -> refreshToolbarOnSelection());
viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
var target = new DropTarget(viewer.getControl(), DND.DROP_MOVE | DND.DROP_COPY);
target.setTransfer(new Transfer[] { TextTransfer.getInstance() });
target.addDropListener(new DropTargetListener() {
@Override
public void dragEnter(DropTargetEvent event) {
}
@Override
public void dragLeave(DropTargetEvent event) {
}
@Override
public void dragOperationChanged(DropTargetEvent event) {
}
@Override
public void dragOver(DropTargetEvent event) {
}
@Override
public void drop(DropTargetEvent event) {
if (event == null || !(event.data instanceof String)) {
return;
}
var txt = (String) event.data;
var names = txt.split("[\r\n]+");
var tuples = new PVTuple[names.length];
var i = 0;
for (var name : names) {
tuples[i] = new PVTuple(name, true);
pvTupleList.add(tuples[i]);
i++;
}
refreshTableViewerFromAction(tuples);
}
@Override
public void dropAccept(DropTargetEvent event) {
}
});
return viewer;
}
Aggregations