Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 128211 - XmlMultiViewDataObject delays Rename action
XmlMultiViewDataObject delays Rename action
Product: xml
Classification: Unclassified
Component: XML Multiview
All All
: P4 (vote)
Assigned To: Svata Dedic
Depends on:
  Show dependency treegraph
Reported: 2008-02-22 23:28 UTC by Dongmei Cao
Modified: 2016-07-07 09:56 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT


Note You need to log in before you can comment on or make changes to this bug.
Description Dongmei Cao 2008-02-22 23:28:26 UTC
I noticed this when I'm working on the Hibernate support module. I have the DataObjects for the Hibernate configuration
and mapping  extend from XmlMultiViewDataObject. Here are the steps to reproduce the problem:

- double click on the Hibernate configuration file so it'll open in the editor
- right click on the configuration file node in the project node and select "Rename..."
- change the name to, say, a.cfg. You'll notice the name changed in the node right away, but not the name in the editor tab.
- now select "Rename..." again. Change it to b.cfg. You'll notice the node name changed right away, and the editor tab
name changed to the previous name, a.cfg.xml.

The problem goes away if I change my DataObject to extend from MultiDataObject, which makes me think it is a
XmlMultiViewDataObject issue.
Comment 1 Dongmei Cao 2008-02-22 23:31:00 UTC
You can reproduce the problem on the web.xml file too. But of course, you first need to modify its layer file to have a
Rename action.
Comment 2 Dongmei Cao 2008-02-22 23:49:26 UTC
The same rename delay is also in the Navigator tab
Comment 3 Erno Mononen 2008-02-26 09:28:46 UTC
The problem seems to be that XmlMultiviewDataObject overrides handleRename(String) and calls 
XmlMultiviewEditorSupport#updateDisplayName before the primary file of the data object has actually been changed (it is 
changed in DataObject after handleRename(String) returns (below is the impl of the method):
   protected FileObject handleRename(String name) throws IOException {
        FileObject retValue = super.handleRename(name);
        return retValue;

To fix this, I can think of two solutions:
- listen on the name change events fired by DataObject and only update the display name once the name has actually been 
- create an overloaded version of XmlMultiviewDataObject#updateDisplayName that takes a FileObject parameter and pass 
the return value of super.handleRename to that method and update the display name using the passed FileObject (however, 
if the actual rename fails, this would leave the display name in an invalid state)

I need to think about how to fix this in xml/multiview in a compatible way. If you need a quick solution, you might 
want to override the handleRename method in your DataObject and do one the above.
Comment 4 Erno Mononen 2008-02-26 10:39:58 UTC
Another workaround for this could be overriding the XmlMultiViewEditorSupport#updateDisplay method so that it uses the 
name of the primary file which is changed by handleRename in MultiDataObject), e.g.: 

 // old - String displayName = messageName();
 String displayName = dObj.getPrimaryFile().getNameExt();
 if (!displayName.equals(mvtc.getDisplayName())) {

This works if the name of the top component should always be the name of the file. I can't make this assumption in xml/
multiview though as some clients may have overridded the messageName method.
Comment 5 Dongmei Cao 2008-02-26 19:54:33 UTC
If you're going to fix in 6.1, then I'll wait for your fix.
Comment 6 Erno Mononen 2008-02-27 11:55:16 UTC
Actually my idea was to fix this for 6.1 only if none of the provided workarounds work for you (since your module seems 
to be the only one that faces this problem, web/persistence/ejb editors don't allow renaming).
Comment 7 Dongmei Cao 2008-02-27 22:18:25 UTC
I chose the 3rd workaround you suggested. The renaming works now. See my checkin
Comment 8 Erno Mononen 2008-02-28 15:41:30 UTC
Great, thanks. I'm downgrading this to P3 then as the workaround proved to be viable. 
Comment 9 Vince Kraemer 2008-12-03 19:32:18 UTC
bad tm value... reset to tbd
Comment 10 Petr Jiricka 2009-10-08 16:04:59 UTC
There is workaround in place for Hibernate and Spring, but this is still reproducible with web.xml:
1. Create a web.xml in web project
2. Open it in the editor
3. Choose Properties in the web.xml node's popup menu
4. Change the Name property => only the node name is changed, not the editor tab name

Since this is a very improbable usecase, changing to P4.
Comment 11 Martin Balin 2016-07-07 09:56:24 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo