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.
NetBeans IDE 6.0 RC1 (Build 200711080000) Java: 1.6.0_03; Java HotSpot(TM) Client VM 1.6.0_03-b02 System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb) User can populate the web/resources directory in a variety of ways. -If a user drops an image component, the components customizer automatically places the file in the web/resources directory. We have a few such file customizers per project. -Or user can drag and drop a file from the desktop to designer, and it automatically gets placed in the web/resources directory. -Or user can manually copy a file to his web/resources dir. Subsequently opening a css file and setting for example, this image file as a background-image, corrupts the file if it is served from the web/resources dir. Steps to reproduce: 1. Create a VW ee5 project and copy any image file and paste it on the projects' resources dir node 2. From the project view, double click on this .jpg or .png file from the resources node to bring into multi-viewer. OK, see image. 3. Doube click on stylesheet.css file to bring it into multiviewer and add style rule body {} but use stylebuilder to add select, Background, then background-image, press ... property and select the test image file. The resources node comes up by default, click on the image file and press ok. > A question dialog comes up (see screen shot, omitting file path below) The file MasterFileObject@ae30be[c:/Document and Settings/...../..../.../web/resources/glasses.png was modified externally. Reload it? Press yes, return to glasses.png tab in multiviewer to see image gone -- message "Could not load the image" appears. The image is still cached in the designer (the image will be tiled by default), but if you deploy it, there will be only a blank page. Via the file system, go to the project's web/resources directory and see that the file has 0 bytes. Testing the style builder picking a file from another directory within the project or from outside the project, the file is not corrupted. It is only from the VW resources directory.
Created attachment 52759 [details] screen shot
Reproducible also without visual web pack. Just open an image from web project /web directory, open a css file, select a rule, add a background - select the file. The question mentioned by Krystyna is shown, after OK the file gets zero size. Just a note, this is not a regression - I haven't touched the responsible code taken from creator. The problem is that the UI handler copies the selected file into the css file's directory even if there is a file with the same name, and *even if the file it the same!*. Moreover the existing code operates with File-s, should be using FileObject-s.
fixed in trunk, please verify asap so I can fix in 6.0 branch, Checking in BackgroundImageUrlDialog.java; /cvs/web/css/src/org/netbeans/modules/css/visual/ui/BackgroundImageUrlDialog.java,v <-- BackgroundImageUrlDialog.java new revision: 1.6; previous revision: 1.5 done
-Tested trunk build #4360 (1108220724) - fixed is that the file doesn't get overwritten, but fix doesnt' work to be able to select the image from the resources file: now stylebuilder won't write in the rule: In the .css file (at end of step #3 above) I get a Warning dialog come up in the place of the Question dialog that says "Cannot create van.jpg in folder (see screenshot)....c:....../web/resources. This file already exists". Press OK. the background-image: url(van.jpg) css never appears in the rule. But it is fixed that we prevent the file from being overwritten. Just user can't use style builder file customizer for background-image. The workaround is to manually edit in css to the rule if intending to use the file from the resources dir. If that was the intended scope of the fix, I think we should take it, so in advance I will mark this verified since this behavior is preferred over corrupting the image that is there. Thanks. fyi - http://wiki.netbeans.org/wiki/view/NB6HighResistance guidelines. For the record, this did work in 5.5.1. Tested workaround and verified background image appears in designer, in deployment.
Created attachment 52770 [details] screen shot after fix
Hmmm, it is obvoius that the css entry should be created if the selected file is *the same* as the one in the css's folder. In the other case - the attempt to copy the file to the already existing one is OK IMHO. The first case should be fixed IMO, reopening. fixed the remaining problem, please reverify Checking in BackgroundImageUrlDialog.java; /cvs/web/css/src/org/netbeans/modules/css/visual/ui/BackgroundImageUrlDialog.java,v <-- BackgroundImageUrlDialog.java new revision: 1.8; previous revision: 1.7 done
fixed
Re-verified: trunk build 4363: NetBeans IDE Dev (Build 20071109053216) Java: 1.6.0_03; Java HotSpot(TM) Client VM 1.6.0_03-b02 System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Marku, can you integrate fix in release60 branch? Thanks
Tome, could you please review the fix? It is quite trivial, please do it quickly.
Fix verified. It should definitely prevent a data loss and not introduce regressions, however I would like to see there an option to override existing file - I filed enhancement issue 121708.
commited into release60 branch Checking in src/org/netbeans/modules/css/visual/ui/BackgroundImageUrlDialog.java; /cvs/web/css/src/org/netbeans/modules/css/visual/ui/BackgroundImageUrlDialog.java,v <-- BackgroundImageUrlDialog.java new revision: 1.5.4.1; previous revision: 1.5 done