use of org.eclipse.jface.layout.TableColumnLayout in project yamcs-studio by yamcs.
the class ConnectionsDialog method createServerPanel.
private Composite createServerPanel(Composite parent, ResourceManager resourceManager) {
Composite serverPanel = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
serverPanel.setLayoutData(gd);
TableColumnLayout tcl = new TableColumnLayout();
serverPanel.setLayout(tcl);
Image serverImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ConnectionsDialog.class, "icons/obj16/server.gif"));
connViewer = new TableViewer(serverPanel, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
connViewer.getTable().setHeaderVisible(true);
connViewer.getTable().setLinesVisible(false);
TableViewerColumn nameColumn = new TableViewerColumn(connViewer, SWT.NONE);
nameColumn.getColumn().setText("Connection Name");
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
return serverImage;
}
@Override
public String getText(Object element) {
YamcsConfiguration conf = (YamcsConfiguration) element;
return conf.getName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(400));
connViewer.setContentProvider(new ArrayContentProvider());
connViewer.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.getFirstElement() != null) {
YamcsConfiguration conf = (YamcsConfiguration) sel.getFirstElement();
yamcsInstanceText.setText(forceString(conf.getInstance()));
yamcsUserText.setText(forceString(conf.getUser()));
yamcsPasswordText.setText(forceString(conf.getPassword()));
savePasswordButton.setSelection(conf.isSavePassword());
yamcsPrimaryHostText.setText(forceString(conf.getPrimaryHost()));
yamcsPrimaryPortText.setText(forceString(conf.getPrimaryPort()));
yamcsFailoverHostText.setText(forceString(conf.getFailoverHost()));
yamcsFailoverPortText.setText(forceString(conf.getFailoverPort()));
nameText.setText(forceString(conf.getName()));
updateState();
}
});
connViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
YamcsConfiguration c1 = (YamcsConfiguration) o1;
YamcsConfiguration c2 = (YamcsConfiguration) o2;
if (c1.getName() != null && c2.getName() != null)
return c1.getName().compareTo(c2.getName());
else
return 0;
}
});
return serverPanel;
}
use of org.eclipse.jface.layout.TableColumnLayout 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.layout.TableColumnLayout in project yamcs-studio by yamcs.
the class DataLinkView method createPartControl.
@Override
public void createPartControl(Composite parent) {
Composite tableWrapper = new Composite(parent, SWT.NONE);
tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
TableColumnLayout tcl = new TableColumnLayout();
tableWrapper.setLayout(tcl);
tableViewer = new DataLinkTableViewer(tableWrapper, tcl);
contentProvider = new DataLinkTableViewerContentProvider(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();
LinkCatalogue.getInstance().addLinkListener(this);
YamcsPlugin.getDefault().addYamcsConnectionListener(this);
ManagementCatalogue.getInstance().addInstanceListener(this);
}
use of org.eclipse.jface.layout.TableColumnLayout in project org.csstudio.display.builder by kasemir.
the class SampleView method doCreatePartControl.
/**
* {@inheritDoc}
*/
@Override
protected void doCreatePartControl(final Composite parent) {
final GridLayout layout = new GridLayout(3, false);
parent.setLayout(layout);
// Item: pvs [Refresh]
Label l = new Label(parent, 0);
l.setText(Messages.SampleView_Item);
l.setLayoutData(new GridData());
items = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
items.setLayoutData(new GridData(SWT.FILL, 0, true, false));
items.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(final SelectionEvent e) {
widgetDefaultSelected(e);
}
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Configure table to display samples of the selected model item
if (items.getSelectionIndex() == 0) {
sample_table.setInput(null);
return;
}
// / Skip initial "Select item" entry
final int selected = items.getSelectionIndex() - 1;
int index = 0;
for (ModelItem item : model.getItems()) {
if (index == selected) {
sample_table.setInput(item);
return;
}
++index;
}
Activator.getLogger().log(Level.WARNING, "Invalid item index " + selected);
}
});
final Button refresh = new Button(parent, SWT.PUSH);
refresh.setText(Messages.SampleView_Refresh);
refresh.setToolTipText(Messages.SampleView_RefreshTT);
refresh.setLayoutData(new GridData());
refresh.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
// Trigger GUI update
update(false);
}
});
// Sample Table
// TableColumnLayout requires this to be in its own container
final Composite table_parent = new Composite(parent, 0);
table_parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
table_parent.setLayout(table_layout);
sample_table = new TableViewer(table_parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
sample_table.setContentProvider(new SampleTableContentProvider());
final Table table = sample_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
// Time column
TableViewerColumn col = TableHelper.createColumn(table_layout, sample_table, Messages.TimeColumn, 90, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
cell.setText(TimestampHelper.format(sample.getPosition()));
}
});
// Value column
col = TableHelper.createColumn(table_layout, sample_table, Messages.ValueColumn, 50, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
cell.setText(format.format(sample.getVType()));
}
@Override
public String getToolTipText(Object element) {
final PlotSample sample = (PlotSample) element;
final VType value = sample.getVType();
// Show numbers in their 'natural' format which may differ from the Display settings
if (value instanceof VStatistics) {
final VStatistics mmd = (VStatistics) value;
return NLS.bind(Messages.SampleView_MinMaxValueTT, new String[] { Double.toString(mmd.getAverage()), Double.toString(mmd.getMin()), Double.toString(mmd.getMax()) });
} else if (value instanceof VNumber) {
final VNumber dbl = (VNumber) value;
return Double.toString(dbl.getValue().doubleValue());
} else
return VTypeHelper.toString(value);
}
});
// Severity column
col = TableHelper.createColumn(table_layout, sample_table, Messages.SeverityColumn, 90, 50);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
final VType value = sample.getVType();
final AlarmSeverity severity = VTypeHelper.getSeverity(value);
cell.setText(severity.toString());
if (severity == AlarmSeverity.NONE) {
cell.setBackground(null);
return;
}
final Display display = cell.getControl().getDisplay();
if (severity == AlarmSeverity.MAJOR)
cell.setBackground(display.getSystemColor(SWT.COLOR_RED));
else if (severity == AlarmSeverity.MINOR)
cell.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
else
cell.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
}
});
// Status column
col = TableHelper.createColumn(table_layout, sample_table, Messages.StatusColumn, 90, 50);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
final VType value = sample.getVType();
cell.setText(VTypeHelper.getMessage(value));
}
});
// Sample Source column
col = TableHelper.createColumn(table_layout, sample_table, Messages.SampleView_Source, 90, 10);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final PlotSample sample = (PlotSample) cell.getElement();
cell.setText(sample.getSource());
}
});
ColumnViewerToolTipSupport.enableFor(sample_table);
// Be ignorant of any change of the current model after this view
// is disposed.
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (model != null)
model.removeListener(model_listener);
}
});
}
use of org.eclipse.jface.layout.TableColumnLayout in project org.csstudio.display.builder by kasemir.
the class ArchiveListGUI method createGUI.
/**
* Create GUI elements
* @param parent Parent widget
*/
private void createGUI(final Composite parent) {
final GridLayout layout = new GridLayout(3, false);
parent.setLayout(layout);
// URL: ___urls___ [info]
Label l;
l = new Label(parent, 0);
l.setText(Messages.Search_URL);
l.setLayoutData(new GridData());
urls = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
urls.setToolTipText(Messages.Search_URL_TT);
for (ArchiveServerURL url : server_urls) urls.add(url.getDisplayName());
urls.setLayoutData(new GridData(SWT.FILL, 0, true, false));
if (urls.getItemCount() <= 0) {
urls.add(Messages.ArchiveListGUI_NoArchives);
urls.setEnabled(false);
}
urls.select(0);
info = new Button(parent, SWT.PUSH);
info.setText(Messages.ArchiveServerInfo);
info.setToolTipText(Messages.ArchiveServerInfoTT);
info.setEnabled(false);
// Table for archives, displaying array of ArchiveDataSource entries
// TableColumnLayout requires table in its own container
final Composite table_parent = new Composite(parent, 0);
table_parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, layout.numColumns, 1));
final TableColumnLayout table_layout = new MinSizeTableColumnLayout(10);
table_parent.setLayout(table_layout);
archive_table = new TableViewer(table_parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
archive_table.setContentProvider(new ArrayContentProvider());
TableViewerColumn col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveName, 150, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(archive.getName());
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getName().compareTo(item2.getName());
}
};
col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveDescription, 50, 100);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(archive.getDescription());
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getDescription().compareTo(item2.getDescription());
}
};
col = TableHelper.createColumn(table_layout, archive_table, Messages.ArchiveKey, 35, 5);
col.setLabelProvider(new CellLabelProvider() {
@Override
public void update(final ViewerCell cell) {
final ArchiveDataSource archive = (ArchiveDataSource) cell.getElement();
cell.setText(Integer.toString(archive.getKey()));
}
});
new TableColumnSortHelper<ArchiveDataSource>(archive_table, col) {
@Override
public int compare(final ArchiveDataSource item1, final ArchiveDataSource item2) {
return item1.getKey() - item2.getKey();
}
};
final Table table = archive_table.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
}
Aggregations