Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 154289 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jface/viewers/TreeEditorImpl.java (-35 / +37 lines)
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, treeItem, columnNumber);
87
                setLayoutData(cellEditor.getLayoutData());
88
            cellEditor.setFocus();
88
                setEditor(control, treeItem, 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 310-316 Link Here
310
     * by delegating to the cell modifier.
312
     * by delegating to the cell modifier.
311
     */
313
     */
312
    private void saveEditorValue(CellEditor cellEditor, Item treeItem) {
314
    private void saveEditorValue(CellEditor cellEditor, Item treeItem) {
313
    	ViewerColumn part = (ViewerColumn)treeItem.getData(ViewerColumn.COLUMN_VIEWER_KEY);
315
    	ViewerColumn part = viewer.getViewerColumn(columnNumber);
314
    	
316
    	
315
    	if( part != null && part.getEditingSupport() != null ) {
317
    	if( part != null && part.getEditingSupport() != null ) {
316
        	part.getEditingSupport().setValue(treeItem.getData(), cellEditor.getValue());
318
        	part.getEditingSupport().setValue(treeItem.getData(), cellEditor.getValue());
(-)src/org/eclipse/jface/viewers/TableEditorImpl.java (-35 / +37 lines)
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());

Return to bug 154289