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;
}
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);
}
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());
}
}
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;
}
});
}
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();
}
Aggregations