Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » TreeEditor Problem
TreeEditor Problem [message #74432] Tue, 19 February 2008 03:59 Go to next message
Eclipse UserFriend
Originally posted by: allen_liu.i-len.com

Hi everyone:
According to Rap's example of using a TreeEditor codes, I found
the TreeItem that can't be edited when I selected the TreeItem. can anyone
tell me the reaseon or give me some ideas? My codes as follows:
final Tree tree = new Tree(shell, SWT.BORDER);
for (int i = 0; i < 3; i++) {
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText("item " + i);
for (int j = 0; j < 3; j++) {
TreeItem subItem = new TreeItem(item, SWT.NONE);
subItem.setText("item " + i + " " + j);
}
}

final TreeEditor editor = new TreeEditor(tree);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;

tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Control oldEditor = editor.getEditor();
if (oldEditor != null) oldEditor.dispose();
TreeItem item = (TreeItem)e.item;
if (item == null) return;
Text newEditor = new Text(tree, SWT.NONE);
newEditor.setText(item.getText());
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Text text = (Text)editor.getEditor();
editor.getItem().setText(text.getText());
}
});
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item);
}
});


Cheers

Allen_liu 2008-02-19
Re: TreeEditor Problem [message #74540 is a reply to message #74432] Tue, 19 February 2008 07:19 Go to previous message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

didn't know, that we provide examples regarding the TreeEditor. In fact
it seems to me that the TreeEditor is available by accident, since we do
not have the possibility yet to open an editor element over an special
tree item. Sorry for that.


Ciao
Frank


-----Ursprüngliche Nachricht-----
Von: allen_liu [mailto:allen_liu@i-len.com]
Bereitgestellt: Dienstag, 19. Februar 2008 05:00
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: TreeEditor Problem
Betreff: TreeEditor Problem


Hi everyone:
According to Rap's example of using a TreeEditor codes, I found the
TreeItem that can't be edited when I selected the TreeItem. can anyone
tell me the reaseon or give me some ideas? My codes as follows:
final Tree tree = new Tree(shell, SWT.BORDER);
for (int i = 0; i < 3; i++) {
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText("item " + i);
for (int j = 0; j < 3; j++) {
TreeItem subItem = new TreeItem(item, SWT.NONE);
subItem.setText("item " + i + " " + j);
}
}

final TreeEditor editor = new TreeEditor(tree);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
editor.minimumWidth = 50;

tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Control oldEditor = editor.getEditor();
if (oldEditor != null) oldEditor.dispose();
TreeItem item = (TreeItem)e.item;
if (item == null) return;
Text newEditor = new Text(tree, SWT.NONE);
newEditor.setText(item.getText());
newEditor.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e) {
Text text =
(Text)editor.getEditor();

editor.getItem().setText(text.getText());
}
});
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item);
}
});


Cheers

Allen_liu 2008-02-19
Previous Topic:CLabel problem
Next Topic:Problem with File Upload Widget
Goto Forum:
  


Current Time: Fri Apr 26 05:07:37 GMT 2024

Powered by FUDForum. Page generated in 0.02269 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top