Search in sources :

Example 6 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project GT by Tencent.

the class CopyAllFromTreeViewAction method getContents.

/**
	 * 获取treeview控件的所有数据
	 * @return
	 */
private StringBuffer getContents() {
    StringBuffer sb = new StringBuffer();
    int columnCount = viewer.getTree().getColumnCount();
    // 表头
    for (TreeColumn column : viewer.getTree().getColumns()) {
        sb.append(column.getText());
        sb.append(SourceDataItem.SPLIT);
    }
    sb.deleteCharAt(sb.length() - 1);
    sb.append("\r\n");
    for (TreeItem tableItem : viewer.getTree().getItems()) {
        parseTree(tableItem, columnCount, sb);
    }
    return sb;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Example 7 with TreeColumn

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

the class OracleMaintenanceDialog method getScriptListener.

@Override
protected SQLScriptProgressListener<T> getScriptListener() {
    return new SQLScriptStatusDialog<T>(getShell(), getTitle() + " progress", null) {

        @Override
        protected void createStatusColumns(Tree objectTree) {
            TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
            msgColumn.setText("Message");
        }

        @Override
        public void processObjectResults(@NotNull T object, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
        }

        @Override
        public void endObjectProcessing(@NotNull T object, Exception error) {
            super.endObjectProcessing(object, error);
            TreeItem treeItem = getTreeItem(object);
            if (treeItem != null) {
                treeItem.setText(1, error == null ? "Done" : error.getMessage());
            }
        }
    };
}
Also used : SWT(org.eclipse.swt.SWT) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) DBCResultSet(org.jkiss.dbeaver.model.exec.DBCResultSet) NotNull(org.jkiss.code.NotNull) DBCStatement(org.jkiss.dbeaver.model.exec.DBCStatement) SQLScriptStatusDialog(org.jkiss.dbeaver.ui.dialogs.sql.SQLScriptStatusDialog) Nullable(org.jkiss.code.Nullable) DBCException(org.jkiss.dbeaver.model.exec.DBCException)

Example 8 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project tdi-studio-se by Talend.

the class ErrorDetailDialog method createTreeTableViewer.

/**
     * DOC chuang Comment method "createTreeTableView".
     * 
     * @param parent
     */
private void createTreeTableViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer = new TreeViewer(composite, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    // init tree
    final Tree tree = viewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    // create tree column
    TreeColumn column = new TreeColumn(tree, SWT.NONE);
    //$NON-NLS-1$
    column.setText("Resource");
    column.setWidth(150);
    column = new TreeColumn(tree, SWT.NONE);
    //$NON-NLS-1$
    column.setText("Description");
    column.setWidth(300);
    viewer.setContentProvider(new ErrorDetailContentProvider());
    viewer.setLabelProvider(new ErrorDetailLabelProvider());
    viewer.setInput(errors);
    viewer.expandAll();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree)

Example 9 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project tdi-studio-se by Talend.

the class JSONFileOutputStep2Form method addJSONFileViewer.

private void addJSONFileViewer(final Composite mainComposite, final int width, final int height) {
    final Group group = Form.createGroup(mainComposite, 1, "Linker Target", height);
    GridData data = new GridData(GridData.FILL_BOTH);
    Composite composite = new Composite(group, SWT.BORDER);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(data);
    JSONViewer = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    data = new GridData(GridData.FILL_BOTH);
    JSONViewer.getControl().setLayoutData(data);
    JSONViewer.setUseHashlookup(true);
    Tree tree = JSONViewer.getTree();
    if (isReadOnly()) {
        tree.setEnabled(false);
    }
    tree.setLinesVisible(true);
    tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("JSON Tree");
    column1.setWidth(120);
    TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
    column2.setText("Related Column");
    column2.setWidth(100);
    TreeColumn column3 = new TreeColumn(tree, SWT.CENTER);
    column3.setText("Node Status");
    column3.setWidth(100);
    TreeColumn column4 = new TreeColumn(tree, SWT.CENTER);
    column4.setText("Default Value");
    column4.setWidth(100);
    tree.setHeaderVisible(true);
    JSONFileTreeViewerProvider provider = new JSONFileTreeViewerProvider();
    JSONViewer.setLabelProvider(provider);
    JSONViewer.setCellModifier(new ICellModifier() {

        public void modify(Object element, String property, Object value) {
            TreeItem treeItem = (TreeItem) element;
            FOXTreeNode node = (FOXTreeNode) treeItem.getData();
            if (property.equals("C1")) {
                node.setLabel((String) value);
            }
            if (property.equals("C4")) {
                node.setDefaultValue((String) value);
            }
            JSONViewer.refresh(node);
        }

        public Object getValue(Object element, String property) {
            FOXTreeNode node = (FOXTreeNode) element;
            if (property.equals("C1")) {
                //$NON-NLS-1$
                return node.getLabel();
            }
            if (property.equals("C4")) {
                //$NON-NLS-1$
                return node.getDefaultValue();
            }
            return null;
        }

        public boolean canModify(Object element, String property) {
            FOXTreeNode node = (FOXTreeNode) element;
            if (property.equals("C1")) {
                if (node.getLabel() != null && node.getLabel().length() > 0) {
                    return true;
                }
            }
            if (property.equals("C4")) {
                if (node.getDefaultValue() != null && node.getDefaultValue().length() > 0) {
                    return true;
                }
            }
            return false;
        }
    });
    JSONViewer.setColumnProperties(new String[] { "C1", "C2", "C3", "C4" });
    CellEditor editor = new TextCellEditor(JSONViewer.getTree());
    editor.addListener(new DialogErrorJSONLabelCellEditor(editor, "C1"));
    CellEditor editorDefault = new TextCellEditor(JSONViewer.getTree());
    editorDefault.addListener(new DialogErrorJSONLabelCellEditor(editorDefault, "C4"));
    JSONViewer.setCellEditors(new CellEditor[] { editor, null, null, editorDefault });
    JSONViewer.setContentProvider(provider);
    // JSONViewer.setInput(treeData);
    JSONViewer.expandAll();
    createAction();
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(JSONViewer.getControl());
    JSONViewer.getControl().setMenu(menu);
    JSONViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
        }
    });
    initToolBar(composite);
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) JSONFileTreeViewerProvider(org.talend.repository.json.ui.wizards.view.JSONFileTreeViewerProvider) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Example 10 with TreeColumn

use of org.eclipse.swt.widgets.TreeColumn in project tdi-studio-se by Talend.

the class CallTreeFilteredTree method configureTree.

/*
     * @see AbstractFilteredTree#configureTree()
     */
@Override
protected void configureTree() {
    for (TreeColumn column : getViewer().getTree().getColumns()) {
        column.dispose();
    }
    getViewer().getTree().setLinesVisible(true);
    getViewer().getTree().setHeaderVisible(true);
    for (Entry<String, Boolean> entry : columns.entrySet()) {
        CallTreeColumn column = CallTreeColumn.getColumn(entry.getKey());
        if (!columns.get(column.label)) {
            continue;
        }
        TreeColumn treeColumn = new TreeColumn(getViewer().getTree(), SWT.NONE);
        treeColumn.setText(column.label);
        treeColumn.setWidth(column.defalutWidth);
        treeColumn.setAlignment(column.alignment);
        treeColumn.setToolTipText(column.toolTip);
    }
}
Also used : TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Aggregations

TreeColumn (org.eclipse.swt.widgets.TreeColumn)59 Tree (org.eclipse.swt.widgets.Tree)27 TreeViewer (org.eclipse.jface.viewers.TreeViewer)20 GridData (org.eclipse.swt.layout.GridData)18 TreeItem (org.eclipse.swt.widgets.TreeItem)18 Composite (org.eclipse.swt.widgets.Composite)16 GridLayout (org.eclipse.swt.layout.GridLayout)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Point (org.eclipse.swt.graphics.Point)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 FillLayout (org.eclipse.swt.layout.FillLayout)7 Menu (org.eclipse.swt.widgets.Menu)7 CellEditor (org.eclipse.jface.viewers.CellEditor)6 Button (org.eclipse.swt.widgets.Button)6 ArrayList (java.util.ArrayList)5 IMenuListener (org.eclipse.jface.action.IMenuListener)5 IMenuManager (org.eclipse.jface.action.IMenuManager)5 ICellModifier (org.eclipse.jface.viewers.ICellModifier)5 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)5 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)4