Index: src/org/openide/awt/MenuBar.java =================================================================== RCS file: /cvs/openide/src/org/openide/awt/MenuBar.java,v retrieving revision 1.49 retrieving revision 1.50 diff -r1.49 -r1.50 328,330d327 < /** The items to be put into the menu */ < private List items; < 397,412c394 < private void doSetItems(List ll) { < JMenu m = LazyMenu.this; < m.removeAll(); < Iterator it = ll.iterator(); < < while (it.hasNext()) { < JMenuItem item = (JMenuItem)it.next(); < if (item == null) { < m.addSeparator(); < } else { < m.add (item); < } < } < } < < /** Prepares the MenuItems from this folder. --- > /** Updates the JMenu represented by this folder. 417a400 > JMenu m = LazyMenu.this; 420c403 < List cInstances = new LinkedList(); --- > LinkedList cInstances = new LinkedList(); 423c406 < final List output = new LinkedList(); --- > m.removeAll(); 434c417 < output.add(item); --- > m.add(item); 453c436 < output.add(null); --- > m.addSeparator(); 456c439 < output.add((JMenuItem)obj); --- > m.add((JMenuItem)obj); 458c441 < addSeparator = output.size() > 0; --- > addSeparator = getMenuComponentCount() > 0; 461c444 < output.add(null); --- > m.addSeparator(); 467c450 < output.add (item); --- > m.add (item); 470,525c453,460 < < items = output; < < return LazyMenu.this; < } < < // All this magic here is to allow the expensive menu creation < // occur out of AWT and only the live component update go in AWT < // The problem is that the resulting task must be deadlock proof < // because it may be waited for it from inside AWT < // If you know how to write it better, do it. < protected Task postCreationTask (final Runnable run) { < Task t = new Task() { < private Task pushingTask; < private Task creationTask = new Task(new Runnable() { < public void run() { < run.run(); < // run the rest in AWT < pushingTask = new AWTTask( new Runnable() { < public void run() { < doSetItems(items); < } < }); < } < }); < < public void run () { < try { < notifyRunning (); < < // this is the task that will create the MenuItems < // we do run it in this RP < creationTask.run(); < pushingTask.waitFinished(); < // doRun < } finally { < notifyFinished (); < } < } < public void waitFinished () { < // wait for MenuItems to be ready < creationTask.waitFinished(); < < // if AWT waits for us, inline the menu setting < if (javax.swing.SwingUtilities.isEventDispatchThread ()) { < pushingTask.run (); < } else { // else let him keep waiting until AWT cacthes < // hopefully AWT is not waiting for him < super.waitFinished (); < } < } < }; < // Start the recreation in default RP instead of the FI processor < RequestProcessor.getDefault().post(t); < return t; < } --- > return m; > } > > /** Recreate the instance in AWT thread. > */ > protected Task postCreationTask (Runnable run) { > return new AWTTask (run); > } Index: src/org/openide/loaders/BrokenDataShadow.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/BrokenDataShadow.java,v retrieving revision 1.13 retrieving revision 1.14 diff -r1.13 -r1.14 76,84c76,79 < private static Set getDataShadowsSet() { < if (allDataShadows == null) { < synchronized (BrokenDataShadow.class) { < if (allDataShadows == null) { < allDataShadows = new HashSet(); < } < } < } < --- > private static synchronized Set getDataShadowsSet() { > if (allDataShadows == null) { > allDataShadows = new HashSet(); > } 91c86 < private static ReferenceQueue getRqueue() { --- > private static synchronized ReferenceQueue getRqueue() { 93,97c88 < synchronized (BrokenDataShadow.class) { < if (rqueue == null) { < rqueue = new ReferenceQueue(); < } < } --- > rqueue = new ReferenceQueue(); 99d89 < Index: src/org/openide/loaders/DataNode.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/DataNode.java,v retrieving revision 1.80 retrieving revision 1.81 diff -r1.80 -r1.81 20a21 > import javax.swing.Action; 268c269 < * the first action returned from getActions () method is used. --- > * the first action returned from getActions (false) method is used. 270c271 < public SystemAction getDefaultAction () { --- > public Action getPreferredAction () { 274c275 < SystemAction action = super.getDefaultAction (); --- > Action action = super.getPreferredAction (); 278c279 < SystemAction[] arr = getActions (); --- > Action[] arr = getActions(false); Index: src/org/openide/loaders/DataShadow.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/DataShadow.java,v retrieving revision 1.49 retrieving revision 1.50 diff -r1.49 -r1.50 64c64 < private static Set getDataShadowsSet() { --- > private static synchronized Set getDataShadowsSet() { 66,70c66 < synchronized (DataShadow.class) { < if (allDataShadows == null) { < allDataShadows = new HashSet(); < } < } --- > allDataShadows = new HashSet(); 72d67 < 79c74 < private static ReferenceQueue getRqueue() { --- > private static synchronized ReferenceQueue getRqueue() { 81,85c76 < synchronized (DataShadow.class) { < if (rqueue == null) { < rqueue = new ReferenceQueue(); < } < } --- > rqueue = new ReferenceQueue(); 87d77 < Index: src/org/openide/loaders/InstanceNode.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/InstanceNode.java,v retrieving revision 1.29 retrieving revision 1.30 diff -r1.29 -r1.30 28a29 > import javax.swing.Action; 37d37 < import org.openide.util.actions.*; 226,235c226,235 < // Also specially handle SystemAction's. < if (SystemAction.class.isAssignableFrom (clazz)) { < SystemAction action = SystemAction.get (clazz); < if (beanInfoIcon == null) { < Icon icon = action.getIcon (); < // [PENDING] not very pretty, but there is no good way to < // get an Image from an Icon that I know of < if (icon instanceof ImageIcon) { < beanInfoIcon = ((ImageIcon) icon).getImage (); < } --- > // Also specially handle action instances. > if (beanInfoIcon == null && Action.class.isAssignableFrom(clazz)) { > Action action = (Action)ic.instanceCreate(); > Icon icon = (Icon)action.getValue(Action.SMALL_ICON); > // [PENDING] not very pretty, but there is no good way to > // get an Image from an Icon that I know of > if (icon instanceof ImageIcon) { > beanInfoIcon = ((ImageIcon)icon).getImage(); > } else { > beanInfoIcon = Utilities.loadImage("org/openide/resources/actions/empty.gif", true); // NOI18N 253d252 < Class clazz; 257,261c256 < clazz = ic.instanceClass(); < } catch (Exception e) { < ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, e); < return; < } --- > Class clazz = ic.instanceClass(); 271,273c266,268 < // Also specially handle SystemAction's. < if (SystemAction.class.isAssignableFrom (clazz)) { < SystemAction action = SystemAction.get (clazz); --- > // Also specially handle action instances. > if (Action.class.isAssignableFrom(clazz)) { > Action action = (Action)ic.instanceCreate(); 275c270 < String name = action.getName (); --- > String name = (String)action.getValue(Action.NAME); 280,281c275,276 < ErrorManager.getDefault().notify( < new RuntimeException("Please attach following information to the issue " + // NOI18N --- > ErrorManager.getDefault().log(ErrorManager.WARNING, > "Please attach following information to the issue " + // NOI18N 283c278 < "SystemAction " + className + " does not implement getName() properly. It returns null!")); // NOI18N --- > "action " + className + " does not implement SystemAction.getName() or Action.getValue(NAME) properly. It returns null!"); // NOI18N 297c292,296 < setDisplayName(getDataObject().getName()); --- > } catch (Exception e) { > ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, e); > setDisplayName(getDataObject().getName()); > return; > } 595c594 < public SystemAction getDefaultAction() { --- > public Action getPreferredAction() { Index: src/org/openide/loaders/TemplateWizard.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/TemplateWizard.java,v retrieving revision 1.68 retrieving revision 1.69 diff -r1.68 -r1.69 259,263c259,261 < if (templateChooser == null) { < synchronized (this) { < if (templateChooser == null) { < templateChooser = createTemplateChooser (); < } --- > synchronized (this) { > if (templateChooser == null) { > templateChooser = createTemplateChooser (); 274,278c272,274 < if (targetChooser == null) { < synchronized (this) { < if (targetChooser == null) { < targetChooser = createTargetChooser (); < } --- > synchronized (this) { > if (targetChooser == null) { > targetChooser = createTargetChooser (); 287,289c283,285 < if (targetIterator == null) { < targetIterator = createDefaultIterator (); < } --- > if (targetIterator == null) { > targetIterator = createDefaultIterator (); > } Index: src/org/openide/loaders/XMLDataObject.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/XMLDataObject.java,v retrieving revision 1.131 retrieving revision 1.132 diff -r1.131 -r1.132 198,202c198,200 < if (infoParser == null) { < synchronized (emgrLock) { < if (infoParser == null) { < infoParser = new InfoParser (); < } --- > synchronized (emgrLock) { > if (infoParser == null) { > infoParser = new InfoParser ();