use of org.eclipse.jface.viewers.ColumnLabelProvider in project yamcs-studio by yamcs.
the class CommandHistoryView method processCommandHistoryEntry.
public void processCommandHistoryEntry(CommandHistoryEntry cmdhistEntry) {
// Maybe we need to update structure
for (CommandHistoryAttribute attr : cmdhistEntry.getAttrList()) {
if (IGNORED_ATTRIBUTES.contains(attr.getName()))
continue;
String shortName = CommandHistoryRecordContentProvider.toHumanReadableName(attr);
if (!dynamicColumns.contains(shortName)) {
TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.LEFT);
column.getColumn().setText(shortName);
column.getColumn().addSelectionListener(getSelectionAdapter(column.getColumn()));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((CommandHistoryRecord) element).getTextForColumn(shortName, showRelativeTime);
}
@Override
public String getToolTipText(Object element) {
return ((CommandHistoryRecord) element).getTooltipForColumn(shortName);
}
@Override
public Image getImage(Object element) {
String imgLoc = ((CommandHistoryRecord) element).getImageForColumn(shortName);
if (CommandHistoryRecordContentProvider.GREEN.equals(imgLoc))
return greenBubble;
else if (CommandHistoryRecordContentProvider.RED.equals(imgLoc))
return redBubble;
else
return null;
}
});
dynamicColumns.add(shortName);
tableLayout.addColumnData(new ColumnPixelData(90));
column.getColumn().setWidth(90);
column.getColumn().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
checkMinWidth(column.getColumn());
}
});
}
}
// Now add content
tableContentProvider.processCommandHistoryEntry(cmdhistEntry);
updateSummaryLine();
}
use of org.eclipse.jface.viewers.ColumnLabelProvider in project yamcs-studio by yamcs.
the class ArgumentTableViewer method addFixedColumns.
private void addFixedColumns(TableColumnLayout tcl) {
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.NONE);
nameColumn.getColumn().setText(COL_NAME);
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
TelecommandArgument argument = (TelecommandArgument) element;
return argument.getName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(200));
TableViewerColumn valueColumn = new TableViewerColumn(this, SWT.NONE);
valueColumn.getColumn().setText(COL_VALUE);
valueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
TelecommandArgument argument = (TelecommandArgument) element;
return argument.getValue();
}
});
tcl.setColumnData(valueColumn.getColumn(), new ColumnWeightData(200));
}
use of org.eclipse.jface.viewers.ColumnLabelProvider in project yamcs-studio by yamcs.
the class CommandStackTableViewer method addFixedColumns.
private void addFixedColumns(TableColumnLayout tcl) {
Image level1Image = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandStackTableViewer.class, "icons/level1s.png"));
Image level2Image = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandStackTableViewer.class, "icons/level2s.png"));
Image level3Image = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandStackTableViewer.class, "icons/level3s.png"));
Image level4Image = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandStackTableViewer.class, "icons/level4s.png"));
Image level5Image = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandStackTableViewer.class, "icons/level5s.png"));
TableViewerColumn rowIdColumn = new TableViewerColumn(this, SWT.CENTER);
rowIdColumn.getColumn().setText(COL_ROW_ID);
rowIdColumn.getColumn().setToolTipText("Sequence Number within Stack");
rowIdColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return String.valueOf(contentProvider.indexOf(element) + 1);
}
});
rowIdColumn.getColumn().setWidth(50);
tcl.setColumnData(rowIdColumn.getColumn(), new ColumnPixelData(50));
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.NONE);
nameColumn.getColumn().setText(COL_COMMAND);
nameColumn.setLabelProvider(new CommandSourceColumnLabelProvider(styleProvider));
tcl.setColumnData(nameColumn.getColumn(), new ColumnPixelData(300));
TableViewerColumn significanceColumn = new TableViewerColumn(this, SWT.CENTER);
significanceColumn.getColumn().setText(COL_SIGNIFICANCE);
significanceColumn.getColumn().setToolTipText("Significance Level");
significanceColumn.setLabelProvider(new CenteredImageLabelProvider() {
@Override
public Image getImage(Object element) {
StackedCommand cmd = (StackedCommand) element;
if (cmd.getMetaCommand().getSignificance() == null)
return null;
switch(cmd.getMetaCommand().getSignificance().getConsequenceLevel()) {
case WATCH:
return level1Image;
case WARNING:
return level2Image;
case DISTRESS:
return level3Image;
case CRITICAL:
return level4Image;
case SEVERE:
return level5Image;
default:
return null;
}
}
@Override
public String getToolTipText(Object element) {
StackedCommand cmd = (StackedCommand) element;
if (cmd.getMetaCommand().getSignificance() == null)
return super.getToolTipText(element);
return cmd.getMetaCommand().getSignificance().getReasonForWarning();
}
});
significanceColumn.getColumn().setWidth(50);
tcl.setColumnData(significanceColumn.getColumn(), new ColumnPixelData(50));
TableViewerColumn constraintsColumn = new TableViewerColumn(this, SWT.LEFT);
constraintsColumn.getColumn().setText(COL_CONSTRAINTS);
constraintsColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
StackedCommand cmd = (StackedCommand) element;
StringBuilder buf = new StringBuilder();
for (int i = 0; i < cmd.getMetaCommand().getConstraintCount(); i++) {
if (i != 0)
buf.append(" and ");
TransmissionConstraintInfo constraint = cmd.getMetaCommand().getConstraint(i);
for (int j = 0; j < constraint.getComparisonCount(); j++) {
if (j != 0)
buf.append(", ");
appendConstraint(constraint.getComparison(j), buf);
}
}
return buf.length() != 0 ? buf.toString() : "-";
}
});
tcl.setColumnData(constraintsColumn.getColumn(), new ColumnPixelData(250));
TableViewerColumn constraintsTimeOutColumn = new TableViewerColumn(this, SWT.CENTER);
constraintsTimeOutColumn.getColumn().setText(COL_CONSTRAINTS_TIMEOUT);
constraintsTimeOutColumn.getColumn().setToolTipText("Constraints Timeout");
constraintsTimeOutColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
StackedCommand cmd = (StackedCommand) element;
long timeout = -1;
for (TransmissionConstraintInfo constraint : cmd.getMetaCommand().getConstraintList()) timeout = Math.max(timeout, constraint.getTimeout());
return (timeout >= 0) ? Long.toString(timeout) + " ms" : "-";
}
});
tcl.setColumnData(constraintsTimeOutColumn.getColumn(), new ColumnPixelData(50));
TableViewerColumn releaseColumn = new TableViewerColumn(this, SWT.CENTER);
releaseColumn.getColumn().setText(COL_RELEASE);
releaseColumn.getColumn().setToolTipText("Release Time");
releaseColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return "ASAP";
}
});
tcl.setColumnData(releaseColumn.getColumn(), new ColumnPixelData(80));
TableViewerColumn ptvColumn = new TableViewerColumn(this, SWT.CENTER);
ptvColumn.getColumn().setText(COL_PTV);
ptvColumn.getColumn().setToolTipText("Pre-Transmission Verification");
ptvColumn.setLabelProvider(new CenteredImageLabelProvider() {
@Override
public Image getImage(Object element) {
StackedCommand cmd = (StackedCommand) element;
switch(cmd.getPTVInfo().getState()) {
case UNDEF:
return grayBubble;
case NA:
case OK:
return greenBubble;
case PENDING:
return waitingImage;
case NOK:
return redBubble;
default:
log.warning("Unexpected PTV state " + cmd.getPTVInfo().getState());
return grayBubble;
}
}
@Override
public String getToolTipText(Object element) {
StackedCommand cmd = (StackedCommand) element;
if (cmd.getPTVInfo().getFailureMessage() != null)
return cmd.getPTVInfo().getFailureMessage();
else
return super.getToolTipText(element);
}
});
tcl.setColumnData(ptvColumn.getColumn(), new ColumnPixelData(50));
TableViewerColumn stateColumn = new TableViewerColumn(this, SWT.CENTER);
stateColumn.getColumn().setText(COL_STATE);
stateColumn.getColumn().setToolTipText("Stack State");
stateColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
StackedCommand cmd = (StackedCommand) element;
return cmd.getStackedState().getText();
}
@Override
public Color getBackground(Object element) {
StackedCommand cmd = (StackedCommand) element;
if (cmd.isArmed())
return getTable().getDisplay().getSystemColor(SWT.COLOR_YELLOW);
else if (cmd.getStackedState() == StackedState.ISSUED)
return getTable().getDisplay().getSystemColor(SWT.COLOR_GREEN);
else if (cmd.getStackedState() == StackedState.REJECTED)
return styleProvider.getErrorBackgroundColor();
return super.getBackground(element);
}
@Override
public Color getForeground(Object element) {
StackedCommand cmd = (StackedCommand) element;
if (cmd.getStackedState() == StackedState.REJECTED)
return getTable().getDisplay().getSystemColor(SWT.COLOR_RED);
return super.getForeground(element);
}
});
tcl.setColumnData(stateColumn.getColumn(), new ColumnPixelData(80));
// column comment
TableViewerColumn commentColumn = new TableViewerColumn(this, SWT.LEFT);
commentColumn.getColumn().setText(COL_COMMENT);
commentColumn.getColumn().setToolTipText("Free Text Comment");
commentColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((StackedCommand) element).getComment();
}
});
tcl.setColumnData(commentColumn.getColumn(), new ColumnPixelData(80));
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(rowIdColumn);
columns.add(nameColumn);
columns.add(significanceColumn);
columns.add(constraintsColumn);
columns.add(constraintsTimeOutColumn);
columns.add(releaseColumn);
columns.add(ptvColumn);
columns.add(stateColumn);
columns.add(commentColumn);
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);
}
});
}
}
use of org.eclipse.jface.viewers.ColumnLabelProvider 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.viewers.ColumnLabelProvider 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;
}
Aggregations