1 32 33 package it.businesslogic.ireport.plugin.massivecompiler; 34 35 import javax.swing.table.*; 36 import java.io.*; 37 41 public class FindThread implements Runnable { 42 43 private MassiveCompilerFrame massiveCompilerFrame = null; 44 private boolean stop = false; 45 private Thread thread = null; 46 47 public FindThread(MassiveCompilerFrame mcf) 48 { 49 this.massiveCompilerFrame = mcf; 50 thread = new Thread (this); 51 } 52 53 public void stop() 54 { 55 stop = true; 56 } 57 58 public void start() 59 { 60 thread.start(); 61 } 62 63 public void run() { 64 if (massiveCompilerFrame == null) 65 { 66 return; 67 } 68 69 71 DefaultTableModel dtm = (DefaultTableModel)massiveCompilerFrame.getFileTable().getModel(); 72 73 dtm.setRowCount(0); 74 massiveCompilerFrame.getFileTable().updateUI(); 75 76 File path = new File(massiveCompilerFrame.getFindDirectory()); 78 79 if (path == null || !path.exists() || path.isFile()) 80 { 81 return; 83 } 84 85 if (!stop) findFiles(path, massiveCompilerFrame.isSearchSubDirectory(),dtm); 86 87 massiveCompilerFrame.finishedFind(); 88 return; 89 } 90 91 private int findFiles(File path, boolean recursive, DefaultTableModel tmodel) 92 { 93 if (stop) return 0; 94 int count = 0; 95 File[] files = path.listFiles(); 96 for (int i=0; i<files.length; ++i) 97 { 98 if (stop) return 0; 99 if (files[i].isDirectory() && recursive) 100 { 101 count += findFiles( files[i], recursive,tmodel); 102 } 103 else 104 { 105 if (files[i].getName().toLowerCase().endsWith(".xml") || 107 files[i].getName().toLowerCase().endsWith(".jrxml")) 108 { 109 FileEntry fe = new FileEntry(); 111 fe.setFile( files[i] ); 112 113 115 116 fe.setStatus( fe.STATUS_NOT_COMPILED ); 118 tmodel.addRow( new Object []{fe,fe,fe.decodeStatus(fe.getStatus())}); 119 120 } 121 } 122 } 123 124 return count; 125 } 126 127 } 128 | Popular Tags |