Search in sources :

Example 6 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project linuxtools by eclipse.

the class VagrantBoxView method createTableViewer.

private void createTableViewer(final Composite container) {
    search = new Text(container, SWT.SEARCH | SWT.ICON_SEARCH);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(search);
    search.addModifyListener(onSearch());
    Composite tableArea = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(tableArea);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableArea);
    final TableColumnLayout tableLayout = new TableColumnLayout();
    tableArea.setLayout(tableLayout);
    this.viewer = new TableViewer(tableArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    this.viewer.setContentProvider(new VagrantBoxContentProvider());
    final Table table = viewer.getTable();
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(table);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(table);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    // 'NAME' column
    final TableViewerColumn idColumn = createColumn(DVMessages.getString(// $NON-NLS-1$
    "NAME"));
    setLayout(idColumn, tableLayout, 150);
    idColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IVagrantBox) {
                return ((IVagrantBox) element).getName();
            }
            return super.getText(element);
        }
    });
    // 'PROVIDER' column
    final TableViewerColumn tagsColumn = createColumn(DVMessages.getString(// $NON-NLS-1$
    "PROVIDER"));
    setLayout(tagsColumn, tableLayout, 150);
    tagsColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IVagrantBox) {
                return ((IVagrantBox) element).getProvider();
            }
            return super.getText(element);
        }
    });
    // 'VERSION' column
    final TableViewerColumn creationDateColumn = createColumn(DVMessages.getString(// $NON-NLS-1$
    "VERSION"));
    setLayout(creationDateColumn, tableLayout, 150);
    creationDateColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IVagrantBox) {
                return ((IVagrantBox) element).getVersion().toString();
            }
            return super.getText(element);
        }
    });
    // comparator
    final VagrantBoxComparator comparator = new VagrantBoxComparator(this.viewer);
    viewer.setComparator(comparator);
    // apply search filter
    this.viewer.addFilter(getImagesFilter());
    setConnection(VagrantService.getInstance());
    connection.addBoxListener(this);
    // get the current selection in the tableviewer
    getSite().setSelectionProvider(viewer);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) IVagrantBox(org.eclipse.linuxtools.vagrant.core.IVagrantBox) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 7 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project linuxtools by eclipse.

the class DockerContainersView method createTableViewer.

private void createTableViewer(final Composite container) {
    this.search = new Text(container, SWT.SEARCH | SWT.ICON_SEARCH);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(search);
    search.addModifyListener(onSearch());
    Composite tableArea = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(tableArea);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableArea);
    final TableColumnLayout tableLayout = new TableColumnLayout();
    tableArea.setLayout(tableLayout);
    this.viewer = new TableViewer(tableArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    this.viewer.setContentProvider(new DockerContainersContentProvider());
    final Table table = this.viewer.getTable();
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).applyTo(table);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(table);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    // 'Name' column
    // $NON-NLS-1$
    final TableViewerColumn nameColumn = createColumn(DVMessages.getString("NAME"));
    setLayout(nameColumn, tableLayout, 150);
    nameColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerContainer) {
                return ((IDockerContainer) element).name();
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof IDockerContainer) {
                final IDockerContainer container = (IDockerContainer) element;
                final EnumDockerStatus containerStatus = EnumDockerStatus.fromStatusMessage(container.status());
                if (containerStatus == EnumDockerStatus.RUNNING) {
                    return STARTED_IMAGE;
                } else if (containerStatus == EnumDockerStatus.PAUSED) {
                    return PAUSED_IMAGE;
                } else {
                    return STOPPED_IMAGE;
                }
            }
            return super.getImage(element);
        }
    });
    // 'Image' column
    // $NON-NLS-1$
    final TableViewerColumn imageColumn = createColumn(DVMessages.getString("IMAGE"));
    setLayout(imageColumn, tableLayout, 150);
    imageColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerContainer) {
                return ((IDockerContainer) element).image();
            }
            return super.getText(element);
        }
    });
    // 'Creation Date' column
    // $NON-NLS-1$
    final TableViewerColumn creationDateColumn = createColumn(DVMessages.getString("CREATED"));
    setLayout(creationDateColumn, tableLayout, 150);
    creationDateColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerContainer) {
                return LabelProviderUtils.toCreatedDate(((IDockerContainer) element).created());
            }
            return super.getText(element);
        }
    });
    // 'Command' column
    final TableViewerColumn commandColumn = createColumn(// $NON-NLS-1$
    DVMessages.getString("COMMAND"));
    setLayout(commandColumn, tableLayout, 150);
    commandColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerContainer) {
                return ((IDockerContainer) element).command();
            }
            return super.getText(element);
        }
    });
    // 'Ports' column
    // $NON-NLS-1$
    final TableViewerColumn portsColumn = createColumn(DVMessages.getString("PORTS"));
    setLayout(portsColumn, tableLayout, 150);
    portsColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerContainer) {
                final StringBuilder ports = new StringBuilder();
                for (Iterator<IDockerPortMapping> iterator = ((IDockerContainer) element).ports().iterator(); iterator.hasNext(); ) {
                    final IDockerPortMapping portMapping = iterator.next();
                    ports.append(LabelProviderUtils.containerPortMappingToString(portMapping));
                    if (iterator.hasNext()) {
                        ports.append(", ");
                    }
                }
                return ports.toString();
            }
            return super.getText(element);
        }
    });
    // 'Status' column
    // $NON-NLS-1$
    final TableViewerColumn statusColumn = createColumn(DVMessages.getString("STATUS"));
    setLayout(statusColumn, tableLayout, 150);
    statusColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof IDockerContainer) {
                return ((IDockerContainer) element).status();
            }
            return super.getText(element);
        }
    });
    // comparator
    final DockerContainersComparator comparator = new DockerContainersComparator(this.viewer);
    comparator.setColumn(creationDateColumn.getColumn());
    // Set column a second time so we reverse the order and default to most
    // currently created containers first
    comparator.setColumn(creationDateColumn.getColumn());
    this.viewer.setComparator(comparator);
    // apply search filter
    this.viewer.setFilters(getContainersFilter());
    setConnection(CommandUtils.getCurrentConnection(null));
    this.viewer.addSelectionChangedListener(onContainerSelection());
    // get the current selection in the tableviewer
    getSite().setSelectionProvider(this.viewer);
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) Image(org.eclipse.swt.graphics.Image) IDockerPortMapping(org.eclipse.linuxtools.docker.core.IDockerPortMapping) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Iterator(java.util.Iterator) EnumDockerStatus(org.eclipse.linuxtools.docker.core.EnumDockerStatus) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 8 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout 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 9 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout 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;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ArgumentTypeInfo(org.yamcs.protobuf.Mdb.ArgumentTypeInfo) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 10 with TableColumnLayout

use of org.eclipse.jface.layout.TableColumnLayout in project yamcs-studio by yamcs.

the class AddParameterPage method createControl.

@Override
public void createControl(Composite parent) {
    var composite = new Composite(parent, SWT.NONE);
    setControl(composite);
    var 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));
    var tableWrapper1 = new Composite(composite, SWT.NONE);
    contentProvider = new ParameterContentProvider();
    trcl = new TreeColumnLayout();
    tableWrapper1.setLayoutData(new GridData(GridData.FILL_BOTH));
    tableWrapper1.setLayout(trcl);
    treeViewer = new TreeViewer(tableWrapper1, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    treeViewer.getTree().setHeaderVisible(true);
    treeViewer.getTree().setLinesVisible(true);
    // column container
    var pathColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
    pathColumn.getColumn().setText(COL_NAMESPACE);
    pathColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            var namespace = (String) element;
            return namespace.substring(namespace.lastIndexOf("/") + 1);
        }
    });
    trcl.setColumnData(pathColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
    treeViewer.addSelectionChangedListener(evt -> {
        var sel = (IStructuredSelection) evt.getSelection();
        if (sel.isEmpty()) {
            contentProvider.setNamespace(null);
            return;
        }
        contentProvider.setNamespace((String) sel.getFirstElement());
    });
    treeViewer.setContentProvider(new NamespaceContentProvider());
    treeViewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object o1, Object o2) {
            var n1 = (String) o1;
            var n2 = (String) o2;
            return n1.compareTo(n2);
        }
    });
    var tableWrapper2 = new Composite(composite, SWT.NONE);
    tcl = new TableColumnLayout();
    tableWrapper2.setLayoutData(new GridData(GridData.FILL_BOTH));
    tableWrapper2.setLayout(tcl);
    tableViewer = new TableViewer(tableWrapper2, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLinesVisible(true);
    var nameColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    nameColumn.getColumn().setText(COL_NAME);
    nameColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            var obj = (ParameterInfo) element;
            return obj.getQualifiedName();
        }
    });
    tcl.setColumnData(nameColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
    tableViewer.addSelectionChangedListener(evt -> {
        var sel = (IStructuredSelection) evt.getSelection();
        if (sel.isEmpty()) {
            setParameter(new ArrayList<>());
            return;
        }
        var parameters = new ArrayList<ParameterInfo>();
        for (var obj : sel.toArray()) {
            parameters.add((ParameterInfo) obj);
        }
        setParameter(parameters);
        setPageComplete(true);
    });
    tableViewer.setContentProvider(contentProvider);
    tableViewer.setInput(contentProvider);
    YamcsPlugin.getMissionDatabase().getParameters().forEach(pmtr -> {
        for (var alias : pmtr.getAliasList()) {
            var namespace = alias.getNamespace();
            if (!namespace.startsWith("/")) {
                return;
            }
            if (!parameterInfos.containsKey(namespace)) {
                parameterInfos.put(namespace, new ArrayList<>());
            }
            parameterInfos.get(namespace).add(pmtr);
            var parentns = namespace.substring(0, namespace.lastIndexOf("/"));
            while (!parentns.isEmpty()) {
                if (!parameterInfos.containsKey(parentns)) {
                    parameterInfos.put(parentns, new ArrayList<>());
                }
                parentns = parentns.substring(0, parentns.lastIndexOf("/"));
            }
        }
    });
    treeViewer.setInput(parameterInfos.keySet());
    tableViewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object o1, Object o2) {
            var n1 = (ParameterInfo) o1;
            var n2 = (ParameterInfo) o2;
            return n1.getQualifiedName().compareTo(n2.getQualifiedName());
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) 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) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)105 Composite (org.eclipse.swt.widgets.Composite)94 TableViewer (org.eclipse.jface.viewers.TableViewer)78 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)62 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)51 GridData (org.eclipse.swt.layout.GridData)46 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)44 Table (org.eclipse.swt.widgets.Table)38 GridLayout (org.eclipse.swt.layout.GridLayout)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)31 Image (org.eclipse.swt.graphics.Image)28 Label (org.eclipse.swt.widgets.Label)27 Viewer (org.eclipse.jface.viewers.Viewer)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)23 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)22 SelectionEvent (org.eclipse.swt.events.SelectionEvent)22 Button (org.eclipse.swt.widgets.Button)21 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)18 TableColumn (org.eclipse.swt.widgets.TableColumn)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)17