ChoiceView and strange Visualizer problem

View: New views
4 Messages — Rating Filter:   Alert me  

ChoiceView and strange Visualizer problem

by jmborer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I just wanted to try different view types for data nodes. I used the
sample from Selection tutorial that you can find
http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=3146

Then in "MyEditor" I replaced, new BeanTreeView by ChoiceView, making
sure that it is no longer a JScrollPane but a JCombobox. When I run
the application I get this strange error:

java.lang.ClassCastException: java.lang.String cannot be cast to
org.openide.explorer.view.VisualizerNode
        at org.openide.explorer.view.NodeRenderer.findVisualizerNode(NodeRenderer.java:232)
        at org.openide.explorer.view.NodeRenderer.getListCellRendererComponent(NodeRenderer.java:152)
        at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(BasicComboBoxUI.java:1202)
        at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.paintCurrentValue(WindowsComboBoxUI.java:293)
        at javax.swing.plaf.basic.BasicComboBoxUI.paint(BasicComboBoxUI.java:888)
        at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.paint(WindowsComboBoxUI.java:199)
        at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
        at javax.swing.JComponent.paintComponent(JComponent.java:763)
        at javax.swing.JComponent.paint(JComponent.java:1029)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at org.netbeans.swing.tabcontrol.TabbedContainer.paint(TabbedContainer.java:968)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at org.netbeans.core.windows.view.ui.MultiSplitPane.paint(MultiSplitPane.java:325)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:567)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:567)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
        at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:278)
        at javax.swing.RepaintManager.paint(RepaintManager.java:1220)
        at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
        at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:803)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)
        at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:694)
[catch] at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Looking at the sources of NodeRenderer there is this very strange line:

VisualizerNode vis = (value instanceof Node) ?
VisualizerNode.getVisualizer(null, (Node) value)
                                                     : (VisualizerNode) value;

where the value seems to be a String. Isn't this an error? Why cast to
VisualizerNode when the value isn't a Visualizer???

I am using Netbeans 6.7.1. Any one running into this issue? I am
missing something?

Cheers

Jean-Marc

Re: ChoiceView and strange Visualizer problem

by Tim Boudreau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

jmborer wrote:
I just wanted to try different view types for data nodes. I used the
sample from Selection tutorial that you can find
http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=3146

Then in "MyEditor" I replaced, new BeanTreeView by ChoiceView, making
sure that it is no longer a JScrollPane but a JCombobox. When I run
the application I get this strange error:

java.lang.ClassCastException: java.lang.String cannot be cast to
org.openide.explorer.view.VisualizerNode
        at org.openide.explorer.view.NodeRenderer.findVisualizerNode(NodeRenderer.java:232)
        at org.openide.explorer.view.NodeRenderer.getListCellRendererComponent(NodeRenderer.java:152)
        at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(BasicComboBoxUI.java:1202)
        at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.paintCurrentValue(WindowsComboBoxUI.java:293)
        at javax.swing.plaf.basic.BasicComboBoxUI.paint(BasicComboBoxUI.java:888)
        at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.paint(WindowsComboBoxUI.java:199)
        at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
        at javax.swing.JComponent.paintComponent(JComponent.java:763)
        at javax.swing.JComponent.paint(JComponent.java:1029)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at org.netbeans.swing.tabcontrol.TabbedContainer.paint(TabbedContainer.java:968)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at org.netbeans.core.windows.view.ui.MultiSplitPane.paint(MultiSplitPane.java:325)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:567)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:567)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
        at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:278)
        at javax.swing.RepaintManager.paint(RepaintManager.java:1220)
        at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
        at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:803)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)
        at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:694)
[catch] at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Looking at the sources of NodeRenderer there is this very strange line:

VisualizerNode vis = (value instanceof Node) ?
VisualizerNode.getVisualizer(null, (Node) value)
                                                     : (VisualizerNode) value;

where the value seems to be a String. Isn't this an error? Why cast to
VisualizerNode when the value isn't a Visualizer???

I am using Netbeans 6.7.1. Any one running into this issue? I am
missing something?
AFAIK, it won't work to use the form editor to add a ChoiceView to a form by changing its creation code, because the form editor will still try to set the model on the ChoiceView to be one populated by Strings.  ChoiceView isn't meant to have something set its model, but I know of no way to cause the form editor not to generate any model-setting code.  Perhaps someone else knows a way to work around this.

A simple workaround would be to add an empty JPanel w/, say, FlowLayout, and then programmatically add the combo box to that.

-Tim

Re: ChoiceView and strange Visualizer problem

by jmborer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I found the solution. Drop a JCombobox into your panel, then in the properties clear the field "model" for the combo. The editor won't create a new "inline" model. So you can continue to create you interfaces visually and use NB views. Very handy

Tim Boudreau wrote:
jmborer wrote:
I just wanted to try different view types for data nodes. I used the
sample from Selection tutorial that you can find
http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=3146

Then in "MyEditor" I replaced, new BeanTreeView by ChoiceView, making
sure that it is no longer a JScrollPane but a JCombobox. When I run
the application I get this strange error:

java.lang.ClassCastException: java.lang.String cannot be cast to
org.openide.explorer.view.VisualizerNode
        at org.openide.explorer.view.NodeRenderer.findVisualizerNode(NodeRenderer.java:232)
        at org.openide.explorer.view.NodeRenderer.getListCellRendererComponent(NodeRenderer.java:152)
        at javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue(BasicComboBoxUI.java:1202)
        at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.paintCurrentValue(WindowsComboBoxUI.java:293)
        at javax.swing.plaf.basic.BasicComboBoxUI.paint(BasicComboBoxUI.java:888)
        at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.paint(WindowsComboBoxUI.java:199)
        at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
        at javax.swing.JComponent.paintComponent(JComponent.java:763)
        at javax.swing.JComponent.paint(JComponent.java:1029)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at org.netbeans.swing.tabcontrol.TabbedContainer.paint(TabbedContainer.java:968)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at org.netbeans.core.windows.view.ui.MultiSplitPane.paint(MultiSplitPane.java:325)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:567)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:567)
        at javax.swing.JComponent.paintChildren(JComponent.java:864)
        at javax.swing.JComponent.paint(JComponent.java:1038)
        at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
        at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:278)
        at javax.swing.RepaintManager.paint(RepaintManager.java:1220)
        at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
        at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:803)
        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)
        at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:694)
[catch] at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Looking at the sources of NodeRenderer there is this very strange line:

VisualizerNode vis = (value instanceof Node) ?
VisualizerNode.getVisualizer(null, (Node) value)
                                                     : (VisualizerNode) value;

where the value seems to be a String. Isn't this an error? Why cast to
VisualizerNode when the value isn't a Visualizer???

I am using Netbeans 6.7.1. Any one running into this issue? I am
missing something?
AFAIK, it won't work to use the form editor to add a ChoiceView to a form by changing its creation code, because the form editor will still try to set the model on the ChoiceView to be one populated by Strings.  ChoiceView isn't meant to have something set its model, but I know of no way to cause the form editor not to generate any model-setting code.  Perhaps someone else knows a way to work around this.

A simple workaround would be to add an empty JPanel w/, say, FlowLayout, and then programmatically add the combo box to that.

-Tim

Re: ChoiceView and strange Visualizer problem

by Tim Boudreau :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

jmborer wrote:
I found the solution. Drop a JCombobox into your panel, then in the properties clear the field "model" for the combo. The editor won't create a new "inline" model. So you can continue to create you interfaces visually and use NB views. Very handy
Great!  It could help everyone else in perpetuity if you'd add step-by-step instructions for how to do this to the Developer FAQ (Nodes and Explorer section):  http://wiki.netbeans.org/NetBeansDeveloperFAQ (I could do it, but my goal here is to get *you* participating in maintaining the FAQs too :-))

Thanks,

-Tim