Search in sources :

Example 6 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method renameJob.

public boolean renameJob(String name, RepositoryDirectoryInterface repdir) {
    boolean retval = false;
    final TreeItem ti = wTree.getSelection()[0];
    if (ti.getItemCount() == 0) {
        final String fname = name;
        final RepositoryDirectoryInterface frepdir = repdir;
        TreeEditor editor = new TreeEditor(wTree);
        editor.setItem(ti);
        final Text text = new Text(wTree, SWT.NONE);
        props.setLook(text);
        text.setText(name);
        text.addFocusListener(new FocusAdapter() {

            @Override
            public void focusLost(FocusEvent arg0) {
                // Focus is lost: apply changes
                String newname = text.getText();
                if (renameJob(fname, newname, frepdir)) {
                    ti.setText(newname);
                }
                text.dispose();
            }
        });
        text.addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                // ESC --> Don't change tree item...
                if (e.keyCode == SWT.ESC) {
                    text.dispose();
                }
                // ENTER --> Save changes...
                if (e.character == SWT.CR) {
                    String newname = text.getText();
                    if (renameJob(fname, newname, frepdir)) {
                        ti.setText(newname);
                    }
                    text.dispose();
                }
            }
        });
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;
        editor.grabVertical = true;
        editor.minimumWidth = 50;
        text.selectAll();
        text.setFocus();
        editor.layout();
        editor.setEditor(text);
    }
    return retval;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) FocusAdapter(org.eclipse.swt.events.FocusAdapter) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 7 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method renameDirectory.

public void renameDirectory(TreeItem treeitem, RepositoryDirectoryInterface rd) {
    final TreeItem ti = treeitem;
    final RepositoryDirectoryInterface repdir = rd;
    final String name = ti.getText();
    TreeEditor editor = new TreeEditor(wTree);
    editor.setItem(ti);
    final Text text = new Text(wTree, SWT.NONE);
    props.setLook(text);
    text.setText(name);
    text.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent arg0) {
            // Focus is lost: apply changes
            String newname = text.getText();
            if (renameDirectory(repdir, name, newname)) {
                ti.setText(newname);
            }
            text.dispose();
        }
    });
    text.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            // ESC --> Don't change tree item...
            if (e.keyCode == SWT.ESC) {
                text.dispose();
            }
            // ENTER --> Save changes...
            if (e.character == SWT.CR) {
                String newname = text.getText();
                if (renameDirectory(repdir, name, newname)) {
                    ti.setText(newname);
                }
                text.dispose();
            }
        }
    });
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.grabVertical = true;
    editor.minimumWidth = 50;
    text.selectAll();
    text.setFocus();
    editor.layout();
    editor.setEditor(text);
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) FocusAdapter(org.eclipse.swt.events.FocusAdapter) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 8 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project dbeaver by dbeaver.

the class DatabaseNavigatorTree method initEditor.

private void initEditor() {
    Tree treeControl = this.treeViewer.getTree();
    treeEditor = new TreeEditor(treeControl);
    treeEditor.horizontalAlignment = SWT.LEFT;
    treeEditor.verticalAlignment = SWT.TOP;
    treeEditor.grabHorizontal = false;
    treeEditor.minimumWidth = 50;
    // treeControl.addSelectionListener(new TreeSelectionAdapter());
    if (!checkEnabled) {
        // Add rename listener only for non CHECK trees
        treeControl.addMouseListener(new TreeSelectionAdapter());
    }
}
Also used : TreeEditor(org.eclipse.swt.custom.TreeEditor) FilteredTree(org.eclipse.ui.dialogs.FilteredTree)

Example 9 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project dbeaver by dbeaver.

the class PropertyTreeViewer method registerEditor.

private void registerEditor() {
    // Make an editor
    final Tree treeControl = super.getTree();
    treeEditor = new TreeEditor(treeControl);
    treeEditor.horizontalAlignment = SWT.CENTER;
    treeEditor.verticalAlignment = SWT.CENTER;
    treeEditor.minimumWidth = 50;
    treeControl.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // showEditor((TreeItem) e.item, true);
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            showEditor((TreeItem) e.item, selectedColumn == 1 && (e.stateMask & SWT.BUTTON_MASK) != 0);
        }
    });
    treeControl.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            TreeItem item = treeControl.getItem(new Point(e.x, e.y));
            if (item != null) {
                selectedColumn = UIUtils.getColumnAtPos(item, e.x, e.y);
            } else {
                selectedColumn = -1;
            }
        }
    });
    treeControl.addTraverseListener(e -> {
        if (e.detail == SWT.TRAVERSE_RETURN) {
            // Set focus on editor
            if (curCellEditor != null) {
                curCellEditor.setFocus();
            } else {
                final TreeItem[] selection = treeControl.getSelection();
                if (selection.length == 0) {
                    return;
                }
                showEditor(selection[0], true);
            }
            e.doit = false;
            e.detail = SWT.TRAVERSE_NONE;
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeEditor(org.eclipse.swt.custom.TreeEditor) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 10 with TreeEditor

use of org.eclipse.swt.custom.TreeEditor in project tmdm-studio-se by Talend.

the class ImpactResultDialog method initTree.

private void initTree() {
    treeViewer.setInput(input.keySet());
    Tree tree = treeViewer.getTree();
    TreeItem[] tableItems = tree.getItems();
    System.out.println(tableItems.length);
    for (TreeItem item : tableItems) {
        Object data = item.getData();
        if (data != null && data instanceof IRepositoryViewObject) {
            final IRepositoryViewObject viewObj = (IRepositoryViewObject) data;
            final TreeEditor editor = new TreeEditor(tree);
            final CCombo combo = new CCombo(tree, SWT.READ_ONLY);
            // combo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
            String[] items = getDefaultComboItems(viewObj);
            combo.setItems(items);
            ImpactOperation operation = getOperation(viewObj);
            combo.setText(operation.getDescription());
            combo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    modifyOperationValue(viewObj, combo.getSelectionIndex());
                }
            });
            editor.grabHorizontal = true;
            editor.setEditor(combo, item, 2);
        }
    }
    // 
    treeViewer.expandAll();
}
Also used : TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) ImpactOperation(org.talend.mdm.repository.core.service.ModelImpactAnalyseService.ImpactOperation) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CCombo(org.eclipse.swt.custom.CCombo) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

TreeEditor (org.eclipse.swt.custom.TreeEditor)37 TreeItem (org.eclipse.swt.widgets.TreeItem)24 MouseEvent (org.eclipse.swt.events.MouseEvent)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)13 MouseAdapter (org.eclipse.swt.events.MouseAdapter)10 FocusEvent (org.eclipse.swt.events.FocusEvent)8 KeyEvent (org.eclipse.swt.events.KeyEvent)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 Point (org.eclipse.swt.graphics.Point)8 Label (org.eclipse.swt.widgets.Label)8 CCombo (org.eclipse.swt.custom.CCombo)5 Control (org.eclipse.swt.widgets.Control)5 FocusAdapter (org.eclipse.swt.events.FocusAdapter)4 KeyAdapter (org.eclipse.swt.events.KeyAdapter)4 Text (org.eclipse.swt.widgets.Text)4 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 CTabFolderEvent (org.eclipse.swt.custom.CTabFolderEvent)3 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)3