Search in sources :

Example 6 with TreeViewerColumn

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);
}
Also used : FormulaFunctionSet(org.diirt.datasource.formula.FormulaFunctionSet) ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) FormulaFunction(org.diirt.datasource.formula.FormulaFunction) Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) Image(org.eclipse.swt.graphics.Image) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree)

Example 7 with TreeViewerColumn

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());
        }
    });
}
Also used : TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ParameterInfo(org.yamcs.protobuf.Mdb.ParameterInfo) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) GridData(org.eclipse.swt.layout.GridData) NamedObjectId(org.yamcs.protobuf.Yamcs.NamedObjectId) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 8 with TreeViewerColumn

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());
        }
    });
}
Also used : LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeViewer(org.eclipse.jface.viewers.TreeViewer) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ArrayList(java.util.ArrayList) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) KeyEvent(org.eclipse.swt.events.KeyEvent) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) Text(org.eclipse.swt.widgets.Text) ResourceManager(org.eclipse.jface.resource.ResourceManager) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) CenteredImageLabelProvider(org.yamcs.studio.core.ui.utils.CenteredImageLabelProvider) CommandInfo(org.yamcs.protobuf.Mdb.CommandInfo) GridData(org.eclipse.swt.layout.GridData) NamedObjectId(org.yamcs.protobuf.Yamcs.NamedObjectId)

Example 9 with TreeViewerColumn

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));
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) CommandInfo(org.yamcs.protobuf.Mdb.CommandInfo) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) ArrayList(java.util.ArrayList) List(java.util.List) NamedObjectId(org.yamcs.protobuf.Yamcs.NamedObjectId) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn)

Example 10 with TreeViewerColumn

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);
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AlarmData(org.yamcs.protobuf.Alarms.AlarmData)

Aggregations

TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)17 Composite (org.eclipse.swt.widgets.Composite)10 TreeViewer (org.eclipse.jface.viewers.TreeViewer)9 GridLayout (org.eclipse.swt.layout.GridLayout)8 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)7 GridData (org.eclipse.swt.layout.GridData)7 TreeColumn (org.eclipse.swt.widgets.TreeColumn)7 Tree (org.eclipse.swt.widgets.Tree)6 TreeColumnLayout (org.eclipse.jface.layout.TreeColumnLayout)5 ArrayList (java.util.ArrayList)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 CellEditor (org.eclipse.jface.viewers.CellEditor)3 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)3 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)3 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)3 EditingSupport (org.eclipse.jface.viewers.EditingSupport)3 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3