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.
Steps to reproduce: -- Open any valid XSD file (it is implied the special schema editor is supported) -- The 3 tab editor appears -- Make sure the tabs are shown correctly -- Switch to the Source tab view and delete the root <schema> element. Only a title and starting comments remain. -- Switch to the Schema tab view. You can see that nothing changed. It shows deleted content. The schema also visible from other places as valid (BPEL, WSDL, ...). Closing and reopening doesn't solve the problem. The only way to make the schema being invalid is restarting the NetBeans.
My investigation has come me to the conclusion that the issue can't be fixed without improving XAM module API. It's necessary to add the method "removeRootComponent()". Now the root component is cached inside of models' implementations. It is created by the method "createRootComponent(org.w3c.dom.Element root)". But there isn't a way to remove the root component. The XAM model is based on XDM model, which can't be considered as invalid if there isn't a root component is specified. It is well formed without a root component. For example, it can be created almost empty (only an XML title is required) at first and be populated with a root component later. So it isn't a responsibility of a XDM model to make a decision if the XAM model is valid or not without a root component. When the root component is deleted, the XDM tries informing the XAM model about it. But XAM model can't be modified correspondingly because of shortage of the mentioned "removeRootComponent()" method. That is why it remains unsynchronized after that. I tried doing a workaround but failed. And anyway, the workaround isn't a good solution. The bad news is that a real implementation of the "removeRootComponent()" method has to be added to all XAM descendants. Such way the addition of the new method comes to losing backward compatibility. I personally think we should apply addition of the method because I'm sure the XAM hardly have any implementations other then ours despite the XAM is declared as public API.
I changed the subcomponent and summary of the issue because it relates not only Schema models, but rather any XAM based models.
Created attachment 81995 [details] main difference of proposed improvements
The fix requires quite big refactoring because of API modification of xml.xam module (see issue #165183). Too many modules depend on the xml.xam. It's too late now to start such changes. The bug happens only if user intentionally delete root component in XML sources. It means deletion of almost all content. Such action looks like meaningless in most cases. So it shouldn't be often. There isn't a workaround. But the lost of synchronization is retrievable in most cases. The user only need create a new root component in XML document.
This bug should be waived on NB 6.8 for the following reasons, which are described in the previous comment from supernikita@netbeans.org, May 15th, 2009): 1. The fix requires quite big refactoring of xml.xam module. 2. The bug happens rarely (only if user intentionally delete root component in XML sources). 3. There isn't a workaround, but the lost of synchronization is retrievable in most cases (an user only need to create a new root component in XML document).
Will get back to it after M1.
Fixed in trunk http://hg.netbeans.org/main/rev/273840b223ba I managed to get rid of API changes I had wrote before. The fix also contains some other small changes: -- JUnit library dependencies are added to some project.xml because the tests don't work without it now -- try/finally blocks are added to xml/xam/ui/undo/QuietUndoManager.java in order to guarantee listeners are unsubscribed. -- Discard model state to STABLE after undo/redo (xml/xdm/XDMModel.java) -- Add checks that model's root component isn't null (different places)
Integrated into 'main-golden', will be available in build *201003240200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/273840b223ba User: supernikita@netbeans.org Log: #162769 - A XAM based model can be unsynchronized with its sources