use of org.eclipse.jface.layout.TableColumnLayout in project yamcs-studio by yamcs.
the class SwitchProcessorDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
var area = (Composite) super.createDialogArea(parent);
var composite = new Composite(area, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout());
var tableWrapper = new Composite(composite, SWT.NONE);
var tcl = new TableColumnLayout();
tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper.setLayout(tcl);
processorsTable = new TableViewer(tableWrapper, SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
processorsTable.getTable().setHeaderVisible(true);
processorsTable.getTable().setLinesVisible(true);
var instanceColumn = new TableViewerColumn(processorsTable, SWT.NONE);
instanceColumn.getColumn().setText("Instance");
instanceColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var info = (ProcessorInfo) element;
return info.getInstance();
}
});
tcl.setColumnData(instanceColumn.getColumn(), new ColumnPixelData(100));
var nameColumn = new TableViewerColumn(processorsTable, SWT.NONE);
nameColumn.getColumn().setText("Processor");
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var info = (ProcessorInfo) element;
return info.getName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(100));
var typeColumn = new TableViewerColumn(processorsTable, SWT.NONE);
typeColumn.getColumn().setText("Type");
typeColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var info = (ProcessorInfo) element;
return info.getType();
}
});
tcl.setColumnData(typeColumn.getColumn(), new ColumnPixelData(100));
processorsTable.setContentProvider(ArrayContentProvider.getInstance());
processorsTable.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
processorsTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 == null || e2 == null) {
return 0;
}
var p1 = (ProcessorInfo) e1;
var p2 = (ProcessorInfo) e2;
var c = p1.getInstance().compareTo(p2.getInstance());
return (c != 0) ? c : p1.getName().compareTo(p2.getName());
}
});
processorsTable.addSelectionChangedListener(event -> {
var okButton = getButton(IDialogConstants.OK_ID);
okButton.setEnabled(!event.getSelection().isEmpty());
});
var client = YamcsPlugin.getYamcsClient();
var filter = new InstanceFilter();
filter.setState(InstanceState.RUNNING);
client.listInstances(filter).whenComplete((response, exc) -> {
parent.getDisplay().asyncExec(() -> {
if (exc == null) {
var processors = new ArrayList<ProcessorInfo>();
for (var instance : response.getInstancesList()) {
processors.addAll(instance.getProcessorsList());
}
processorsTable.setInput(processors);
}
});
});
return composite;
}
use of org.eclipse.jface.layout.TableColumnLayout in project yamcs-studio by yamcs.
the class PredefinedFontsFieldEditor method createTableControl.
private void createTableControl(Composite parent) {
var tableWrapper = new Composite(parent, SWT.NONE);
tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
var tcl = new TableColumnLayout();
tableWrapper.setLayout(tcl);
tableViewer = new TableViewer(tableWrapper, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.getTable().setHeaderVisible(true);
tableViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
var f1 = (OPIFont) e1;
var f2 = (OPIFont) e2;
return f1.getFontMacroName().compareToIgnoreCase(f2.getFontMacroName());
}
});
var textColumn = new TableViewerColumn(tableViewer, SWT.NONE);
textColumn.getColumn().setText("Name");
textColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var font = (OPIFont) element;
return font.getFontMacroName();
}
});
tcl.setColumnData(textColumn.getColumn(), new ColumnWeightData(100, true));
var descColumn = new TableViewerColumn(tableViewer, SWT.NONE);
descColumn.getColumn().setText("Font");
descColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var font = (OPIFont) element;
return StringConverter.asString(font.getRawFontData());
}
});
tcl.setColumnData(descColumn.getColumn(), new ColumnWeightData(200, true));
tableViewer.getTable().addListener(SWT.Selection, evt -> {
updatePreviewFont();
updateButtonStatus();
});
tableViewer.getTable().addListener(SWT.MouseDoubleClick, e -> {
var item = tableViewer.getTable().getItem(new Point(e.x, e.y));
if (item == null) {
return;
}
var bounds = item.getBounds();
var isClickOnCheckbox = e.x < bounds.x;
if (isClickOnCheckbox) {
return;
}
var selectedFont = getSelectedFont();
editFont(selectedFont);
updatePreviewFont();
updateButtonStatus();
});
}
use of org.eclipse.jface.layout.TableColumnLayout in project yamcs-studio by yamcs.
the class PredefinedColorsFieldEditor method createTableControl.
private void createTableControl(Composite parent) {
var tableWrapper = new Composite(parent, SWT.NONE);
tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
var tcl = new TableColumnLayout();
tableWrapper.setLayout(tcl);
tableViewer = new TableViewer(tableWrapper, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
var c1 = (NamedColor) e1;
var c2 = (NamedColor) e2;
return c1.name.compareToIgnoreCase(c2.name);
}
});
var colorColumn = new TableViewerColumn(tableViewer, SWT.NONE);
colorColumn.setLabelProvider(new ColorLabelProvider() {
@Override
public Color getColor(Object element) {
var color = (NamedColor) element;
return colorCache.computeIfAbsent(color.rgb, resourceManager::createColor);
}
@Override
public Color getBorderColor(Object element) {
return parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
}
});
tcl.setColumnData(colorColumn.getColumn(), new ColumnWeightData(50, 50, false));
var textColumn = new TableViewerColumn(tableViewer, SWT.NONE);
textColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
var color = (NamedColor) element;
return color.name;
}
});
tcl.setColumnData(textColumn.getColumn(), new ColumnWeightData(200, 200, true));
tableViewer.getTable().addListener(SWT.Selection, evt -> updateButtonStatus());
tableViewer.getTable().addListener(SWT.MouseDoubleClick, e -> {
var item = tableViewer.getTable().getItem(new Point(e.x, e.y));
if (item == null) {
return;
}
var bounds = item.getBounds();
var isClickOnCheckbox = e.x < bounds.x;
if (isClickOnCheckbox) {
return;
}
var selectedRule = getSelectedColor();
editColor(selectedRule);
updateButtonStatus();
});
}
use of org.eclipse.jface.layout.TableColumnLayout in project yamcs-studio by yamcs.
the class LinksView method createPartControl.
@Override
public void createPartControl(Composite parent) {
var tableWrapper = new Composite(parent, SWT.NONE);
tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
var tcl = new TableColumnLayout();
tableWrapper.setLayout(tcl);
tableViewer = new LinkTableViewer(tableWrapper, tcl);
contentProvider = new LinkTableViewerContentProvider(tableViewer);
tableViewer.setContentProvider(contentProvider);
tableViewer.setInput(contentProvider);
tableViewer.getTable().addListener(SWT.MouseDown, evt -> {
// broke the popup menu for me.
if (tableViewer.getCell(new Point(evt.x, evt.y)) == null) {
tableViewer.getTable().deselectAll();
}
});
if (getViewSite() != null) {
getViewSite().setSelectionProvider(tableViewer);
}
// Set initial state
tableViewer.refresh();
YamcsPlugin.addListener(this);
}
use of org.eclipse.jface.layout.TableColumnLayout in project hale by halestudio.
the class LookupTablePage method addPreview.
// add table for the preview to the given composite
private void addPreview(Composite page) {
tableContainer = new Composite(page, SWT.NONE);
tableContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TableColumnLayout layout = new TableColumnLayout();
tableContainer.setLayout(layout);
tableViewer = new TableViewer(tableContainer, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
tableViewer.getTable().setLinesVisible(true);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
sourceColumn = new TableViewerColumn(tableViewer, SWT.NONE);
layout.setColumnData(sourceColumn.getColumn(), new ColumnWeightData(1));
sourceColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
@SuppressWarnings("unchecked") Entry<Value, Value> entry = (Entry<Value, Value>) element;
return entry.getKey().getStringRepresentation();
}
});
targetColumn = new TableViewerColumn(tableViewer, SWT.NONE);
layout.setColumnData(targetColumn.getColumn(), new ColumnWeightData(1));
targetColumn.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
@SuppressWarnings("unchecked") Entry<Value, Value> entry = (Entry<Value, Value>) cell.getElement();
if (entry.getValue() == null) {
StyledString styledString = new StyledString("(unmapped)", StyledString.DECORATIONS_STYLER);
cell.setText(styledString.getString());
cell.setStyleRanges(styledString.getStyleRanges());
} else {
cell.setText(entry.getValue().getStringRepresentation());
cell.setStyleRanges(null);
}
super.update(cell);
}
});
}
Aggregations