This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 47857
Collapse All | Expand All

(-)src/org/openide/explorer/propertysheet/ComboInplaceEditor.java (-17 / +20 lines)
Lines 176-198 Link Here
176
    }
176
    }
177
177
178
    public void reset() {
178
    public void reset() {
179
        log ("Combo editor reset setting selected item to " + editor.getAsText());
179
        String targetValue = null;
180
        String targetValue = editor.getAsText();
180
        if (editor != null) {
181
        
181
            log ("Combo editor reset setting selected item to " + editor.getAsText());
182
        //issue 26367, form editor needs ability to set a custom value
182
            targetValue = editor.getAsText();
183
        //when editing is initiated (event handler combos, part of them
183
184
        //cleaning up their EnhancedPropertyEditors).  
184
            //issue 26367, form editor needs ability to set a custom value
185
        
185
            //when editing is initiated (event handler combos, part of them
186
        if (getClass() == ComboInplaceEditor.class && env != null && 
186
            //cleaning up their EnhancedPropertyEditors).  
187
            env.getFeatureDescriptor() != null) {
187
188
            
188
            if (getClass() == ComboInplaceEditor.class && env != null && 
189
            String initialEditValue = (String) env.getFeatureDescriptor().
189
                env.getFeatureDescriptor() != null) {
190
                getValue("initialEditValue"); //NOI18N
190
191
            
191
                String initialEditValue = (String) env.getFeatureDescriptor().
192
            if (initialEditValue != null) {
192
                    getValue("initialEditValue"); //NOI18N
193
                targetValue = initialEditValue;
193
194
                if (initialEditValue != null) {
195
                    targetValue = initialEditValue;
196
                }
197
194
            }
198
            }
195
            
196
        }
199
        }
197
        setSelectedItem(targetValue);
200
        setSelectedItem(targetValue);
198
    }
201
    }
Lines 453-459 Link Here
453
    /** A handy runnable which will ensure the popup is really displayed */
456
    /** A handy runnable which will ensure the popup is really displayed */
454
    private class PopupChecker implements Runnable {
457
    private class PopupChecker implements Runnable {
455
        public void run() {
458
        public void run() {
456
            if (isShowing() && !isPopupVisible()) {
459
            if (isShowing() && !isPopupVisible() && hasFocus()) {
457
                log ("Popup checker ensuring editor prepared or popup visible");
460
                log ("Popup checker ensuring editor prepared or popup visible");
458
                if (isEditable()) {
461
                if (isEditable()) {
459
                    prepareEditor();
462
                    prepareEditor();
(-)src/org/openide/explorer/propertysheet/CustomEditorAction.java (-18 / +28 lines)
Lines 88-110 Link Here
88
        final java.beans.PropertyEditor editor = 
88
        final java.beans.PropertyEditor editor = 
89
            PropUtils.getPropertyEditor (p);
89
            PropUtils.getPropertyEditor (p);
90
90
91
        //if there is no custom property editor...
92
        if (!editor.supportsCustomEditor()) {
93
            if (PropUtils.isLoggable(CustomEditorAction.class)) {
94
                PropUtils.log (CustomEditorAction.class, "Cant invoke custom " +
95
                    "editor for editor " + editor + " - it returns false " +
96
                    "from supportsCustomEditor()."); //NOI18N
97
            }
98
            //Somebody invoked it from the keyboard on an editor w/o custom editor
99
            Toolkit.getDefaultToolkit().beep();
100
            return;
101
        }
102
103
        final Component curComp = invoker.getCursorChangeComponent();
104
105
        Cursor cur = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
106
        curComp.setCursor (cur);
107
108
        //Create a new PropertyEnv to carry the values of the Property to the editor
91
        //Create a new PropertyEnv to carry the values of the Property to the editor
109
        PropertyEnv env = null;
92
        PropertyEnv env = null;
110
        if (editor instanceof ExPropertyEditor) {
93
        if (editor instanceof ExPropertyEditor) {
Lines 124-130 Link Here
124
            //Set up the editor with any hints from the property
107
            //Set up the editor with any hints from the property
125
            ((ExPropertyEditor) editor).attachEnv (env);
108
            ((ExPropertyEditor) editor).attachEnv (env);
126
        } 
109
        } 
110
        
111
        //if there is no custom property editor...
112
        if (!editor.supportsCustomEditor()) {
113
            if (PropUtils.isLoggable(CustomEditorAction.class)) {
114
                PropUtils.log (CustomEditorAction.class, "Cant invoke custom " +
115
                    "editor for editor " + editor + " - it returns false " +
116
                    "from supportsCustomEditor()."); //NOI18N
117
            }
118
            //Somebody invoked it from the keyboard on an editor w/o custom editor
119
            Toolkit.getDefaultToolkit().beep();
120
            return;
121
        }
122
        final Component curComp = invoker.getCursorChangeComponent();
127
123
124
        Cursor cur = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
125
        curComp.setCursor (cur);
126
        
128
//            customEditing = true;
127
//            customEditing = true;
129
        Object partialValue=invoker.getPartialValue();
128
        Object partialValue=invoker.getPartialValue();
130
129
Lines 211-217 Link Here
211
        WindowListener wl = new WindowAdapter() {
210
        WindowListener wl = new WindowAdapter() {
212
                public void windowClosed(WindowEvent e) {
211
                public void windowClosed(WindowEvent e) {
213
                    if (pdm.getComponent() instanceof EnhancedCustomPropertyEditor) {
212
                    if (pdm.getComponent() instanceof EnhancedCustomPropertyEditor) {
214
                        if (!pdm.wasCancelled()) {
213
                        if (!pdm.wasCancelled() && !closedOption && !pdm.wasOK() && !pdm.wasReset()) {
215
                            try {
214
                            try {
216
                                    //Enhanced custom property editors don't trigger property changes, so try to force it
215
                                    //Enhanced custom property editors don't trigger property changes, so try to force it
217
                                pdm.getEditor().setValue(((EnhancedCustomPropertyEditor) pdm.getComponent()).getPropertyValue());
216
                                pdm.getEditor().setValue(((EnhancedCustomPropertyEditor) pdm.getComponent()).getPropertyValue());
Lines 234-239 Link Here
234
                        Cursor.getPredefinedCursor(
233
                        Cursor.getPredefinedCursor(
235
                        Cursor.DEFAULT_CURSOR));
234
                        Cursor.DEFAULT_CURSOR));
236
                }
235
                }
236
                 // MCF ISSUE 44366 
237
                 public void windowClosing(WindowEvent ev) {
238
                     if (PropUtils.isLoggable(CustomEditorAction.class)) {
239
                        PropUtils.log (CustomEditorAction.class, 
240
                            "CustomerEditorAction windowClosing event");
241
                     }
242
                     closedOption = true;
243
                 }               
244
                 
245
                 //  MCF ISSUE 44366 
246
                 boolean closedOption = false;                
237
247
238
            };
248
            };
239
249
(-)src/org/openide/explorer/propertysheet/EditablePropertyDisplayer.java (-1 / +1 lines)
Lines 715-721 Link Here
715
        bp.setButtonAction(getCustomEditorAction());
715
        bp.setButtonAction(getCustomEditorAction());
716
    }
716
    }
717
    
717
    
718
    private Action getCustomEditorAction() {
718
    Action getCustomEditorAction() {
719
        if (customEditorAction == null) {
719
        if (customEditorAction == null) {
720
            PropertyModel mdl=null;;
720
            PropertyModel mdl=null;;
721
            if (modelRef != null) {
721
            if (modelRef != null) {
(-)src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java (+1 lines)
Lines 67-72 Link Here
67
        } else {
67
        } else {
68
            throw new IllegalStateException("This is not an array: " + details); // NOI18N
68
            throw new IllegalStateException("This is not an array: " + details); // NOI18N
69
        }
69
        }
70
        env.setChangeImmediate(false);
70
    }
71
    }
71
72
72
73
(-)src/org/openide/explorer/propertysheet/PropertyDialogManager.java (-9 / +40 lines)
Lines 20-25 Link Here
20
import javax.swing.JButton;
20
import javax.swing.JButton;
21
import javax.swing.JOptionPane;
21
import javax.swing.JOptionPane;
22
import javax.swing.JComponent;
22
import javax.swing.JComponent;
23
import javax.swing.UIManager;
23
import org.openide.DialogDescriptor;
24
import org.openide.DialogDescriptor;
24
25
25
import org.openide.nodes.Node;
26
import org.openide.nodes.Node;
Lines 212-227 Link Here
212
                defaultButton.getAccessibleContext().setAccessibleDescription(getString("ACSD_CTL_Default"));
213
                defaultButton.getAccessibleContext().setAccessibleDescription(getString("ACSD_CTL_Default"));
213
                defaultButton.setDefaultCapable(false);
214
                defaultButton.setDefaultCapable(false);
214
                defaultButton.setVerifyInputWhenFocusTarget(false);
215
                defaultButton.setVerifyInputWhenFocusTarget(false);
215
                options = new Object[] {
216
217
                if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
218
                    //Support Aqua button ordering
219
                    options = new Object[] {
216
                        defaultButton,
220
                        defaultButton,
221
                        cancelButton,
222
                        okButton
223
                    };
224
                } else {
225
                    options = new Object[] {
226
                            okButton,
227
                            defaultButton,
228
                            cancelButton
229
                    };
230
                }
231
            } else {
232
                if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
233
                    options = new Object[] {
234
                        cancelButton,
235
                        okButton
236
                    };
237
                } else {
238
                    options = new Object[] {
217
                        okButton,
239
                        okButton,
218
                        cancelButton
240
                        cancelButton
219
                };
241
                    };
220
            } else {
242
                }
221
                options = new Object[] {
222
                    okButton,
223
                    cancelButton
224
                };
225
            }
243
            }
226
            defaultOption = okButton;
244
            defaultOption = okButton;
227
        }
245
        }
Lines 408-414 Link Here
408
    public boolean wasCancelled() {
426
    public boolean wasCancelled() {
409
        return cancelled;
427
        return cancelled;
410
    }
428
    }
411
    
429
430
    private boolean ok = false;
431
    public boolean wasOK() {
432
        return ok;
433
    }
434
    private boolean reset = false;
435
    public boolean wasReset() {
436
        return reset;
437
    }
438
412
    /** Called when user presses a button on some option (button) in the
439
    /** Called when user presses a button on some option (button) in the
413
     * dialog.
440
     * dialog.
414
     * @param evt The button press event.
441
     * @param evt The button press event.
Lines 416-425 Link Here
416
    private void doButtonPressed(ActionEvent evt) {
443
    private void doButtonPressed(ActionEvent evt) {
417
        String label = evt.getActionCommand();
444
        String label = evt.getActionCommand();
418
        if (label.equals(getString("CTL_Cancel"))) {
445
        if (label.equals(getString("CTL_Cancel"))) {
419
            cancelled = true;
446
            cancelled = true; // XXX shouldn't this be reset otherwise?
420
            cancelValue();
447
            cancelValue();
421
        } 
448
        } 
449
        ok = false;
450
        reset = false;
422
        if (label.equals(getString("CTL_Default"))) {
451
        if (label.equals(getString("CTL_Default"))) {
452
            reset = true;
423
            if (prop != null) {
453
            if (prop != null) {
424
                try {
454
                try {
425
                    prop.restoreDefaultValue();
455
                    prop.restoreDefaultValue();
Lines 431-436 Link Here
431
            }
461
            }
432
        }
462
        }
433
        if ( label.equals(getString("CTL_OK"))) {
463
        if ( label.equals(getString("CTL_OK"))) {
464
            ok = true;
434
            if ((env!=null)&&(env.getState() == PropertyEnv.STATE_NEEDS_VALIDATION)) {
465
            if ((env!=null)&&(env.getState() == PropertyEnv.STATE_NEEDS_VALIDATION)) {
435
                env.setState(PropertyEnv.STATE_VALID);
466
                env.setState(PropertyEnv.STATE_VALID);
436
                if (env.getState() != PropertyEnv.STATE_VALID) {
467
                if (env.getState() != PropertyEnv.STATE_VALID) {
(-)src/org/openide/explorer/propertysheet/PropertyPanel.java (+32 lines)
Lines 30-35 Link Here
30
import java.beans.PropertyEditor;
30
import java.beans.PropertyEditor;
31
import java.beans.PropertyVetoException;
31
import java.beans.PropertyVetoException;
32
import java.beans.VetoableChangeListener;
32
import java.beans.VetoableChangeListener;
33
import javax.swing.Action;
33
import javax.swing.JComponent;
34
import javax.swing.JComponent;
34
35
35
import org.openide.nodes.Node;
36
import org.openide.nodes.Node;
Lines 248-253 Link Here
248
                System.err.println(""); //NOI18N
249
                System.err.println(""); //NOI18N
249
            }
250
            }
250
        });
251
        });
252
        getActionMap().put("invokeCustomEditor", new CustomEditorProxyAction()); //NOI18N
253
    }
254
255
    /**
256
     * Held in action map to allow TreeTableView to invoke the custom editor over read-only cells
257
     */
258
    private class CustomEditorProxyAction extends AbstractAction {
259
        Action wrapped = null;
260
        public void actionPerformed(ActionEvent e) {
261
            Action wrapped = getWrapped();
262
            if (wrapped != null) {
263
                wrapped.actionPerformed (e);
264
            }
265
        }
266
        
267
        public Action getWrapped() {
268
            Node.Property p = getProperty();
269
            EditablePropertyDisplayer pd = getPropertyDisplayer() instanceof EditablePropertyDisplayer ?
270
                (EditablePropertyDisplayer) getPropertyDisplayer() : new EditablePropertyDisplayer(p);
271
            
272
            return pd.getCustomEditorAction();
273
        }
274
275
        public boolean isEnabled() {
276
            Action wrapped = getWrapped();
277
            if (wrapped != null) {
278
                return wrapped.isEnabled();
279
            } else {
280
                return getProperty() != null;
281
            }
282
        }
251
    }
283
    }
252
    private boolean initializing = false;
284
    private boolean initializing = false;
253
    
285
    
(-)src/org/openide/explorer/view/TreeTable.java (-59 / +145 lines)
Lines 28-33 Link Here
28
import javax.swing.table.TableColumn;
28
import javax.swing.table.TableColumn;
29
import javax.swing.plaf.basic.BasicTableUI;
29
import javax.swing.plaf.basic.BasicTableUI;
30
import java.util.EventObject;
30
import java.util.EventObject;
31
import java.beans.PropertyEditor;
31
import javax.swing.plaf.TableUI;
32
import javax.swing.plaf.TableUI;
32
import javax.swing.table.JTableHeader;
33
import javax.swing.table.JTableHeader;
33
import javax.swing.table.TableCellEditor;
34
import javax.swing.table.TableCellEditor;
Lines 35-40 Link Here
35
import org.openide.nodes.Node.Property;
36
import org.openide.nodes.Node.Property;
36
import org.openide.nodes.Node;
37
import org.openide.nodes.Node;
37
import org.openide.ErrorManager;
38
import org.openide.ErrorManager;
39
import org.openide.explorer.propertysheet.PropertyPanel;
38
import org.openide.util.NbBundle;
40
import org.openide.util.NbBundle;
39
import org.openide.awt.MouseUtils;
41
import org.openide.awt.MouseUtils;
40
42
Lines 43-49 Link Here
43
 *
45
 *
44
 * @author Jan Rojcek
46
 * @author Jan Rojcek
45
 */
47
 */
46
class TreeTable extends JTable {
48
class TreeTable extends JTable implements Runnable {
47
    /** A subclass of JTree. */
49
    /** A subclass of JTree. */
48
    private TreeTableCellRenderer tree;
50
    private TreeTableCellRenderer tree;
49
    private NodeTableModel tableModel;
51
    private NodeTableModel tableModel;
Lines 73-80 Link Here
73
        this.tree = new TreeTableCellRenderer(treeModel);
75
        this.tree = new TreeTableCellRenderer(treeModel);
74
        this.tableModel = new TreeTableModelAdapter(tree, tableModel);
76
        this.tableModel = new TreeTableModelAdapter(tree, tableModel);
75
77
76
        NodeRenderer rend = NodeRenderer.sharedInstance ();
78
        tree.setCellRenderer(new NodeRenderer());
77
        tree.setCellRenderer(rend);
78
79
79
	// Install a tableModel representing the visible rows in the tree. 
80
	// Install a tableModel representing the visible rows in the tree. 
80
	setModel(this.tableModel);
81
	setModel(this.tableModel);
Lines 158-169 Link Here
158
        false), "beginEdit");
159
        false), "beginEdit");
159
        getActionMap().put("beginEdit", new EditAction());
160
        getActionMap().put("beginEdit", new EditAction());
160
        
161
        
161
        imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0,
162
        imp2.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0,
162
        false), "cancelEdit");
163
        false), "cancelEdit");
163
        getActionMap().put("cancelEdit", new CancelEditAction());
164
        getActionMap().put("cancelEdit", new CancelEditAction());
164
        
165
        
165
        imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0,
166
        imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0,
166
        false), "enter");
167
            false), "enter");
167
        getActionMap().put("enter", new EnterAction());
168
        getActionMap().put("enter", new EnterAction());
168
        
169
        
169
        imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "next");
170
        imp.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "next");
Lines 273-302 Link Here
273
    private void calcRowHeight(Graphics g) {
274
    private void calcRowHeight(Graphics g) {
274
        Font f = getFont();
275
        Font f = getFont();
275
        FontMetrics fm = g.getFontMetrics(f);
276
        FontMetrics fm = g.getFontMetrics(f);
276
        int rowHeight = fm.getHeight() + 4;
277
        int rowHeight = fm.getHeight() + fm.getMaxDescent();
277
        needCalcRowHeight = false;
278
        needCalcRowHeight = false;
278
        rowHeight = Math.min(20, rowHeight);
279
        rowHeight = Math.max(20, rowHeight);
279
        setRowHeight (rowHeight);
280
        tree.setRowHeight (rowHeight);
281
        setRowHeight(rowHeight);
280
    }    
282
    }    
281
283
282
    /*
283
     * Overridden to pass the new rowHeight to the tree.
284
     */
285
    public void setRowHeight(int rowHeight) { 
286
        super.setRowHeight(rowHeight); 
287
	if (tree != null && tree.getRowHeight() != rowHeight) {
288
            tree.setRowHeight(getRowHeight()); 
289
	}
290
    }
291
292
    /**
284
    /**
293
     * Returns the tree that is being shared between the model.
285
     * Returns the tree that is being shared between the model.
294
     */
286
     */
295
    JTree getTree() {
287
    JTree getTree() {
296
	return tree;
288
	return tree;
297
    }
289
    }
298
290
    
299
    /**
291
   /**
300
     * Returns table column index of the column displaying the tree.
292
     * Returns table column index of the column displaying the tree.
301
     */
293
     */
302
    int getTreeColumnIndex() {
294
    int getTreeColumnIndex() {
Lines 351-357 Link Here
351
        
343
        
352
        //Bypass standard tab and escape handling, and use our registered
344
        //Bypass standard tab and escape handling, and use our registered
353
        //actions instead
345
        //actions instead
354
        if ((e.getKeyCode() != e.VK_TAB && e.getKeyCode() != e.VK_ESCAPE) || (e.getModifiers() & e.CTRL_MASK) != 0) {
346
        if (!isEditing() || ((e.getKeyCode() != e.VK_TAB && e.getKeyCode() != e.VK_ESCAPE) || (e.getModifiers() & e.CTRL_MASK) != 0)) {
355
            super.processKeyEvent(e);
347
            super.processKeyEvent(e);
356
        } else {
348
        } else {
357
            processKeyBinding(KeyStroke.getKeyStroke(
349
            processKeyBinding(KeyStroke.getKeyStroke(
Lines 386-392 Link Here
386
            inEditRequest =false;
378
            inEditRequest =false;
387
            return false;
379
            return false;
388
        }
380
        }
389
        
381
390
        if (isEditing()) {
382
        if (isEditing()) {
391
            inEditorChangeRequest = true;
383
            inEditorChangeRequest = true;
392
            try {
384
            try {
Lines 396-402 Link Here
396
                inEditorChangeRequest = false;
388
                inEditorChangeRequest = false;
397
            }
389
            }
398
        }
390
        }
399
        
391
400
        //Treat a keyEvent request to edit on a non-editable
392
        //Treat a keyEvent request to edit on a non-editable
401
        //column as a request to edit the nearest column that is
393
        //column as a request to edit the nearest column that is
402
        //editable
394
        //editable
Lines 407-434 Link Here
407
            editable = false;
399
            editable = false;
408
            column = 1;
400
            column = 1;
409
        }
401
        }
410
        
402
403
        boolean columnShifted = false;
411
        if (!editable && (e instanceof KeyEvent || e == null)) {
404
        if (!editable && (e instanceof KeyEvent || e == null)) {
412
            for (int i=column; i < getColumnCount(); i++) {
405
            for (int i=column; i < getColumnCount(); i++) {
413
                if (getModel().isCellEditable(row, i)) {
406
                if (getModel().isCellEditable(row, i)) {
407
                    columnShifted = i != column;
414
                    column = i;
408
                    column = i;
415
                    changeSelection(row, column, false, false);
409
                    changeSelection(row, column, false, false);
416
                    break;
410
                    break;
417
                }
411
                }
418
            }
412
            }
419
        }
413
        }
420
        
414
421
        
415
        final Rectangle r = getCellRect (row, column, true);
416
        //#44226 - Provide a way to invoke the custom editor on disabled cells
417
        boolean canTryCustomEditor = !columnShifted && e instanceof MouseEvent ?
418
                ((MouseEvent) e).getX() > r.x + r.width - 24 && ((MouseEvent) e).getX() < r.x + r.width :
419
                true;
422
        try {
420
        try {
423
            canEdit = (lastRow == row);
421
            canEdit = (lastRow == row);
424
            Object o = getValueAt(row, column);
422
            Object o = getValueAt(row, column);
425
            if (o instanceof Property) { // && (e == null || e instanceof KeyEvent)) {
423
            if (o instanceof Property) { // && (e == null || e instanceof KeyEvent)) {
426
                //Toggle booleans without instantiating an editor
424
                //Toggle booleans without instantiating an editor
427
                Property p = (Property) o;
425
                Property p = (Property) o;
428
                if (p.getValueType() == Boolean.class || p.getValueType() == Boolean.TYPE) {
426
                if (p.canWrite() && (p.getValueType() == Boolean.class || p.getValueType() == Boolean.TYPE)) {
429
                    if (!p.canWrite()) {
430
                        return false;
431
                    }
432
                    try {
427
                    try {
433
                        Boolean val = (Boolean) p.getValue();
428
                        Boolean val = (Boolean) p.getValue();
434
                        if (Boolean.FALSE.equals(val)) {
429
                        if (Boolean.FALSE.equals(val)) {
Lines 437-470 Link Here
437
                            //This covers null multi-selections too
432
                            //This covers null multi-selections too
438
                            p.setValue(Boolean.FALSE);
433
                            p.setValue(Boolean.FALSE);
439
                        }
434
                        }
440
                        Rectangle r = getCellRect (row, column, true);
435
441
                        repaint (r.x, r.y, r.width, r.height);
436
                        repaint (r.x, r.y, r.width, r.height);
442
                        return false;
437
                        return false;
443
                    } catch (Exception e1) {
438
                    } catch (Exception e1) {
444
                        ErrorManager.getDefault().notify(ErrorManager.WARNING, e1);
439
                        ErrorManager.getDefault().notify(ErrorManager.WARNING, e1);
445
                        return false;
440
                        return false;
446
                    }
441
                    }
442
                } else if (canTryCustomEditor && !Boolean.TRUE.equals(p.getValue("suppressCustomEditor"))) { //NOI18N
443
                    PropertyPanel panel = new PropertyPanel (p);
444
                    PropertyEditor ed = panel.getPropertyEditor();
445
                    if (ed != null && ed.supportsCustomEditor()) {
446
                        Action act = panel.getActionMap().get("invokeCustomEditor"); //NOI18N
447
                        if (act != null) {
448
                            SwingUtilities.invokeLater (new Runnable(){
449
                                public void run() {
450
                                    r.x = 0;
451
                                    r.width = getWidth();
452
                                    TreeTable.this.repaint (r);
453
                                }
454
                            });
455
                            act.actionPerformed(null);
456
                            return false;
457
                        }
458
                    }
459
                }
460
                if (!p.canWrite()) {
461
                    return false;
447
                }
462
                }
448
            }
463
            }
449
                
464
450
465
451
            boolean ret = super.editCellAt(row, column, e);
466
            boolean ret = super.editCellAt(row, column, e);
452
            if (ret) {
467
            if (ret) {
453
                editorComp.requestFocus();
468
                //InvokeLater to get out of the way of anything the winsys is going to do
454
            }
469
            if (column == getTreeColumnIndex()) {
455
456
            if (ret && column == getTreeColumnIndex()) {
457
                ignoreScrolling = true;
470
                ignoreScrolling = true;
458
                tree.scrollRectToVisible(tree.getRowBounds(row));
471
                tree.scrollRectToVisible(tree.getRowBounds(row));
459
                ignoreScrolling = false;
472
                ignoreScrolling = false;
473
            } else {
474
                SwingUtilities.invokeLater (this);
460
            }
475
            }
476
        }
477
461
            return ret;
478
            return ret;
462
        } finally {
479
        } finally {
463
            inEditRequest = false;
480
            inEditRequest = false;
464
        }
481
        }
465
    }
482
    }
466
    
483
467
    /* 
484
    /**
485
     *
486
     */
487
    public void run() {
488
        if (editorComp != null && editorComp.isShowing()) {
489
            editorComp.requestFocus();
490
        }
491
    }
492
493
    /*
468
     */
494
     */
469
    public void valueChanged(ListSelectionEvent e) {
495
    public void valueChanged(ListSelectionEvent e) {
470
        if (getSelectedRowCount() == 1)
496
        if (getSelectedRowCount() == 1)
Lines 578-584 Link Here
578
        
604
        
579
	public TreeTableCellRenderer(TreeModel model) {
605
	public TreeTableCellRenderer(TreeModel model) {
580
	    super(model); 
606
	    super(model); 
581
            setRowHeight(getRowHeight()); 
582
            setToggleClickCount(0);
607
            setToggleClickCount(0);
583
            putClientProperty("JTree.lineStyle", "None"); // NOI18N
608
            putClientProperty("JTree.lineStyle", "None"); // NOI18N
584
	}
609
	}
Lines 599-618 Link Here
599
            //do nothing
624
            //do nothing
600
        }
625
        }
601
626
627
        /**
628
         * Accessor so NodeRenderer can check if the tree table or its child has
629
         * focus and paint with the appropriate color.
630
         *
631
         * @see NodeRenderer#configureFrom
632
         * @return The tree table
633
         */
634
        TreeTable getTreeTable() {
635
            return TreeTable.this;
636
        }
637
602
	/**
638
	/**
603
	 * Sets the row height of the tree, and forwards the row height to
639
	 * Sets the row height of the tree, and forwards the row height to
604
	 * the table.
640
	 * the table.
605
	 */
641
	 */
606
	public void setRowHeight(int rowHeight) { 
642
	public void setRowHeight(int rowHeight) {
607
	    if (rowHeight > 0) {
643
            if (rowHeight > 0) {
608
                synchronized (getTreeLock()) {
644
                super.setRowHeight(rowHeight); 
609
                    super.setRowHeight(rowHeight); 
645
                TreeTable.this.setRowHeight(rowHeight);
610
                    if (TreeTable.this != null &&
646
            }
611
                        TreeTable.this.getRowHeight() != rowHeight) {
612
                        TreeTable.this.setRowHeight(getRowHeight()); 
613
                    }
614
                }
615
	    }
616
	}
647
	}
617
648
618
	/**
649
	/**
Lines 701-714 Link Here
701
732
702
                boolean tableHasFocus = focusOwner == this || 
733
                boolean tableHasFocus = focusOwner == this || 
703
                    focusOwner == TreeTable.this
734
                    focusOwner == TreeTable.this
704
                    || TreeTable.this.isAncestorOf(focusOwner);
735
                    || TreeTable.this.isAncestorOf(focusOwner) ||
736
                    focusOwner instanceof JRootPane; //RootPane == popup menu
705
                
737
                
738
                //TODO - it should be possible to simply set the correct
739
                //color in prepareRenderer for the tree's cell renderer,
740
                //rather than set it for the whole tree.  Might fix a 
741
                //couple problems. -Tim
706
                setBackground(tableHasFocus ?
742
                setBackground(tableHasFocus ?
707
                    table.getSelectionBackground() :
743
                    table.getSelectionBackground() :
708
                    NodeRenderer.getNoFocusSelectionBackground());
744
                    getUnfocusedSelectedBackground());
709
                setForeground(tableHasFocus ?
745
                setForeground(tableHasFocus ?
710
                    table.getSelectionForeground() :
746
                    table.getSelectionForeground() :
711
                    NodeRenderer.getNoFocusSelectionForeground());
747
                    getUnfocusedSelectedForeground());
712
            } else {
748
            } else {
713
		setBackground(table.getBackground());
749
		setBackground(table.getBackground());
714
                setForeground(table.getForeground());
750
                setForeground(table.getForeground());
Lines 818-827 Link Here
818
        if (isEditing() && editorComp != null) {
854
        if (isEditing() && editorComp != null) {
819
            editorComp.setBackground(focused ?
855
            editorComp.setBackground(focused ?
820
                getSelectionBackground() :
856
                getSelectionBackground() :
821
                NodeRenderer.getNoFocusSelectionBackground());
857
                getUnfocusedSelectedBackground());
822
            editorComp.setForeground(focused ?
858
            editorComp.setForeground(focused ?
823
                getSelectionForeground() :
859
                getSelectionForeground() :
824
                NodeRenderer.getNoFocusSelectionForeground());
860
                getUnfocusedSelectedForeground());
825
        }
861
        }
826
    }
862
    }
827
863
Lines 1181-1187 Link Here
1181
		    int        min = listSelectionModel.getMinSelectionIndex();
1217
		    int        min = listSelectionModel.getMinSelectionIndex();
1182
		    int        max = listSelectionModel.getMaxSelectionIndex();
1218
		    int        max = listSelectionModel.getMaxSelectionIndex();
1183
1219
1184
		    this.clearSelection ();
1220
                    boolean unset = true;
1185
                    if(min != -1 && max != -1) {
1221
                    if(min != -1 && max != -1) {
1186
			for(int counter = min; counter <= max; counter++) {
1222
			for(int counter = min; counter <= max; counter++) {
1187
			    if(listSelectionModel.isSelectedIndex(counter)) {
1223
			    if(listSelectionModel.isSelectedIndex(counter)) {
Lines 1189-1199 Link Here
1189
				                            (counter);
1225
				                            (counter);
1190
1226
1191
				if(selPath != null) {
1227
				if(selPath != null) {
1192
				    addSelectionPath(selPath);
1228
                                    if (unset) {
1229
                                        setSelectionPath(selPath);
1230
                                        unset = false;
1231
                                    } else {
1232
                                        addSelectionPath(selPath);
1233
                                    }
1193
				}
1234
				}
1194
                            }
1235
                            }
1195
			}
1236
			}
1196
		    }
1237
		    }
1238
                    if (unset) {
1239
                        clearSelection();
1240
                    }
1197
		}
1241
		}
1198
		finally {
1242
		finally {
1199
		    updatingListSelectionModel = false;
1243
		    updatingListSelectionModel = false;
Lines 1323-1329 Link Here
1323
                    setDispatchComponent(e); 
1367
                    setDispatchComponent(e); 
1324
                    repostEvent(e); 
1368
                    repostEvent(e); 
1325
                } 
1369
                } 
1326
                else { 
1370
                
1371
                if (e.getID() == MouseEvent.MOUSE_PRESSED) {
1327
                    table.requestFocus();
1372
                    table.requestFocus();
1328
                }
1373
                }
1329
1374
Lines 1547-1554 Link Here
1547
        }
1592
        }
1548
        
1593
        
1549
        public boolean isEnabled() {
1594
        public boolean isEnabled() {
1550
            //            return isEditing();
1595
            return isEditing();
1551
            return true;
1552
        }
1596
        }
1553
    }
1597
    }
1554
    
1598
    
Lines 1611-1614 Link Here
1611
            }
1655
            }
1612
        }
1656
        }
1613
    }
1657
    }
1658
    
1659
    private static Color unfocusedSelBg = null;
1660
    private static Color unfocusedSelFg = null;
1661
    
1662
    /** Get the system-wide unfocused selection background color */
1663
    static Color getUnfocusedSelectedBackground() {
1664
        if (unfocusedSelBg == null) {
1665
            //allow theme/ui custom definition
1666
            unfocusedSelBg =
1667
            UIManager.getColor("nb.explorer.unfocusedSelBg"); //NOI18N
1668
            if (unfocusedSelBg == null) {
1669
                //try to get standard shadow color
1670
                unfocusedSelBg = UIManager.getColor("controlShadow"); //NOI18N
1671
                if (unfocusedSelBg == null) {
1672
                    //Okay, the look and feel doesn't suport it, punt
1673
                    unfocusedSelBg = Color.lightGray;
1674
                }
1675
                //Lighten it a bit because disabled text will use controlShadow/
1676
                //gray
1677
                unfocusedSelBg = unfocusedSelBg.brighter();
1678
            }
1679
        }
1680
        return unfocusedSelBg;
1681
    }
1682
    
1683
    /** Get the system-wide unfocused selection foreground color */
1684
    static Color getUnfocusedSelectedForeground() {
1685
        if (unfocusedSelFg == null) {
1686
            //allow theme/ui custom definition
1687
            unfocusedSelFg =
1688
            UIManager.getColor("nb.explorer.unfocusedSelFg"); //NOI18N
1689
            if (unfocusedSelFg == null) {
1690
                //try to get standard shadow color
1691
                unfocusedSelFg = UIManager.getColor("textText"); //NOI18N
1692
                if (unfocusedSelFg == null) {
1693
                    //Okay, the look and feel doesn't suport it, punt
1694
                    unfocusedSelFg = Color.BLACK;
1695
                }
1696
            }
1697
        }
1698
        return unfocusedSelFg;
1699
    }    
1614
}
1700
}
(-)src/org/openide/nodes/Index.java (-3 / +3 lines)
Lines 7-13 Link Here
7
 * http://www.sun.com/
7
 * http://www.sun.com/
8
 * 
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
12
 */
13
13
Lines 380-389 Link Here
380
    */
380
    */
381
    public int indexOf (final Node node) {
381
    public int indexOf (final Node node) {
382
        try {
382
        try {
383
            PR.enterWriteAccess ();
383
            PR.enterReadAccess ();
384
            return ((List)nodes).indexOf(node);
384
            return ((List)nodes).indexOf(node);
385
        } finally {
385
        } finally {
386
            PR.exitWriteAccess ();
386
            PR.exitReadAccess ();
387
        }
387
        }
388
    }
388
    }
389
389

Return to bug 47857