1 23 24 package org.enhydra.kelp.forte.services; 25 26 import java.io.IOException ; 27 import java.util.*; 28 29 import org.openide.compiler.*; 30 import org.openide.compiler.Compiler; 31 import org.openide.filesystems.*; 32 33 37 public class XMLCCleanCompilerGroup extends CompilerGroup { 38 39 private Set compilers = new HashSet (); 41 public void add (Compiler c) throws IllegalArgumentException { 42 if (! (c instanceof XMLCCleanCompiler)) throw new IllegalArgumentException (); 43 compilers.add (c); 44 } 45 46 public boolean start () { 47 boolean ok = true; 48 Iterator it = compilers.iterator (); 49 while (it.hasNext ()) { 50 XMLCCleanCompiler c = (XMLCCleanCompiler) it.next (); 51 if (c.isUpToDate ()) continue; 52 FileObject fo = c.getFileObject (); 53 FileObject toKill = FileUtil.findBrother (fo, "compiledExt"); 54 if (toKill == null) continue; 55 try { 56 FileLock lock = toKill.lock (); 57 try { 58 toKill.delete (lock); 59 fireProgressEvent (new ProgressEvent (this, fo, ProgressEvent.TASK_WRITING)); 60 } finally { 61 lock.releaseLock (); 62 } 63 } catch (IOException ioe) { 64 fireErrorEvent (new ErrorEvent (this, toKill, 0, 0, ioe.toString (), null)); 65 ok = false; 66 } 67 } 68 return ok; 69 } 70 71 } 72 | Popular Tags |