use of org.eclipse.jface.viewers.ColumnLabelProvider 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.ColumnLabelProvider 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.ColumnLabelProvider 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.ColumnLabelProvider in project yamcs-studio by yamcs.
the class AddToStackWizardPage1 method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
setControl(composite);
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
composite.setLayout(gl);
// add filter box
Text searchbox = new Text(composite, SWT.SEARCH | SWT.BORDER | SWT.ICON_CANCEL);
searchbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// build tree table
ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), composite);
level1Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level1s.png"));
level2Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level2s.png"));
level3Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level3s.png"));
level4Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level4s.png"));
level5Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level5s.png"));
Composite tableWrapper = new Composite(composite, SWT.NONE);
tcl = new TreeColumnLayout();
tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper.setLayout(tcl);
commandsTreeTable = new TreeViewer(tableWrapper, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
commandsTreeTable.getTree().setHeaderVisible(true);
commandsTreeTable.getTree().setLinesVisible(false);
// column xtce path
TreeViewerColumn pathColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
pathColumn.getColumn().setText(COL_PATH);
pathColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandInfo cmd = (CommandInfo) element;
return cmd.getName();
}
});
tcl.setColumnData(pathColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
// column significance
TreeViewerColumn significanceColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
significanceColumn.getColumn().setText(COL_SIGN);
significanceColumn.getColumn().setToolTipText("Significance Level");
significanceColumn.getColumn().setAlignment(SWT.CENTER);
significanceColumn.setLabelProvider(new CenteredImageLabelProvider() {
@Override
public Image getImage(Object element) {
CommandInfo cmd = (CommandInfo) element;
if (cmd.getSignificance() == null)
return null;
switch(cmd.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;
}
}
});
tcl.setColumnData(significanceColumn.getColumn(), new ColumnPixelData(40));
// column qualified name
TreeViewerColumn nameColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
nameColumn.getColumn().setText(COL_QNAME);
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandInfo cmd = (CommandInfo) element;
if (cmd.getAbstract()) {
// show a blank line if the command is abstract
return "";
}
return cmd.getQualifiedName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
// on item selection update significance message and page completion status
commandsTreeTable.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
setMessage(null);
return;
}
CommandInfo cmd = (CommandInfo) sel.getFirstElement();
setMessage(getMessage(cmd));
command.setMetaCommand(cmd);
command.setSelectedAliase(cmd.getQualifiedName());
setPageComplete(!cmd.getAbstract());
});
CommandTreeContentProvider commandTreeContentProvider = new CommandTreeContentProvider();
commandsTreeTable.setContentProvider(commandTreeContentProvider);
// load command list
Collection<CommandInfo> commandInfos = new ArrayList<>();
CommandingCatalogue.getInstance().getMetaCommands().forEach(cmd -> {
// add aliases columns
for (NamedObjectId alias : cmd.getAliasList()) {
String namespace = alias.getNamespace();
if (!namespaces.contains(namespace) && !namespace.startsWith("/")) {
namespaces.add(namespace);
addAliasColumn(namespace);
}
}
commandInfos.add(cmd);
});
commandsTreeTable.setInput(commandInfos);
commandsTreeTable.expandAll();
// with a small hack to display full data on the first column
for (TreeColumn tc : commandsTreeTable.getTree().getColumns()) tc.pack();
pathColumn.getColumn().setWidth(pathColumn.getColumn().getWidth() + 11 * commandTreeContentProvider.nbLevels);
for (TreeColumn tc : commandsTreeTable.getTree().getColumns()) {
if (tc.getWidth() > COLUMN_MAX_WIDTH)
tc.setWidth(COLUMN_MAX_WIDTH);
}
// filter
CommandInfoTreeViewerFilter filter = new CommandInfoTreeViewerFilter(commandTreeContentProvider);
commandsTreeTable.addFilter(filter);
searchbox.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent ke) {
filter.setSearchTerm(searchbox.getText());
commandsTreeTable.refresh();
commandsTreeTable.expandAll();
}
});
commandsTreeTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
CommandInfo c1 = (CommandInfo) o1;
CommandInfo c2 = (CommandInfo) o2;
return c1.getQualifiedName().compareTo(c2.getQualifiedName());
}
});
}
use of org.eclipse.jface.viewers.ColumnLabelProvider in project yamcs-studio by yamcs.
the class AddToStackWizardPage1 method addAliasColumn.
// Add dynamically columns for each alias of a command
private void addAliasColumn(String namespace) {
TreeViewerColumn aliasColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
aliasColumn.getColumn().setText(namespace);
aliasColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandInfo cmd = (CommandInfo) element;
if (cmd.getAbstract()) {
// show a blank line if the command is abstract
return "";
}
List<NamedObjectId> aliases = cmd.getAliasList();
for (NamedObjectId aliase : aliases) {
if (aliase.getNamespace().equals(namespace))
return aliase.getName();
}
return "";
}
});
tcl.setColumnData(aliasColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
}
Aggregations