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 32143
Collapse All | Expand All

(-)src/org/openide/awt/MenuBar.java (-93 / +18 lines)
Lines 328-330 Link Here
328
            /** The items to be put into the menu */
329
            private List items;
330
            
Lines 397-412 Link Here
397
            private void doSetItems(List ll) {
394
    	    /** Updates the <code>JMenu</code> represented by this folder.
398
		JMenu m = LazyMenu.this;
399
        	m.removeAll();
400
                Iterator it = ll.iterator();
401
                
402
        	while (it.hasNext()) {
403
            	    JMenuItem item = (JMenuItem)it.next();
404
                    if (item == null) {
405
                        m.addSeparator();
406
                    } else {
407
                        m.add (item);
408
            	    }
409
        	}
410
            }
411
412
            /** Prepares the MenuItems from this folder.
413
--
Line 418 Link Here
400
		JMenu m = LazyMenu.this;
Line 420 Link Here
420
        	List cInstances = new LinkedList();
403
        	LinkedList cInstances = new LinkedList();
421
--
Line 423 Link Here
423
                final List output = new LinkedList();
406
        	m.removeAll();
424
--
Line 434 Link Here
434
		    output.add(item);
417
		    m.add(item);
435
--
Line 453 Link Here
453
                            output.add(null);
436
                	    m.addSeparator();
454
--
Line 456 Link Here
456
            		output.add((JMenuItem)obj);
439
            		m.add((JMenuItem)obj);
457
--
Line 458 Link Here
458
                	addSeparator = output.size() > 0;
441
                	addSeparator = getMenuComponentCount() > 0;
459
--
Line 461 Link Here
461
                            output.add(null);
444
                	    m.addSeparator();
462
--
Line 467 Link Here
467
                	output.add (item);
450
                	m.add (item);
468
--
Lines 470-525 Link Here
470
                
453
        	return m;
471
                items = output;
454
    	    }
472
                
455
473
        	return LazyMenu.this;
456
    	    /** Recreate the instance in AWT thread.
474
    	    }
457
    	     */
475
458
    	    protected Task postCreationTask (Runnable run) {
476
            // All this magic here is to allow the expensive menu creation
459
        	return new AWTTask (run);
477
            // occur out of AWT and only the live component update go in AWT
460
    	    }
478
            // The problem is that the resulting task must be deadlock proof
479
            // because it may be waited for it from inside AWT
480
            // If you know how to write it better, do it.
481
            protected Task postCreationTask (final Runnable run) {
482
                Task t = new Task() {
483
                    private Task pushingTask;
484
                    private Task creationTask = new Task(new Runnable() {
485
                        public void run() {
486
                            run.run();
487
                            // run the rest in AWT
488
                            pushingTask =  new AWTTask( new Runnable() {
489
                                public void run() {
490
                                    doSetItems(items);
491
                                }
492
                            });
493
                        }
494
                    });
495
496
                    public void run () {
497
                        try {
498
                            notifyRunning ();
499
                            
500
                            // this is the task that will create the MenuItems
501
                            // we do run it in this RP
502
                            creationTask.run();
503
                            pushingTask.waitFinished();                            
504
                            // doRun
505
                        } finally {
506
                            notifyFinished ();
507
                        }
508
                    }
509
                    public void waitFinished () {
510
                        // wait for MenuItems to be ready
511
                        creationTask.waitFinished();
512
                        
513
                        // if AWT waits for us, inline the menu setting
514
                        if (javax.swing.SwingUtilities.isEventDispatchThread ()) {
515
                            pushingTask.run ();
516
                        } else { // else let him keep waiting until AWT cacthes
517
                            // hopefully AWT is not waiting for him
518
                            super.waitFinished ();
519
                        }
520
                    }
521
                };
522
                // Start the recreation in default RP instead of the FI processor
523
                RequestProcessor.getDefault().post(t);
524
                return t;
525
            }
526
--
(-)src/org/openide/loaders/BrokenDataShadow.java (-19 / +6 lines)
Lines 76-84 Link Here
76
    private static Set getDataShadowsSet() {
76
    private static synchronized Set getDataShadowsSet() {
77
        if (allDataShadows == null) {
77
       if (allDataShadows == null) {
78
            synchronized (BrokenDataShadow.class) {
78
           allDataShadows = new HashSet();
79
                if (allDataShadows == null) {
79
       }
80
                    allDataShadows = new HashSet();
81
                }
82
            }
83
        }
84
        
85
--
Line 91 Link Here
91
    private static ReferenceQueue getRqueue() {
86
    private static synchronized ReferenceQueue getRqueue() {
92
--
Lines 93-97 Link Here
93
            synchronized (BrokenDataShadow.class) {
88
            rqueue = new ReferenceQueue();
94
                if (rqueue == null) {
95
                    rqueue = new ReferenceQueue();
96
                }
97
            }
98
--
Line 99 Link Here
99
        
(-)src/org/openide/loaders/DataNode.java (-8 / +5 lines)
Line 21 Link Here
21
import javax.swing.Action;
Line 268 Link Here
268
    *    the first action returned from getActions () method is used.
269
    *    the first action returned from getActions (false) method is used.
269
--
Line 270 Link Here
270
    public SystemAction getDefaultAction () {
271
    public Action getPreferredAction () {
271
--
Line 274 Link Here
274
            SystemAction action = super.getDefaultAction ();
275
            Action action = super.getPreferredAction ();
275
--
Line 278 Link Here
278
            SystemAction[] arr = getActions ();
279
            Action[] arr = getActions(false);
279
--
(-)src/org/openide/loaders/DataShadow.java (-18 / +4 lines)
Line 64 Link Here
64
    private static Set getDataShadowsSet() {
64
    private static synchronized Set getDataShadowsSet() {
65
--
Lines 66-70 Link Here
66
            synchronized (DataShadow.class) {
66
            allDataShadows = new HashSet();
67
                if (allDataShadows == null) {
68
                    allDataShadows = new HashSet();
69
                }
70
            }
71
--
Line 72 Link Here
72
        
Line 79 Link Here
79
    private static ReferenceQueue getRqueue() {
74
    private static synchronized ReferenceQueue getRqueue() {
80
--
Lines 81-85 Link Here
81
            synchronized (DataShadow.class) {
76
            rqueue = new ReferenceQueue();
82
                if (rqueue == null) {
83
                    rqueue = new ReferenceQueue();
84
                }
85
            }
86
--
Line 87 Link Here
87
        
(-)src/org/openide/loaders/InstanceNode.java (-34 / +25 lines)
Line 29 Link Here
29
import javax.swing.Action;
Line 37 Link Here
37
import org.openide.util.actions.*;
Lines 226-235 Link Here
226
            // Also specially handle SystemAction's.
226
            // Also specially handle action instances.
227
            if (SystemAction.class.isAssignableFrom (clazz)) {
227
            if (beanInfoIcon == null && Action.class.isAssignableFrom(clazz)) {
228
                SystemAction action = SystemAction.get (clazz);
228
                Action action = (Action)ic.instanceCreate();
229
                if (beanInfoIcon == null) {
229
                Icon icon = (Icon)action.getValue(Action.SMALL_ICON);
230
                    Icon icon = action.getIcon ();
230
                // [PENDING] not very pretty, but there is no good way to
231
                    // [PENDING] not very pretty, but there is no good way to
231
                // get an Image from an Icon that I know of
232
                    // get an Image from an Icon that I know of
232
                if (icon instanceof ImageIcon) {
233
                    if (icon instanceof ImageIcon) {
233
                    beanInfoIcon = ((ImageIcon)icon).getImage();
234
                        beanInfoIcon = ((ImageIcon) icon).getImage ();
234
                } else {
235
                    }
235
                    beanInfoIcon = Utilities.loadImage("org/openide/resources/actions/empty.gif", true); // NOI18N
236
--
Line 253 Link Here
253
        Class clazz;
Lines 257-261 Link Here
257
            clazz = ic.instanceClass();
256
            Class clazz = ic.instanceClass();
258
        } catch (Exception e) {
259
            ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, e);
260
            return;
261
        }
262
--
Lines 271-273 Link Here
271
        // Also specially handle SystemAction's.
266
        // Also specially handle action instances.
272
        if (SystemAction.class.isAssignableFrom (clazz)) {
267
        if (Action.class.isAssignableFrom(clazz)) {
273
            SystemAction action = SystemAction.get (clazz);
268
            Action action = (Action)ic.instanceCreate();
274
--
Line 275 Link Here
275
            String name = action.getName ();
270
            String name = (String)action.getValue(Action.NAME);
276
--
Lines 280-281 Link Here
280
                ErrorManager.getDefault().notify(
275
                ErrorManager.getDefault().log(ErrorManager.WARNING,
281
                    new RuntimeException("Please attach following information to the issue " + // NOI18N
276
                    "Please attach following information to the issue " + // NOI18N
282
--
Line 283 Link Here
283
                    "SystemAction " + className + " does not implement getName() properly. It returns null!")); // NOI18N
278
                    "action " + className + " does not implement SystemAction.getName() or Action.getValue(NAME) properly. It returns null!"); // NOI18N
284
--
Line 297 Link Here
297
        setDisplayName(getDataObject().getName());
292
        } catch (Exception e) {
298
--
293
            ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, e);
294
            setDisplayName(getDataObject().getName());
295
            return;
296
        }
Line 595 Link Here
595
    public SystemAction getDefaultAction() {
594
    public Action getPreferredAction() {
596
--
(-)src/org/openide/loaders/TemplateWizard.java (-16 / +9 lines)
Lines 259-263 Link Here
259
        if (templateChooser == null) {
259
        synchronized (this) {
260
            synchronized (this) {
260
            if (templateChooser == null) {
261
                if (templateChooser == null) {
261
                templateChooser = createTemplateChooser ();
262
                    templateChooser = createTemplateChooser ();
263
                }
264
--
Lines 274-278 Link Here
274
        if (targetChooser == null) {
272
        synchronized (this) {
275
            synchronized (this) {
273
            if (targetChooser == null) {
276
                if (targetChooser == null) {
274
                targetChooser = createTargetChooser ();
277
                    targetChooser = createTargetChooser ();
278
                }
279
--
Lines 287-289 Link Here
287
                if (targetIterator == null) {
283
        if (targetIterator == null) {
288
                    targetIterator = createDefaultIterator ();
284
            targetIterator = createDefaultIterator ();
289
                }
285
        }
290
--
(-)src/org/openide/loaders/XMLDataObject.java (-6 / +3 lines)
Lines 198-202 Link Here
198
        if (infoParser == null) {
198
        synchronized (emgrLock) {
199
            synchronized (emgrLock) {
199
            if (infoParser == null) {
200
                if (infoParser == null) {
200
                infoParser = new InfoParser ();
201
                    infoParser = new InfoParser ();
202
                }
203
--

Return to bug 32143