if (oldEditor != null)
oldEditor.dispose();
// Identify the selected row
TableTreeItem[] selection = listEpsTree.getSelection();
if (selection.length == 0) return;
final TableTreeItem item = selection[0];
// The control that will be the editor must be a child of the Table
// that underlies the TableTree
final Text text = new Text(listEpsTree.getTable(), SWT.NONE);
//text.moveAbove(tableTree);
//The text editor must have the same size as the cell and must
//not be any smaller than 50 pixels.
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
//editor.minimumWidth = 50;
// Open the text editor in the second column of the selected row.
editor.setEditor (text, item, 1);
// Assign focus to the text control
text.setText( item.getText(1) );
text.setFocus ();
//Listener for editor
text.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
int escPressed=0;
switch (e.character){
case SWT.CR: escPressed=1;break;
}
if (escPressed == 1){
lines[1] = item.getText(0);
lines[2] = text.getText();
//System.out.println(lines[1] + " | " + lines[2]);
epiMaker = new EpiMaker();
epiMaker.commentWriter(pluginInterface, lines);
Control oldEditor = editor.getEditor();
if (oldEditor != null)
{
oldEditor.dispose();
}
if (!item.isDisposed())
item.setText(1, lines[2]);
}
}
public void keyReleased (KeyEvent e) {
}
});
//Focus Listener for Editor
text.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
lines[1] = item.getText(0);
lines[2] = text.getText();
//System.out.println(lines[1] + " | " + lines[2]);
epiMaker = new EpiMaker();
epiMaker.commentWriter(pluginInterface, lines);
Control oldEditor = editor.getEditor();
if (oldEditor != null)
{
oldEditor.dispose();
}
if (!item.isDisposed())
item.setText(1, lines[2]);
}
});
}