use of org.eclipse.jface.viewers.TableViewerColumn in project yamcs-studio by yamcs.
the class ParameterTableViewer 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(40));
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterInfo cnt = (ParameterInfo) element;
return cnt.getQualifiedName();
}
});
TableViewerColumn engValueColumn = new TableViewerColumn(this, SWT.RIGHT);
engValueColumn.getColumn().setText(COL_ENG);
tcl.setColumnData(engValueColumn.getColumn(), new ColumnWeightData(10));
engValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
return String.valueOf(getValue(value.getEngValue()));
}
});
TableViewerColumn rawValueColumn = new TableViewerColumn(this, SWT.RIGHT);
rawValueColumn.getColumn().setText(COL_RAW);
tcl.setColumnData(rawValueColumn.getColumn(), new ColumnWeightData(10));
rawValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
return String.valueOf(getValue(value.getRawValue()));
}
});
TableViewerColumn gentimeValueColumn = new TableViewerColumn(this, SWT.LEFT);
gentimeValueColumn.getColumn().setText(COL_TIME);
tcl.setColumnData(gentimeValueColumn.getColumn(), new ColumnWeightData(20));
gentimeValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date time = new Date(value.getGenerationTime());
String strDate = sdfDate.format(time);
return strDate;
}
});
TableViewerColumn aqutimeValueColumn = new TableViewerColumn(this, SWT.LEFT);
aqutimeValueColumn.getColumn().setText(COL_AQU_TIME);
tcl.setColumnData(aqutimeValueColumn.getColumn(), new ColumnWeightData(20));
aqutimeValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date time = new Date(value.getAcquisitionTime());
String strDate = sdfDate.format(time);
return strDate;
}
});
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(nameColumn);
columns.add(engValueColumn);
columns.add(rawValueColumn);
columns.add(gentimeValueColumn);
columns.add(aqutimeValueColumn);
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.TableViewerColumn in project yamcs-studio by yamcs.
the class CommandHistoryView method addFixedColumns.
private void addFixedColumns() {
TableViewerColumn stateColumn = new TableViewerColumn(tableViewer, SWT.NONE);
stateColumn.getColumn().setImage(headerCompleteImage);
stateColumn.getColumn().addSelectionListener(getSelectionAdapter(stateColumn.getColumn()));
stateColumn.getColumn().setToolTipText("Completion");
stateColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
switch(((CommandHistoryRecord) element).getCommandState()) {
case COMPLETED:
return checkmarkImage;
case FAILED:
return errorImage;
default:
return null;
}
}
@Override
public String getText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
switch(((CommandHistoryRecord) element).getCommandState()) {
case COMPLETED:
return "Completed";
case FAILED:
return rec.getPTVInfo().getFailureMessage();
default:
return null;
}
}
});
tableLayout.addColumnData(new ColumnPixelData(90));
TableViewerColumn gentimeColumn = new TableViewerColumn(tableViewer, SWT.NONE);
gentimeColumn.getColumn().setText(COL_T);
gentimeColumn.getColumn().addSelectionListener(getSelectionAdapter(gentimeColumn.getColumn()));
gentimeColumn.getColumn().setToolTipText("Generation Time");
gentimeColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((CommandHistoryRecord) element).getGenerationTime();
}
});
tableLayout.addColumnData(new ColumnPixelData(150));
TableViewerColumn nameColumn = new TableViewerColumn(tableViewer, SWT.NONE);
nameColumn.getColumn().setText(COL_COMMAND);
nameColumn.getColumn().setToolTipText("Command String");
nameColumn.getColumn().addSelectionListener(getSelectionAdapter(nameColumn.getColumn()));
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
return rec.getCommandString();
}
});
tableLayout.addColumnData(new ColumnPixelData(500));
TableViewerColumn originColumn = new TableViewerColumn(tableViewer, SWT.NONE);
originColumn.getColumn().setText(COL_SRC);
originColumn.getColumn().setToolTipText("Source (user@origin)");
originColumn.getColumn().addSelectionListener(getSelectionAdapter(originColumn.getColumn()));
originColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
return rec.getUsername() + "@" + rec.getOrigin();
}
});
tableLayout.addColumnData(new ColumnPixelData(200));
TableViewerColumn seqIdColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
seqIdColumn.getColumn().setText(COL_SRC_ID);
seqIdColumn.getColumn().addSelectionListener(getSelectionAdapter(seqIdColumn.getColumn()));
seqIdColumn.getColumn().setToolTipText("Client ID");
seqIdColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return String.valueOf(((CommandHistoryRecord) element).getSequenceNumber());
}
});
tableLayout.addColumnData(new ColumnPixelData(50));
TableViewerColumn ptvColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
ptvColumn.getColumn().setText(COL_PTV);
ptvColumn.getColumn().addSelectionListener(getSelectionAdapter(ptvColumn.getColumn()));
ptvColumn.getColumn().setToolTipText("Pre-Transmission Verification");
ptvColumn.setLabelProvider(new CenteredImageLabelProvider() {
@Override
public Image getImage(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
switch(rec.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 " + rec.getPTVInfo().getState());
return grayBubble;
}
}
@Override
public String getToolTipText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
if (rec.getPTVInfo().getFailureMessage() != null) {
return rec.getPTVInfo().getFailureMessage();
} else {
return super.getToolTipText(element);
}
}
});
tableLayout.addColumnData(new ColumnPixelData(50));
TableViewerColumn finalSeqColumn = new TableViewerColumn(tableViewer, SWT.CENTER);
finalSeqColumn.getColumn().setText(COL_SEQ_ID);
finalSeqColumn.getColumn().addSelectionListener(getSelectionAdapter(finalSeqColumn.getColumn()));
finalSeqColumn.getColumn().setToolTipText("Final Sequence Count");
finalSeqColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandHistoryRecord rec = (CommandHistoryRecord) element;
return (rec.getFinalSequenceCount() != null) ? String.valueOf(rec.getFinalSequenceCount()) : "-";
}
});
tableLayout.addColumnData(new ColumnPixelData(50));
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(gentimeColumn);
columns.add(nameColumn);
columns.add(originColumn);
columns.add(seqIdColumn);
columns.add(ptvColumn);
columns.add(finalSeqColumn);
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) {
checkMinWidth(column.getColumn());
}
});
}
// TODO use IMemento or something
tableViewer.getTable().setSortColumn(gentimeColumn.getColumn());
tableViewer.getTable().setSortDirection(SWT.DOWN);
getViewSite().setSelectionProvider(tableViewer);
}
use of org.eclipse.jface.viewers.TableViewerColumn in project yamcs-studio by yamcs.
the class VerificationStepsTableViewer method addFixedColumns.
private void addFixedColumns(TableLayout tl) {
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.NONE);
nameColumn.getColumn().setText(COL_NAME);
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
VerificationStep step = (VerificationStep) element;
return step.getName();
}
});
tl.addColumnData(new ColumnWeightData(200));
TableViewerColumn statusColumn = new TableViewerColumn(this, SWT.NONE);
statusColumn.getColumn().setText(COL_STATUS);
statusColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
VerificationStep step = (VerificationStep) element;
if (step.getStatus().contains("OK")) {
return commandHistoryView.greenBubble;
} else {
return commandHistoryView.redBubble;
}
}
@Override
public String getText(Object element) {
VerificationStep step = (VerificationStep) element;
return step.getStatus();
}
});
tl.addColumnData(new ColumnWeightData(200));
TableViewerColumn deltaColumn = new TableViewerColumn(this, SWT.NONE);
deltaColumn.getColumn().setText(COL_DELTA);
deltaColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
VerificationStep step = (VerificationStep) element;
return step.getDelta();
}
});
tl.addColumnData(new ColumnWeightData(200));
TableViewerColumn dateColumn = new TableViewerColumn(this, SWT.NONE);
dateColumn.getColumn().setText(COL_DATE);
dateColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
VerificationStep step = (VerificationStep) element;
return step.getTime();
}
});
tl.addColumnData(new ColumnWeightData(200));
}
use of org.eclipse.jface.viewers.TableViewerColumn in project yamcs-studio by yamcs.
the class CommandQueuesTableViewer method addFixedColumns.
private void addFixedColumns(TableColumnLayout tcl) {
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.NONE);
nameColumn.getColumn().setText(COL_QUEUE);
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(40));
TableViewerColumn stateColumn = new TableViewerColumn(this, SWT.CENTER);
stateColumn.getColumn().setText(COL_STATE);
stateColumn.getColumn().setWidth(250);
stateColumn.setEditingSupport(new StateEditingSupport(stateColumn.getViewer()));
tcl.setColumnData(stateColumn.getColumn(), new ColumnWeightData(30));
TableViewerColumn commandsColumn = new TableViewerColumn(this, SWT.CENTER);
commandsColumn.getColumn().setText(COL_COMMANDS);
tcl.setColumnData(commandsColumn.getColumn(), new ColumnWeightData(10));
TableViewerColumn sentColumn = new TableViewerColumn(this, SWT.CENTER);
sentColumn.getColumn().setText(COL_SENT);
tcl.setColumnData(sentColumn.getColumn(), new ColumnWeightData(10));
TableViewerColumn rejectedColumn = new TableViewerColumn(this, SWT.CENTER);
rejectedColumn.getColumn().setText(COL_REJECTED);
tcl.setColumnData(rejectedColumn.getColumn(), new ColumnWeightData(10));
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(nameColumn);
columns.add(stateColumn);
columns.add(commandsColumn);
columns.add(sentColumn);
columns.add(rejectedColumn);
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.TableViewerColumn in project yamcs-studio by yamcs.
the class ArgumentTableBuilder method createArgumentTable.
public TableViewer createArgumentTable(Composite shell) {
Label desc = new Label(shell, SWT.NONE);
desc.setText("Specify the command arguments:");
desc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
TableColumnLayout tcl = new TableColumnLayout();
Composite argumentsComposite = new Composite(shell, SWT.NONE);
argumentsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
argumentsComposite.setLayout(tcl);
argumentTable = new TableViewer(argumentsComposite, SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
Table table = argumentTable.getTable();
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
table.setLayoutData(gridData);
table.setHeaderVisible(true);
table.setLinesVisible(true);
argumentTable.setContentProvider(new ArrayContentProvider());
// create columns
String[] titles = { "Argument", "Eng. Type", "Range", "Value", "Default Value" };
// argument
TableViewerColumn column = createTableViewerColumn(argumentTable, titles[0], 0);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof ArgumentAssignement)
return ((ArgumentAssignement) element).arg.getName();
return super.getText(element);
}
});
tcl.setColumnData(column.getColumn(), new ColumnPixelData(10));
// eng. type
column = createTableViewerColumn(argumentTable, titles[1], 1);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof ArgumentAssignement)
return ((ArgumentAssignement) element).arg.getType().getEngType();
return super.getText(element);
}
});
tcl.setColumnData(column.getColumn(), new ColumnPixelData(10));
// range
column = createTableViewerColumn(argumentTable, titles[2], 2);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof ArgumentAssignement) {
ArgumentTypeInfo ati = ((ArgumentAssignement) element).arg.getType();
String format = INT.equals(ati.getEngType()) ? "%.0f" : "%f";
String range = "";
if (ati.hasRangeMin()) {
range = "[" + String.format(format, ati.getRangeMin()) + ", ";
}
if (ati.hasRangeMax()) {
range += String.format(format, ati.getRangeMax()) + "]";
}
return range;
}
return super.getText(element);
}
});
tcl.setColumnData(column.getColumn(), new ColumnPixelData(0));
// value
column = createTableViewerColumn(argumentTable, titles[3], 3);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof ArgumentAssignement)
return ((ArgumentAssignement) element).value;
return super.getText(element);
}
});
column.setEditingSupport(new ParameterEditingSupport(argumentTable));
tcl.setColumnData(column.getColumn(), new ColumnPixelData(200));
// default value
column = createTableViewerColumn(argumentTable, titles[4], 4);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof ArgumentAssignement) {
ArgumentAssignement aa = (ArgumentAssignement) element;
return aa.arg.hasInitialValue() ? aa.arg.getInitialValue() : null;
}
return super.getText(element);
}
});
tcl.setColumnData(column.getColumn(), new ColumnPixelData(200));
return argumentTable;
}
Aggregations