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 83970

Summary: NullPointerException on the first attribute in Design view
Product: xml Reporter: htt <htt>
Component: Schema ToolsAssignee: Ayub Khan <ayubskhan>
Status: VERIFIED FIXED    
Severity: blocker    
Priority: P1    
Version: 5.x   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:

Description htt 2006-08-31 22:43:48 UTC
With trunk build 060831_1, jdk1.5.0_07....

Open a new schema (default Design Pattern = Venetian Blind).
In Design view,
  drag/drop a new element, name it e.
  add (drag/drop) an element to e, name it e1.
  drag/drop an attribute to e1: wait until e1Type appears under golbal
complexTypes, then press Return -> NPE below.  

Workaround: click OK to dismiss the NPE and continue working in the IDE.  It'd
seem the NPE occurs only for the first dropped attribute. 

 java.lang.NullPointerException
        at
org.netbeans.modules.xml.schema.abe.AttributePanel.setAttrNameInModel(AttributePanel.java:317)
        at
org.netbeans.modules.xml.schema.abe.AttributePanel.access$200(AttributePanel.java:63)
        at
org.netbeans.modules.xml.schema.abe.AttributePanel$6$1.actionPerformed(AttributePanel.java:273)
        at javax.swing.JTextField.fireActionPerformed(JTextField.java:487)
        at javax.swing.JTextField.postActionEvent(JTextField.java:668)
        at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:783)
        at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1571)
        at javax.swing.JComponent.processKeyBinding(JComponent.java:2763)
        at javax.swing.JComponent.processKeyBindings(JComponent.java:2798)
        at javax.swing.JComponent.processKeyEvent(JComponent.java:2726)
        at java.awt.Component.processEvent(Component.java:5265)
        at java.awt.Container.processEvent(Container.java:1966)
        at java.awt.Component.dispatchEventImpl(Component.java:3955)
        at java.awt.Container.dispatchEventImpl(Container.java:2024)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1810)
        at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:672)
        at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:920)
        at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:798)
        at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:636)
        at java.awt.Component.dispatchEventImpl(Component.java:3841)
        at java.awt.Container.dispatchEventImpl(Container.java:2024)
        at java.awt.Window.dispatchEventImpl(Window.java:1774)
        at java.awt.Component.dispatchEvent(Component.java:3803)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Comment 1 Girish Balachandran 2006-09-01 19:20:25 UTC
There was a recent change related to automatic DP based code generation in the
model. Since then, I can not reproduce this bug.
I am marking it as worksforme. Please verify the same and close.
Comment 2 htt 2006-09-01 21:02:07 UTC
With trunk build 060831_2, jdk1.5.0_07...

Now that the default Design Pattern is changed to Russian Doll, observe
different issue/behavior for a related scenario:

Open a new schema (default DP = RD)
In Design view, 
  drag/drop element e
  add (drag/drop) element e1 to e
  add (drag/drop) attribute a1 to e1
In Projects, right-click newXmlSchema.xsd and select Apply Design Pattern
In Apply Design Pattern dialog box, change DP to Venetian Blind.
In Design view,
  expand everything and observe:
      e
        e1 > a1=string
      e1Type > a1=string
  add (drag/drop) attribute a2 to e1
  => Design view blanks out with "Schema is invalid" msg.

Comment 3 Girish Balachandran 2006-09-01 21:33:57 UTC
This seem to me now like a code gen issue.
Comment 4 Girish Balachandran 2006-09-01 21:35:40 UTC
This is the resulting invalid schema after doing the above mentioned actions.


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://xml.netbeans.org/schema/newXMLSchema"
            xmlns:tns="http://xml.netbeans.org/schema/newXMLSchema"
            elementFormDefault="qualified">
    <xsd:element name="e">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="e1" type="tns:e1Type">
                    <xsd:complexType>
                        <xsd:attribute name="newAttribute" type="xsd:string"/>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:complexType name="e1Type">
        <xsd:attribute name="a1" type="xsd:string"/>
        <xsd:attribute name="newAttribute" type="xsd:string"/>
    </xsd:complexType>
</xsd:schema>
Comment 5 Ayub Khan 2006-09-02 00:10:13 UTC
Fixed.

Files affected:
===============

/cvs/xml/axi/src/org/netbeans/modules/xml/axi/impl/Attic/DefaultSchemaGenerator.java
new revision: 1.1.2.40; previous revision: 1.1.2.39

/cvs/xml/axi/src/org/netbeans/modules/xml/axi/impl/Attic/GardenOfEden.java
new revision: 1.1.2.26; previous revision: 1.1.2.25

/cvs/xml/axi/src/org/netbeans/modules/xml/axi/impl/Attic/VenetianBlind.java
new revision: 1.1.2.19; previous revision: 1.1.2.18
Comment 6 htt 2006-09-11 21:02:35 UTC
Verified in trunk build 060911.