Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 121514 - Style builder file customizer corrupts files from VW resources dir
Style builder file customizer corrupts files from VW resources dir
Product: web
Classification: Unclassified
Component: CSS Visual Tools
All All
: P1 (vote)
: 6.x
Assigned To: Marek Fukala
Jindrich Sedek
Depends on:
  Show dependency treegraph
Reported: 2007-11-08 20:58 UTC by _ krystyna
Modified: 2008-04-28 13:37 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT

screen shot (171.74 KB, text/plain)
2007-11-08 20:59 UTC, _ krystyna
screen shot after fix (188.53 KB, text/plain)
2007-11-09 00:59 UTC, _ krystyna

Note You need to log in before you can comment on or make changes to this bug.
Description _ krystyna 2007-11-08 20:58:10 UTC
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
Comment 1 _ krystyna 2007-11-08 20:59:02 UTC
Created attachment 52759 [details]
screen shot
Comment 2 Marek Fukala 2007-11-08 21:36:39 UTC
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.

Comment 3 Marek Fukala 2007-11-08 21:58:51 UTC
fixed in trunk, please verify asap so I can fix in 6.0 branch,

Checking in;
/cvs/web/css/src/org/netbeans/modules/css/visual/ui/,v  <--
new revision: 1.6; previous revision: 1.5
Comment 4 _ krystyna 2007-11-09 00:23:07 UTC
-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 -  guidelines.

  For the record, this did work in 5.5.1.

  Tested workaround and verified background image appears in designer, in deployment.
Comment 5 _ krystyna 2007-11-09 00:59:30 UTC
Created attachment 52770 [details]
screen shot after fix
Comment 6 Marek Fukala 2007-11-09 04:55:53 UTC
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;
/cvs/web/css/src/org/netbeans/modules/css/visual/ui/,v  <--
new revision: 1.8; previous revision: 1.7
Comment 7 Marek Fukala 2007-11-09 04:56:25 UTC
Comment 8 _ krystyna 2007-11-09 18:51:03 UTC
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)
Comment 9 Petr Blaha 2007-11-12 08:53:30 UTC
Marku, can you integrate fix in release60 branch? Thanks
Comment 10 Marek Fukala 2007-11-12 09:42:08 UTC
Tome, could you please review the fix? It is quite trivial, please do it quickly.
Comment 11 Tomasz Slota 2007-11-12 10:28:58 UTC
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.
Comment 12 Marek Fukala 2007-11-12 11:50:56 UTC
commited into release60 branch

Checking in src/org/netbeans/modules/css/visual/ui/;
/cvs/web/css/src/org/netbeans/modules/css/visual/ui/,v  <--
new revision:; previous revision: 1.5

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