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 162769 - A XAM based model can be unsynchronized with its sources
Summary: A XAM based model can be unsynchronized with its sources
Status: RESOLVED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: XAM (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Nikita Krjukov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-15 23:05 UTC by Nikita Krjukov
Modified: 2010-03-24 05:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
main difference of proposed improvements (2.50 KB, text/plain)
2009-05-12 17:35 UTC, Nikita Krjukov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Krjukov 2009-04-15 23:05:21 UTC
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.
Comment 1 Nikita Krjukov 2009-05-12 15:37:15 UTC
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. 
Comment 2 Nikita Krjukov 2009-05-12 16:02:04 UTC
I changed the subcomponent and summary of the issue because it relates not only Schema models, but rather any XAM based
models. 
Comment 3 Nikita Krjukov 2009-05-12 17:35:57 UTC
Created attachment 81995 [details]
main difference of proposed improvements
Comment 4 Nikita Krjukov 2009-05-15 17:04:31 UTC
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. 
Comment 5 _ alexpetrov 2009-09-23 16:27:54 UTC
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).
Comment 6 Sergey Lunegov 2010-02-10 03:24:42 UTC
Will get back to it after M1.
Comment 7 Nikita Krjukov 2010-03-23 10:21:03 UTC
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)
Comment 8 Quality Engineering 2010-03-24 05:24:08 UTC
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