|
Lines 72-113
Link Here
|
| 72 |
|
72 |
|
| 73 |
if( part != null && part.getEditingSupport() != null && part.getEditingSupport().canEdit(element) ) { |
73 |
if( part != null && part.getEditingSupport() != null && part.getEditingSupport().canEdit(element) ) { |
| 74 |
cellEditor = part.getEditingSupport().getCellEditor(element); |
74 |
cellEditor = part.getEditingSupport().getCellEditor(element); |
| 75 |
cellEditor.addListener(cellEditorListener); |
75 |
if( cellEditor != null ) { |
| 76 |
Object value = part.getEditingSupport().getValue(element); |
76 |
cellEditor.addListener(cellEditorListener); |
| 77 |
cellEditor.setValue(value); |
77 |
Object value = part.getEditingSupport().getValue(element); |
| 78 |
// Tricky flow of control here: |
78 |
cellEditor.setValue(value); |
| 79 |
// activate() can trigger callback to cellEditorListener which will clear cellEditor |
79 |
// Tricky flow of control here: |
| 80 |
// so must get control first, but must still call activate() even if there is no control. |
80 |
// activate() can trigger callback to cellEditorListener which will clear cellEditor |
| 81 |
final Control control = cellEditor.getControl(); |
81 |
// so must get control first, but must still call activate() even if there is no control. |
| 82 |
cellEditor.activate(); |
82 |
final Control control = cellEditor.getControl(); |
| 83 |
if (control == null) { |
83 |
cellEditor.activate(); |
| 84 |
return; |
84 |
if (control == null) { |
| 85 |
} |
85 |
return; |
| 86 |
setLayoutData(cellEditor.getLayoutData()); |
86 |
} |
| 87 |
setEditor(control, tableItem, columnNumber); |
87 |
setLayoutData(cellEditor.getLayoutData()); |
| 88 |
cellEditor.setFocus(); |
88 |
setEditor(control, tableItem, columnNumber); |
| 89 |
if (focusListener == null) { |
89 |
cellEditor.setFocus(); |
| 90 |
focusListener = new FocusAdapter() { |
90 |
if (focusListener == null) { |
| 91 |
public void focusLost(FocusEvent e) { |
91 |
focusListener = new FocusAdapter() { |
| 92 |
applyEditorValue(); |
92 |
public void focusLost(FocusEvent e) { |
|
|
93 |
applyEditorValue(); |
| 94 |
} |
| 95 |
}; |
| 96 |
} |
| 97 |
control.addFocusListener(focusListener); |
| 98 |
mouseListener = new MouseAdapter() { |
| 99 |
public void mouseDown(MouseEvent e) { |
| 100 |
// time wrap? |
| 101 |
// check for expiration of doubleClickTime |
| 102 |
if (e.time <= doubleClickExpirationTime) { |
| 103 |
control.removeMouseListener(mouseListener); |
| 104 |
cancelEditing(); |
| 105 |
handleDoubleClickEvent(); |
| 106 |
} else if (mouseListener != null) { |
| 107 |
control.removeMouseListener(mouseListener); |
| 108 |
} |
| 93 |
} |
109 |
} |
| 94 |
}; |
110 |
}; |
| 95 |
} |
111 |
control.addMouseListener(mouseListener); |
| 96 |
control.addFocusListener(focusListener); |
112 |
} |
| 97 |
mouseListener = new MouseAdapter() { |
|
|
| 98 |
public void mouseDown(MouseEvent e) { |
| 99 |
// time wrap? |
| 100 |
// check for expiration of doubleClickTime |
| 101 |
if (e.time <= doubleClickExpirationTime) { |
| 102 |
control.removeMouseListener(mouseListener); |
| 103 |
cancelEditing(); |
| 104 |
handleDoubleClickEvent(); |
| 105 |
} else if (mouseListener != null) { |
| 106 |
control.removeMouseListener(mouseListener); |
| 107 |
} |
| 108 |
} |
| 109 |
}; |
| 110 |
control.addMouseListener(mouseListener); |
| 111 |
} |
113 |
} |
| 112 |
} |
114 |
} |
| 113 |
|
115 |
|
|
Lines 305-311
Link Here
|
| 305 |
* by delegating to the cell modifier. |
307 |
* by delegating to the cell modifier. |
| 306 |
*/ |
308 |
*/ |
| 307 |
private void saveEditorValue(CellEditor cellEditor, Item tableItem) { |
309 |
private void saveEditorValue(CellEditor cellEditor, Item tableItem) { |
| 308 |
ViewerColumn part = (ViewerColumn)tableItem.getData(ViewerColumn.COLUMN_VIEWER_KEY); |
310 |
ViewerColumn part = viewer.getViewerColumn(columnNumber); |
| 309 |
|
311 |
|
| 310 |
if( part != null && part.getEditingSupport() != null ) { |
312 |
if( part != null && part.getEditingSupport() != null ) { |
| 311 |
part.getEditingSupport().setValue(tableItem.getData(), cellEditor.getValue()); |
313 |
part.getEditingSupport().setValue(tableItem.getData(), cellEditor.getValue()); |