Search in sources :

Example 51 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project dbeaver by dbeaver.

the class DriverTreeViewer method initDrivers.

public void initDrivers(Object site, List<DataSourceProviderDescriptor> providers, boolean expandRecent) {
    getTree().setHeaderVisible(true);
    this.site = site;
    this.providers = providers;
    if (this.providers == null) {
        this.providers = DataSourceProviderRegistry.getInstance().getEnabledDataSourceProviders();
    }
    TreeColumn nameColumn = new TreeColumn(getTree(), SWT.LEFT);
    nameColumn.setText("Name");
    nameColumn.addListener(SWT.Selection, new DriversSortListener(nameColumn, true));
    TreeColumn usersColumn = new TreeColumn(getTree(), SWT.LEFT);
    usersColumn.setText("#");
    usersColumn.addListener(SWT.Selection, new DriversSortListener(usersColumn, false));
    this.setContentProvider(new ViewContentProvider());
    this.setLabelProvider(new ViewLabelProvider());
    this.addSelectionChangedListener(this);
    this.addDoubleClickListener(this);
    this.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    Collection<Object> drivers = collectDrivers();
    this.setInput(drivers);
    this.expandAll();
    UIUtils.packColumns(getTree(), true, new float[] { 0.9f, 0.1f });
    if (expandRecent) {
        // Expand used driver categories
        for (Object driver : drivers) {
            if (driver instanceof DriverCategory && getConnectionCount(driver) > 0) {
                expandToLevel(driver, ALL_LEVELS);
            } else {
                collapseToLevel(driver, ALL_LEVELS);
            }
        }
    } else {
        this.collapseAll();
    }
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData)

Example 52 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn 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 53 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn 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 54 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project erlide_eclipse by erlang.

the class CoverStatsView method createTableTree.

private void createTableTree() {
    final Tree tree = viewer.getTree();
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    colName = new TreeColumn(tree, SWT.LEFT);
    colName.setText("Name");
    colName.setWidth(540);
    colLines = new TreeColumn(tree, SWT.RIGHT);
    colLines.setText("Total Lines");
    colLines.setWidth(150);
    colCovered = new TreeColumn(tree, SWT.RIGHT);
    colCovered.setText("Covered Lines");
    colCovered.setWidth(150);
    colPercentage = new TreeColumn(tree, SWT.RIGHT);
    colPercentage.setText("Coverage %");
    colPercentage.setWidth(150);
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree)

Example 55 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project abstools by abstools.

the class VariableView method createViewer.

@Override
protected Viewer createViewer(final Composite parent) {
    final TreeViewer viewer = new TreeViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION);
    viewer.setContentProvider(new VariableContentProvider());
    viewer.setLabelProvider(new VariableLabelProvider());
    final TreeColumn column1 = new TreeColumn(viewer.getTree(), SWT.LEFT);
    column1.setText("Name");
    final TreeColumn column2 = new TreeColumn(viewer.getTree(), SWT.LEFT);
    column2.setText("Value");
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (selection != null) {
                viewer.setExpandedState(selection, !viewer.getExpandedState(selection));
            }
        }
    });
    parent.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            Rectangle area = parent.getClientArea();
            int width = area.width;
            column1.setWidth(width / 3);
            column2.setWidth(2 * width / 3);
        }
    });
    return viewer;
}
Also used : ControlAdapter(org.eclipse.swt.events.ControlAdapter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Rectangle(org.eclipse.swt.graphics.Rectangle) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

TreeColumn (org.eclipse.swt.widgets.TreeColumn)189 Tree (org.eclipse.swt.widgets.Tree)99 TreeViewer (org.eclipse.jface.viewers.TreeViewer)55 Composite (org.eclipse.swt.widgets.Composite)52 TreeItem (org.eclipse.swt.widgets.TreeItem)45 FillLayout (org.eclipse.swt.layout.FillLayout)40 Point (org.eclipse.swt.graphics.Point)39 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)28 Viewer (org.eclipse.jface.viewers.Viewer)28 GridData (org.eclipse.swt.layout.GridData)28 ControlEvent (org.eclipse.swt.events.ControlEvent)27 ControlAdapter (org.eclipse.swt.events.ControlAdapter)25 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 TableColumn (org.eclipse.swt.widgets.TableColumn)24 TableLayout (org.eclipse.jface.viewers.TableLayout)23 Table (org.eclipse.swt.widgets.Table)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)21 ViewerPane (org.eclipse.emf.common.ui.ViewerPane)19