Community
Participate
Working Groups
Paul, In JETCompileTemplateOperation we do the following. String encoding = outputFile.getCharset(); String result = stringWriter.getBuffer().toString(); byte [] bytes; try { bytes = encoding == null ? result.getBytes() : result.getBytes(encoding); } catch (UnsupportedEncodingException exception) { bytes = result.getBytes(); } if (!outputFile.exists()) { outputFile.create(new ByteArrayInputStream(bytes), true, progressMonitor); } else { boolean changed = true; try { InputStream inputStream = outputFile.getContents(); byte [] oldBytes = new byte[inputStream.available()]; inputStream.read(oldBytes); inputStream.close(); changed = !Arrays.equals(oldBytes, bytes); } catch (IOException exception) { } if (changed) { if (outputFile.isReadOnly()) { // This call should get the files checked out from version control if the project is a 'team' project. // IStatus status = ResourcesPlugin.getWorkspace().validateEdit(new IFile [] { outputFile }, null); if (!status.isOK()) { throw new CoreException(status); } } outputFile.setContents(new ByteArrayInputStream(bytes), true, true, progressMonitor); } } The validateEdit code was contributed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=149770, so I'm making that change but don't want to lose it when we move to JET2. That made me notice the other nice things we're already doing that JET2Compiler.writeFile is not already doing. It's nice to minimize the number of deltas on a file, so creating an empty version and then writing to it isn't so nice. Most importantly, producing a no-op delta on the file is quite unpleasant and makes for a bad CVS experience where files change for no good reason. So I would suggest that this method be changed to be more like what's being done in old JET right now.
This should be marked as a contribution once the changes with the validateEdit support have been commited.
Changes committed to CVS. IP log updated.
Fixed in build I200705031530.
Fixed in build I200705031530
Move to verified as per bug 206558.
[contrib email="merks@ca.ibm.com"/]