use of org.eclipse.jface.viewers.ColumnWeightData in project yamcs-studio by yamcs.
the class SwitchProcessorDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(area, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout());
Composite tableWrapper = new Composite(composite, SWT.NONE);
TableColumnLayout 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);
TableViewerColumn instanceColumn = new TableViewerColumn(processorsTable, SWT.NONE);
instanceColumn.getColumn().setText("Instance");
instanceColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ProcessorInfo info = (ProcessorInfo) element;
return info.getInstance();
}
});
tcl.setColumnData(instanceColumn.getColumn(), new ColumnPixelData(100));
TableViewerColumn nameColumn = new TableViewerColumn(processorsTable, SWT.NONE);
nameColumn.getColumn().setText("Processor");
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ProcessorInfo info = (ProcessorInfo) element;
return info.getName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(100));
TableViewerColumn typeColumn = new TableViewerColumn(processorsTable, SWT.NONE);
typeColumn.getColumn().setText("Type");
typeColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ProcessorInfo 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;
ProcessorInfo p1 = (ProcessorInfo) e1;
ProcessorInfo p2 = (ProcessorInfo) e2;
int c = p1.getInstance().compareTo(p2.getInstance());
return (c != 0) ? c : p1.getName().compareTo(p2.getName());
}
});
ManagementCatalogue catalogue = ManagementCatalogue.getInstance();
processorsTable.setInput(catalogue.getProcessors());
return composite;
}
use of org.eclipse.jface.viewers.ColumnWeightData in project yamcs-studio by yamcs.
the class ThemeColorBlock method createMasterPart.
@Override
protected void createMasterPart(IManagedForm managedForm, Composite parent) {
FormToolkit tk = managedForm.getToolkit();
Section section = tk.createSection(parent, Section.NO_TITLE);
section.marginWidth = 10;
section.marginHeight = 5;
Composite client = tk.createComposite(section, SWT.WRAP);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 2;
layout.marginHeight = 2;
client.setLayout(layout);
Composite tableWrapper = tk.createComposite(client, SWT.NONE);
tableWrapper.setLayoutData(new GridData(GridData.FILL_VERTICAL));
TableColumnLayout tcl = new TableColumnLayout();
tableWrapper.setLayout(tcl);
Table t = tk.createTable(tableWrapper, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
t.setHeaderVisible(false);
t.setLinesVisible(false);
tk.paintBordersFor(client);
Composite buttonWrapper = tk.createComposite(client);
buttonWrapper.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
buttonWrapper.setLayout(gl);
Button b = tk.createButton(buttonWrapper, "Add", SWT.PUSH);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
b.setLayoutData(gd);
b = tk.createButton(buttonWrapper, "Remove", SWT.PUSH);
gd = new GridData(GridData.FILL_HORIZONTAL);
b.setLayoutData(gd);
b = tk.createButton(buttonWrapper, "Up", SWT.PUSH);
b.setImage(upImage);
b.setToolTipText("Move Up");
gd = new GridData(GridData.FILL_HORIZONTAL);
b.setLayoutData(gd);
b = tk.createButton(buttonWrapper, "Down", SWT.PUSH);
b.setImage(downImage);
b.setToolTipText("Move Down");
gd = new GridData(GridData.FILL_HORIZONTAL);
b.setLayoutData(gd);
section.setClient(client);
SectionPart spart = new SectionPart(section);
managedForm.addPart(spart);
TableViewer viewer = new TableViewer(t);
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.addSelectionChangedListener(evt -> {
managedForm.fireSelectionChanged(spart, evt.getSelection());
});
TableViewerColumn colorColumn = new TableViewerColumn(viewer, SWT.NONE);
colorColumn.setLabelProvider(new ColorLabelProvider() {
@Override
public Color getColor(Object element) {
ThemeColor color = (ThemeColor) element;
return colorMap.get(color.getRGB());
}
@Override
public Color getBorderColor(Object element) {
return parent.getDisplay().getSystemColor(SWT.COLOR_BLACK);
}
});
tcl.setColumnData(colorColumn.getColumn(), new ColumnWeightData(50, 50, false));
TableViewerColumn textColumn = new TableViewerColumn(viewer, SWT.NONE);
textColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ThemeColor color = (ThemeColor) element;
return color.getLabel();
}
});
tcl.setColumnData(textColumn.getColumn(), new ColumnWeightData(200, 200, true));
viewer.setInput(def.getColors());
}
use of org.eclipse.jface.viewers.ColumnWeightData in project yamcs-studio by yamcs.
the class DataLinkTableViewer method addFixedColumns.
private void addFixedColumns(TableColumnLayout tcl) {
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.LEFT);
nameColumn.getColumn().setText(COL_NAME);
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn typeColumn = new TableViewerColumn(this, SWT.LEFT);
typeColumn.getColumn().setText(COL_TYPE);
tcl.setColumnData(typeColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn specColumn = new TableViewerColumn(this, SWT.LEFT);
specColumn.getColumn().setText(COL_SPEC);
tcl.setColumnData(specColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn streamColumn = new TableViewerColumn(this, SWT.LEFT);
streamColumn.getColumn().setText(COL_STREAM);
tcl.setColumnData(streamColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn statusColumn = new TableViewerColumn(this, SWT.CENTER);
statusColumn.getColumn().setText(COL_STATUS);
tcl.setColumnData(statusColumn.getColumn(), new ColumnWeightData(18));
TableViewerColumn datacount = new TableViewerColumn(this, SWT.RIGHT);
datacount.getColumn().setText(COL_DATACOUNT);
tcl.setColumnData(datacount.getColumn(), new ColumnWeightData(10));
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(nameColumn);
columns.add(typeColumn);
columns.add(specColumn);
columns.add(streamColumn);
columns.add(statusColumn);
columns.add(datacount);
for (TableViewerColumn column : columns) {
// prevent resize to 0
column.getColumn().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (column.getColumn().getWidth() < 5)
column.getColumn().setWidth(5);
}
});
}
}
Aggregations