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 21677 - Changing ClassElement name does not update its source node's display name
Summary: Changing ClassElement name does not update its source node's display name
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Data Systems (show other bugs)
Version: 3.x
Hardware: Sun Solaris
: P2 blocker (vote)
Assignee: _ ttran
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-18 17:48 UTC by Chris Webster
Modified: 2012-04-26 10:35 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Here is the result of the test case specified in the report (43.27 KB, image/jpeg)
2002-04-10 20:37 UTC, Chris Webster
Details
Patch jar printing diagnostic messages (37.01 KB, application/octet-stream)
2002-04-12 12:35 UTC, Svata Dedic
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Webster 2002-03-18 17:48:48 UTC
Consider the following test case:
1. create java class (c)
2. expand node until the c ClassElementNode is visible
3. use context menu -> rename to c2

The explorer displays c and not c2!
Comment 1 Chris Webster 2002-03-18 23:20:35 UTC
This bug appears to be only on Solaris 8. I can reproduce this
consistently using JDK 1.4 FCS with all patches installed.
Comment 2 Jan Becicka 2002-03-22 11:01:14 UTC
Chris, can you reproduce this bug in latest dev builds or in NB 3.3.1?
We cannot reproduce it here...
Thanks
Comment 3 Svata Dedic 2002-03-22 14:00:10 UTC
Cannot reproduce even on Solaris 8 machine, JDK-1.4.1 + all patches.
Comment 4 Chris Webster 2002-04-10 20:37:29 UTC
Created attachment 5363 [details]
Here is the result of the test case specified in the report
Comment 5 Chris Webster 2002-04-10 20:40:38 UTC
This problem still happens consistently on Solaris 8, using JDK 1.4
(with all required os patches). I attached a screen shot of the
resulting explorer view. This problem also happens consistently for a
colleague using the same os and jdk. If there are any diagnostics
which would be helpful in diagnosing this problem, please attach to
bug report.
Comment 6 Chris Webster 2002-04-10 21:05:09 UTC
The attached image shows the problem when rename was used on the
test234 java class element. As you will notice, the class element and
the file have a different name. 
Comment 7 Jan Becicka 2002-04-11 10:17:02 UTC
Chris, if the package declaration of test234.java is not correct,
ClassElementNode is not renamed. Are you sure, that package
declaration of test234.java is "package something.b12345" ?
Thanks

Comment 8 Chris Webster 2002-04-11 17:44:26 UTC
I am positive that the package declaration is correct. I can replicate
the test by create a new class, then selecting the ClassElementNode
and executing the rename action. 
Comment 9 Chris Webster 2002-04-11 18:10:41 UTC
I looked in the directory containing the java file and the file has
been renamed correctly. The explorer view is not updated properly. 

I verfied this by executing the following using internal execution:
   try {
        ClassElement ce = ClassElement.forName("b12345.t2345");
        ce.setName(Identifier.create("t23456"));
        ce = ClassElement.forName("b12345.t23456");
        System.out.println(ce);
        } catch (SourceException se) {}
Comment 10 Jan Chalupa 2002-04-12 08:33:13 UTC
Not fixed yet. Changing milestone to 3.4. To be moved back as soon as
fixed.
Comment 11 Svata Dedic 2002-04-12 09:49:48 UTC
x 
Comment 12 Svata Dedic 2002-04-12 10:02:47 UTC
Chris, your last comment suggests that the file 
name/classname are both correct - only the visuals of the 
file node hasn't beed updated. Is that true ? [we may be 
looking into wrong part of the code all the time :-)] 
Comment 13 Svata Dedic 2002-04-12 12:35:18 UTC
Created attachment 5395 [details]
Patch jar printing diagnostic messages
Comment 14 Svata Dedic 2002-04-12 12:36:28 UTC
I've attached a patch jar; please put it into directory 
modules/patches/org-netbeans-modules-java/ 
under your IDE installation. It's quite noisy :-) 
 
Comment 15 Chris Webster 2002-04-12 20:03:37 UTC
Here is the output during the rename operation. The rename is
performed on the ClassElementNode, however, the explorer view still
reflects the c2 original name. In the filesystem the filename is
c3.java as expected.

Class name change (c2->c3
main class: c3, file=c2
[rescan-start]
found main class: c3
[rescan-end]
primaryFileMoved: c3->b12345/c3.java
[rescan-start]
found main class: c3
[rescan-end]

The display following the rename is
c2.java
  class c3

As a side note: The diagnostic patch was displaying messages about
internal ide classes such as 
[rescan-start]
found main class: EntJavaBeanImpl
[rescan-end]
[rescan-start]
found main class: WeblogicServerInstanceNode
[rescan-end]
[rescan-start]
found main class: LCTest
[rescan-end]
[rescan-start]
found main class: i18n
[rescan-end]

Why would this classes appear here? 
Comment 16 Chris Webster 2002-04-12 20:09:43 UTC
I tried another execution this time renaming at the top level node
(not the ClassElement). This was immediately following the c2-c3
rename. The logging information:

[rescan-start]
[rescan-end]
primaryFileMoved: c4->b12345/c4.java
Class name change (c3->c4
main class forgotten or invalid ?, rescanning.
[rescan-start]
found main class: c4
[rescan-end]
[rescan-start]
found main class: c4
[rescan-end]

This leaves the node name and the class name in synch as expected.
Comment 17 Svata Dedic 2002-04-14 10:06:57 UTC
OK, so (once again to be sure). If the error happens, then the file on
the disk has the correct name, but the display in the explorer is
wrong. If so, I'll move the diagnostic into the DataObject part. Do
you have file extensions visible in your Explorer ?
Comment 18 Chris Webster 2002-04-15 18:13:50 UTC
Yes, your assessment is correct the file on disk matches the
ClassElementNode, but the top level node is different. Also, I am
displaying file extensions.
Comment 19 Svata Dedic 2002-04-16 10:35:01 UTC
At least I reproduced it (once) - the key is to turn on file extension
display. Everything, including name property of the java source node
is updated, but not the display name.
Comment 20 Svata Dedic 2002-04-16 15:21:27 UTC
I hate to reassign bugs without a patch... but here's what  
I've found:  
The JavaNode (represents the whole source file), NOT the  
ClassElementNode ("class XXX") retains the obsoleted name.  
To reproduce:  
- start a fresh build  
- turn "Show File Extensions" in Tools | Options | IDE  
Settings | System to True  
- drill down to some public class node (e.g.  
examples/advanced/MemoryView.java -> class MemoryView)  
then do a rename of the class.  
  
During debugging, I found out that the  
AbstractNode.setName() avoids setting displayName  
property, while firing PROP_DISPLAY_NAME change event.  
That works when file extensions are off, setDisplayName()  
calls are passed the value of getName() ==  
getPrimaryFile().getName() and Node.setDisplayName() finds  
this out and does nothing, leaving null (== use getName())  
as the display name value.  
  
I would recommend to call DataNode.updateDisplayName()  
from within PROP_NAME handler attached to DataObject  
(inside DataNode.fireChange) - but I'm not sure about side 
effects. 
Comment 21 _ ttran 2002-04-16 16:00:44 UTC
yarda, please help us with this bug.  harmernik is on vacation
Comment 22 _ ttran 2002-04-17 17:44:12 UTC
x
Comment 23 _ ttran 2002-04-17 17:47:28 UTC
Svata, thanks for your thorough analysis and the suggested fix.  I've
committed into the CVS trunk.  

DataNode.java rev 1.69
Comment 24 Jan Zajicek 2002-04-18 12:42:43 UTC
Verified in the trunk.
Comment 25 _ ttran 2002-04-18 16:01:02 UTC
merged into orion_fcs
Comment 26 Jan Zajicek 2002-04-19 09:43:19 UTC
verified in Orion too
Comment 27 Quality Engineering 2003-07-01 16:17:38 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.
Comment 28 Quality Engineering 2012-04-26 10:35:04 UTC
Integrated into 'main-golden', will be available in build *201204260400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/93ab0a7b0668
User: Jaroslav Bachorik <yardus@netbeans.org>
Log: #21677: Do not hard-wire dependency on "dist" target when generating profiler targets