use of org.eclipse.jface.viewers.TreeViewerColumn in project yamcs-studio by yamcs.
the class FunctionsView method createPartControl.
@Override
public void createPartControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
TreeColumnLayout tcl_composite = new TreeColumnLayout();
composite.setLayout(tcl_composite);
treeViewer = new TreeViewer(composite, SWT.BORDER);
Tree tree = treeViewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
TreeViewerColumn treeViewerColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
treeViewerColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
return null;
}
@Override
public String getText(Object element) {
if (element instanceof FormulaFunctionSet) {
return ((FormulaFunctionSet) element).getName();
} else if (element instanceof FormulaFunction) {
return FormulaFunctions.formatSignature((FormulaFunction) element);
}
return "";
}
});
TreeColumn trclmnNewColumn = treeViewerColumn.getColumn();
tcl_composite.setColumnData(trclmnNewColumn, new ColumnWeightData(10, ColumnWeightData.MINIMUM_WIDTH, true));
trclmnNewColumn.setText("Name");
TreeViewerColumn treeViewerColumn_1 = new TreeViewerColumn(treeViewer, SWT.NONE);
treeViewerColumn_1.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
return null;
}
@Override
public String getText(Object element) {
if (element instanceof FormulaFunction) {
return ((FormulaFunction) element).getDescription();
} else if (element instanceof FormulaFunctionSet) {
return ((FormulaFunctionSet) element).getDescription();
}
return "";
}
});
TreeColumn trclmnNewColumn_1 = treeViewerColumn_1.getColumn();
tcl_composite.setColumnData(trclmnNewColumn_1, new ColumnWeightData(7, ColumnWeightData.MINIMUM_WIDTH, true));
trclmnNewColumn_1.setText("Description");
treeViewer.setContentProvider(new FunctionTreeContentProvider());
List<String> functionSetNames = new ArrayList<>(FormulaRegistry.getDefault().listFunctionSets());
Collections.sort(functionSetNames);
List<FormulaFunctionSet> functionSets = new ArrayList<>();
for (String functionSetName : functionSetNames) {
functionSets.add(FormulaRegistry.getDefault().findFunctionSet(functionSetName));
}
treeViewer.setInput(functionSets);
}
use of org.eclipse.jface.viewers.TreeViewerColumn in project yamcs-studio by yamcs.
the class AddParameterPage 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;
gl.numColumns = 2;
gl.makeColumnsEqualWidth = false;
composite.setLayout(gl);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite tableWrapper1 = new Composite(composite, SWT.NONE);
contentProvider = new ParameterContentProvider();
trcl = new TreeColumnLayout();
tableWrapper1.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper1.setLayout(trcl);
namespaceTable = new TreeViewer(tableWrapper1, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
namespaceTable.getTree().setHeaderVisible(true);
namespaceTable.getTree().setLinesVisible(true);
// column container
TreeViewerColumn pathColumn = new TreeViewerColumn(namespaceTable, SWT.NONE);
pathColumn.getColumn().setText(COL_NAMESPACE);
pathColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
String namespace = (String) element;
return namespace;
}
});
trcl.setColumnData(pathColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
namespaceTable.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
contentProvider.setNamespace(null);
return;
}
contentProvider.setNamespace((String) sel.getFirstElement());
});
namespaceTable.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection sel = new IStructuredSelection() {
@Override
public boolean isEmpty() {
return false;
}
@Override
public List toList() {
return Arrays.asList(contentProvider.getElements(event));
}
@Override
public Object[] toArray() {
return contentProvider.getElements(event);
}
@Override
public int size() {
return contentProvider.getElements(event).length;
}
@Override
public Iterator iterator() {
return Arrays.asList(contentProvider.getElements(event)).iterator();
}
@Override
public Object getFirstElement() {
return null;
}
};
parameterTable.setSelection(sel);
}
});
namespaceTable.setContentProvider(new NamespaceContentProvider());
namespaceTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
String n1 = (String) o1;
String n2 = (String) o2;
return n1.compareTo(n2);
}
});
Composite tableWrapper2 = new Composite(composite, SWT.NONE);
tcl = new TableColumnLayout();
tableWrapper2.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper2.setLayout(tcl);
parameterTable = new TableViewer(tableWrapper2, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
parameterTable.getTable().setHeaderVisible(true);
parameterTable.getTable().setLinesVisible(true);
TableViewerColumn nameColumn = new TableViewerColumn(parameterTable, SWT.NONE);
nameColumn.getColumn().setText(COL_NAME);
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterInfo obj = (ParameterInfo) element;
return obj.getQualifiedName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
parameterTable.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
setParameter(new ArrayList<>());
return;
}
List<ParameterInfo> parameters = new ArrayList<>();
for (Object obj : sel.toArray()) {
parameters.add((ParameterInfo) obj);
}
setParameter(parameters);
setPageComplete(true);
});
parameterTable.setContentProvider(contentProvider);
parameterTable.setInput(contentProvider);
ParameterCatalogue.getInstance().getMetaParameters().forEach(pmtr -> {
for (NamedObjectId alias : pmtr.getAliasList()) {
String namespace = alias.getNamespace();
if (!namespace.startsWith("/"))
return;
if (!parameterInfos.containsKey(namespace)) {
parameterInfos.put(namespace, new ArrayList<>());
}
parameterInfos.get(namespace).add(pmtr);
String parentns = namespace.substring(0, namespace.lastIndexOf("/"));
while (!parentns.isEmpty()) {
if (!parameterInfos.containsKey(parentns)) {
parameterInfos.put(parentns, new ArrayList<>());
}
parentns = parentns.substring(0, parentns.lastIndexOf("/"));
}
}
});
namespaceTable.setInput(parameterInfos.keySet());
parameterTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
ParameterInfo n1 = (ParameterInfo) o1;
ParameterInfo n2 = (ParameterInfo) o2;
return n1.getQualifiedName().compareTo(n2.getQualifiedName());
}
});
}
use of org.eclipse.jface.viewers.TreeViewerColumn 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.TreeViewerColumn 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));
}
use of org.eclipse.jface.viewers.TreeViewerColumn in project yamcs-studio by yamcs.
the class ActiveAlarmsView method createPartControl.
@Override
public void createPartControl(Composite parent) {
viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
contentProvider = new ActiveAlarmsContentProvider();
viewer.setContentProvider(contentProvider);
viewer.setInput(contentProvider);
viewer.getTree().setHeaderVisible(true);
viewer.getTree().setLinesVisible(true);
TreeViewerColumn nameColumn = new TreeViewerColumn(viewer, SWT.NONE);
nameColumn.getColumn().setWidth(300);
nameColumn.getColumn().setText("Alarm");
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((XtceTreeNode) element).getName();
}
});
TreeViewerColumn triggeredColumn = new TreeViewerColumn(viewer, SWT.NONE);
triggeredColumn.getColumn().setWidth(300);
triggeredColumn.getColumn().setText("Date");
triggeredColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XtceAlarmNode) {
AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
return String.valueOf(alarmData.getTriggerValue().getGenerationTimeUTC());
} else {
return null;
}
}
});
TreeViewerColumn currentSeverityColumn = new TreeViewerColumn(viewer, SWT.NONE);
currentSeverityColumn.getColumn().setWidth(300);
currentSeverityColumn.getColumn().setText("Current Severity");
currentSeverityColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XtceAlarmNode) {
AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
return String.valueOf(alarmData.getCurrentValue().getMonitoringResult());
} else {
return null;
}
}
});
TreeViewerColumn triggeredSeverityColumn = new TreeViewerColumn(viewer, SWT.NONE);
triggeredSeverityColumn.getColumn().setWidth(300);
triggeredSeverityColumn.getColumn().setText("Severity");
triggeredSeverityColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XtceAlarmNode) {
AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
return String.valueOf(alarmData.getTriggerValue().getMonitoringResult());
} else {
return null;
}
}
});
TreeViewerColumn typeColumn = new TreeViewerColumn(viewer, SWT.NONE);
typeColumn.getColumn().setWidth(300);
typeColumn.getColumn().setText("Type");
typeColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XtceAlarmNode) {
AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
return "Out of Limits";
} else {
return null;
}
}
});
TreeViewerColumn valueColumn = new TreeViewerColumn(viewer, SWT.NONE);
valueColumn.getColumn().setWidth(300);
valueColumn.getColumn().setText("Value");
valueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XtceAlarmNode) {
AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
return alarmData.getTriggerValue().getEngValue().toString();
} else {
return null;
}
}
});
TreeViewerColumn violationsColumn = new TreeViewerColumn(viewer, SWT.NONE);
violationsColumn.getColumn().setWidth(300);
violationsColumn.getColumn().setText("Violations");
violationsColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof XtceAlarmNode) {
AlarmData alarmData = ((XtceAlarmNode) element).getAlarmData();
return String.valueOf(alarmData.getViolations());
} else {
return null;
}
}
});
GridLayoutFactory.fillDefaults().generateLayout(parent);
viewer.getTree().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem item = (TreeItem) e.item;
if (item.getItemCount() > 0) {
item.setExpanded(!item.getExpanded());
viewer.refresh();
}
}
});
viewer.addDoubleClickListener(event -> {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
Object selectedNode = sel.getFirstElement();
viewer.setExpandedState(selectedNode, !viewer.getExpandedState(selectedNode));
});
getSite().setSelectionProvider(viewer);
// Set initial state
viewer.refresh();
AlarmCatalogue.getInstance().addAlarmListener(this);
}
Aggregations