Index: src/org/openide/awt/MenuBar.java =================================================================== RCS file: /cvs/openide/src/org/openide/awt/MenuBar.java,v --- src/org/openide/awt/MenuBar.java 1.50 +++ src/org/openide/awt/MenuBar.java @@ -328,3 +328,0 @@ - /** The items to be put into the menu */ - private List items; - @@ -397,16 +394,1 @@ - 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. @@ -418,0 +400,1 @@ + JMenu m = LazyMenu.this; @@ -420,1 +403,1 @@ - List cInstances = new LinkedList(); --- + LinkedList cInstances = new LinkedList(); @@ -423,1 +406,1 @@ - final List output = new LinkedList(); --- + m.removeAll(); @@ -434,1 +417,1 @@ - output.add(item); --- + m.add(item); @@ -453,1 +436,1 @@ - output.add(null); --- + m.addSeparator(); @@ -456,1 +439,1 @@ - output.add((JMenuItem)obj); --- + m.add((JMenuItem)obj); @@ -458,1 +441,1 @@ - addSeparator = output.size() > 0; --- + addSeparator = getMenuComponentCount() > 0; @@ -461,1 +444,1 @@ - output.add(null); --- + m.addSeparator(); @@ -467,1 +450,1 @@ - output.add (item); --- + m.add (item); @@ -470,56 +453,8 @@ - - 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 --- src/org/openide/loaders/BrokenDataShadow.java 1.14 +++ src/org/openide/loaders/BrokenDataShadow.java @@ -76,9 +76,4 @@ - 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(); + } @@ -91,1 +86,1 @@ - private static ReferenceQueue getRqueue() { --- + private static synchronized ReferenceQueue getRqueue() { @@ -93,5 +88,1 @@ - synchronized (BrokenDataShadow.class) { - if (rqueue == null) { - rqueue = new ReferenceQueue(); - } - } --- + rqueue = new ReferenceQueue(); @@ -99,1 +90,0 @@ - Index: src/org/openide/loaders/DataNode.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/DataNode.java,v --- src/org/openide/loaders/DataNode.java 1.81 +++ src/org/openide/loaders/DataNode.java @@ -21,0 +21,1 @@ +import javax.swing.Action; @@ -268,1 +269,1 @@ - * the first action returned from getActions () method is used. --- + * the first action returned from getActions (false) method is used. @@ -270,1 +271,1 @@ - public SystemAction getDefaultAction () { --- + public Action getPreferredAction () { @@ -274,1 +275,1 @@ - SystemAction action = super.getDefaultAction (); --- + Action action = super.getPreferredAction (); @@ -278,1 +279,1 @@ - 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 --- src/org/openide/loaders/DataShadow.java 1.50 +++ src/org/openide/loaders/DataShadow.java @@ -64,1 +64,1 @@ - private static Set getDataShadowsSet() { --- + private static synchronized Set getDataShadowsSet() { @@ -66,5 +66,1 @@ - synchronized (DataShadow.class) { - if (allDataShadows == null) { - allDataShadows = new HashSet(); - } - } --- + allDataShadows = new HashSet(); @@ -72,1 +68,0 @@ - @@ -79,1 +74,1 @@ - private static ReferenceQueue getRqueue() { --- + private static synchronized ReferenceQueue getRqueue() { @@ -81,5 +76,1 @@ - synchronized (DataShadow.class) { - if (rqueue == null) { - rqueue = new ReferenceQueue(); - } - } --- + rqueue = new ReferenceQueue(); @@ -87,1 +78,0 @@ - Index: src/org/openide/loaders/InstanceNode.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/InstanceNode.java,v --- src/org/openide/loaders/InstanceNode.java 1.30 +++ src/org/openide/loaders/InstanceNode.java @@ -29,0 +29,1 @@ +import javax.swing.Action; @@ -37,1 +38,0 @@ -import org.openide.util.actions.*; @@ -226,10 +226,10 @@ - // 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 @@ -253,1 +253,0 @@ - Class clazz; @@ -257,5 +256,1 @@ - clazz = ic.instanceClass(); - } catch (Exception e) { - ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, e); - return; - } --- + Class clazz = ic.instanceClass(); @@ -271,3 +266,3 @@ - // 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(); @@ -275,1 +270,1 @@ - String name = action.getName (); --- + String name = (String)action.getValue(Action.NAME); @@ -280,2 +275,2 @@ - 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 @@ -283,1 +278,1 @@ - "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 @@ -297,1 +292,5 @@ - setDisplayName(getDataObject().getName()); --- + } catch (Exception e) { + ErrorManager.getDefault ().notify (ErrorManager.INFORMATIONAL, e); + setDisplayName(getDataObject().getName()); + return; + } @@ -595,1 +594,1 @@ - public SystemAction getDefaultAction() { --- + public Action getPreferredAction() { Index: src/org/openide/loaders/TemplateWizard.java =================================================================== RCS file: /cvs/openide/src/org/openide/loaders/TemplateWizard.java,v --- src/org/openide/loaders/TemplateWizard.java 1.69 +++ src/org/openide/loaders/TemplateWizard.java @@ -259,5 +259,3 @@ - if (templateChooser == null) { - synchronized (this) { - if (templateChooser == null) { - templateChooser = createTemplateChooser (); - } --- + synchronized (this) { + if (templateChooser == null) { + templateChooser = createTemplateChooser (); @@ -274,5 +272,3 @@ - if (targetChooser == null) { - synchronized (this) { - if (targetChooser == null) { - targetChooser = createTargetChooser (); - } --- + synchronized (this) { + if (targetChooser == null) { + targetChooser = createTargetChooser (); @@ -287,3 +283,3 @@ - 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 --- src/org/openide/loaders/XMLDataObject.java 1.132 +++ src/org/openide/loaders/XMLDataObject.java @@ -198,5 +198,3 @@ - if (infoParser == null) { - synchronized (emgrLock) { - if (infoParser == null) { - infoParser = new InfoParser (); - } --- + synchronized (emgrLock) { + if (infoParser == null) { + infoParser = new InfoParser ();