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.

Bug 93884 - AJAX components can be added only for one project
Summary: AJAX components can be added only for one project
Status: VERIFIED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 5.x
Hardware: PC Windows XP
: P2 blocker (vote)
Assignee: Peter Zavadsky
URL:
Keywords: RELNOTE
Depends on:
Blocks:
 
Reported: 2007-02-01 22:31 UTC by bugbridge
Modified: 2007-04-27 22:56 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bugbridge 2007-02-01 22:31:26 UTC
Original status: 6-Fix Understood; Suggested Status: NEW

Original Target Release: shortfin_dev; Suggested Target Milestone : 5.5

These items should be added to the Keywords: RELNOTE

Original submitter: alexeybutenko

Description:
Pack RC1

Steps:
 - Create project
 - Create second project
 - Add BluePrints AJAX Components library to the first project.
AJAX components doesn't appeared in Palette, it will appear only after adding
components library
to second project

Evaluation:
Component import issue; assigning to Edwin.

Evaluation (Entry 2):
The bug is in designer code so I am reassigning this to PeterZ. The workaround
is to "Refresh Palette" from the palette category context menu.

Here is my analysis: This is a palette refresh problem. Each JsfForm seems to
have its own PaletteController. The PaletteController also has a PaletteFilter.
Whenever a new JsfForm is created, a new PaletteController and PaletteFilter is
created and a singleton ComplibListener is set to the last PaletteController
that was created. First this happens for project #1 then project #2. When the
user switches back to project #1, the Listener is still set to PaletteController
#2. So when a complib is added to project #1, the Listener notifies
PaletteController #2 instead of #1.

See
designer/jsf/src/.../PaletteControllerFactory.JsfComplibListener.paletteChanged().
In that method, PaletteController.refresh() is called on the wrong
PaletteController.

Evaluation (Entry 3):
Correct, the mistake is that the listener is singleton and notifies only last
palette congtoller used. Preparing fix.

Evaluation (Entry 4):
See suggested fix for the diff. It makes the bridge (renamed more
appropriatelly) to keep refs to all palette controllers and refresh them based
on changes in the comp lib.

Workaround:
The workaround is to "Refresh Palette" from the palette category context menu.

Suggested Fix:
Diff of suggested fix:

Index: xxx/designer/jsf/src/com/sun/rave/designer/jsf/PaletteControllerFactory.java
===================================================================
RCS file:
xxx/designer/jsf/src/com/sun/rave/designer/jsf/PaletteControllerFactory.java,v
retrieving revision 1.1
diff -u -r1.1 PaletteControllerFactory.java
--- designer/jsf/src/com/sun/rave/designer/jsf/PaletteControllerFactory.java   
13 Oct 2006 20:56:06 -0000      1.1
+++ designer/jsf/src/com/sun/rave/designer/jsf/PaletteControllerFactory.java   
28 Nov 2006 18:12:56 -0000
@@ -17,7 +17,8 @@
 import java.awt.event.ActionEvent;
 import java.io.File;
 import java.io.IOException;
-import java.lang.ref.WeakReference;
+import java.util.HashSet;
+import java.util.Set;
 import javax.swing.AbstractAction;
 import javax.swing.Action;
 import org.netbeans.api.project.Project;
@@ -34,6 +35,7 @@
 import org.openide.nodes.Node;
 import org.openide.util.Lookup;
 import org.openide.util.NbBundle;
+import org.openide.util.WeakSet;

 /**
  * Factory for creating JSF <code>PaletteController</code>.
@@ -90,8 +92,8 @@
                     new JsfPaletteActions(paletteDirectory),
complibPaletteFilter, null);

             // XXX #6466711 Listening to changes of complib to refresh the palette.
-            JsfComplibListener.getDefault().install();
-            JsfComplibListener.getDefault().setPaletteController(controller);
+            JsfComplibListenerBridge.getDefault().install();
+            JsfComplibListenerBridge.getDefault().addPaletteController(controller);

             return controller;
         } catch (IOException ex) {
@@ -107,14 +109,14 @@
     }


-    private static class JsfComplibListener implements ComplibListener {
-        private static JsfComplibListener INSTANCE = new JsfComplibListener();
+    private static class JsfComplibListenerBridge implements ComplibListener {
+        private static JsfComplibListenerBridge INSTANCE = new
JsfComplibListenerBridge();

-        private WeakReference<PaletteController> paletteControllerWRef = new
WeakReference<PaletteController>(null);
+        private final Set<PaletteController> paletteControllers = new
WeakSet/*<PaletteController>*/();

         private boolean installed;

-        public static JsfComplibListener getDefault() {
+        public static JsfComplibListenerBridge getDefault() {
             return INSTANCE;
         }

@@ -139,18 +141,19 @@
             installed = false;
         }

-        public void setPaletteController(PaletteController paletteController) {
-            paletteControllerWRef = new
WeakReference<PaletteController>(paletteController);
+        public void addPaletteController(PaletteController paletteController) {
+            paletteControllers.add(paletteController);
         }

         public void paletteChanged(ComplibEvent evt) {
-            PaletteController paletteController = paletteControllerWRef.get();
-            if (paletteController == null) {
-                return;
+            Set<PaletteController> controllers = new HashSet(paletteControllers);
+            for (PaletteController controller : controllers) {
+                if (controller != null) {
+                    controller.refresh();
+                }
             }
-            paletteController.refresh();
         }
-    } // End of JsfComplibListener
+    } // End of JsfComplibListenerBridge.


     // XXX Moved from designer/DesignerPaletteActions.
Comment 1 Peter Zavadsky 2007-02-20 21:51:51 UTC
This was fixed already.
Comment 2 Lark Fitzgerald 2007-04-27 22:56:05 UTC
verified using 6.0 04270000