protected void renameItem(final TreeItem item) {
		boolean showBorder = true;
		final TreeEditor editor = new TreeEditor(tree);
		final Composite composite = new Composite(tree, SWT.NONE);
		final Text text = new Text(composite, SWT.NONE);
		final int inset = showBorder ? 1 : 0;

		// NONO for syms and dirs
		if (item.getData() instanceof String || item.getData() instanceof Integer)
			return;

		if (showBorder)
			composite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));

		composite.addListener(SWT.Resize, new Listener() {
			public void handleEvent(Event e) {
				Rectangle rect = composite.getClientArea();
				text.setBounds(rect.x + inset, rect.y + inset, rect.width - inset * 2, rect.height - inset * 2);
			}
		});

		Listener textListener = new Listener() {
			public void handleEvent(final Event e) {
				switch (e.type) {
				case SWT.FocusOut:
					handleRenameItem(item, text.getText());
					composite.dispose();
					break;
				case SWT.Verify:
					String newText = text.getText();
					String leftText = newText.substring(0, e.start);
					String rightText = newText.substring(e.end, newText.length());

					GC gc = new GC(text);
					Point size = gc.textExtent(leftText + e.text + rightText);
					gc.dispose();

					size = text.computeSize(size.x, SWT.DEFAULT);
					editor.horizontalAlignment = SWT.LEFT;

					Rectangle itemRect = item.getBounds(),
					rect = tree.getClientArea();
					editor.minimumWidth = Math.max(size.x, itemRect.width) + inset * 2;
					int left = itemRect.x,
					right = rect.x + rect.width;

					editor.minimumWidth = Math.min(editor.minimumWidth, right - left);
					editor.minimumHeight = size.y + inset * 2;
					editor.layout();
					break;
				case SWT.Traverse:
					switch (e.detail) {
					case SWT.TRAVERSE_RETURN:
						handleRenameItem(item, text.getText());
						// FALL THROUGH
					case SWT.TRAVERSE_ESCAPE:
						composite.dispose();
						e.doit = false;
					}
					break;
				}
			}
		};

		text.addListener(SWT.FocusOut, textListener);
		text.addListener(SWT.Traverse, textListener);
		text.addListener(SWT.Verify, textListener);

		editor.setEditor(composite, item);

		text.setText(item.getText());
		text.selectAll();
		text.setFocus();
	}