1
2
3
4
5
6
7 package net.sf.gumshoe;
8
9 import java.io.File;
10 import java.util.logging.Level;
11 import java.util.logging.Logger;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.widgets.MenuItem;
15 import org.eclipse.swt.widgets.MessageBox;
16 import org.getopt.luke.Luke;
17
18 import net.sf.gumshoe.indexer.DiskIndexer;
19
20 /***
21 * @author Gabor
22 *
23 * TODO To change the template for this generated type comment go to
24 * Window - Preferences - Java - Code Style - Code Templates
25 */
26 public class Gumshoe extends TrayApp implements Runnable {
27
28 private String searchRoot="C://Documents and Settings";
29
30 private String indexStore=System.getProperty("user.home")+File.separator+".scavenger";
31
32 private boolean threadSuspended=true;
33
34 protected Logger logger=null;
35
36 protected Thread t=null;
37
38 public static void main( String[] args ) {
39 Gumshoe app = new Gumshoe();
40 app.setToolTip(Messages.getString("Gumshoe.applicationtitle"));
41 app.setIcon("/images/gumshoe.ico");
42 app.start(args);
43 }
44
45 /***
46 *
47 */
48 public Gumshoe() {
49 super();
50 logger=Logger.getLogger(getClass().getName());
51 startIndexing();
52 }
53
54
55
56
57 public void initGUI() {
58 createLeftMenu();
59 createRightMenu();
60 }
61
62 /***
63 *
64 */
65 private void createRightMenu() {
66
67
68 }
69
70 /***
71 *
72 */
73 private void createLeftMenu() {
74 MenuItem miConfiguration = createMenu(reMenu, Messages.getString("Gumshoe.advancedsearch"),
75 new MenuCommand() {
76 public void perform() {
77 advancedSearch();
78 }
79 }, SWT.PUSH);
80
81
82
83
84
85
86
87
88
89
90
91
92 MenuItem miOptions = createMenu(reMenu, Messages.getString("Gumshoe.options"),
93 new MenuCommand() {
94 public void perform() {
95 options();
96 }
97 }, SWT.PUSH);
98 MenuItem miAbout = createMenu(reMenu, Messages.getString("Gumshoe.about"),
99 new MenuCommand() {
100 public void perform() {
101 about();
102 }
103 }, SWT.PUSH);
104 MenuItem miExit = createMenu(reMenu, Messages.getString("Gumshoe.exit"),
105 new MenuCommand() {
106 public void perform() {
107 exit();
108 }
109 }, SWT.PUSH);
110 }
111
112 /***
113 *
114 */
115 protected void advancedSearch() {
116 String[] args={"-ro", "-index", indexStore};
117 Luke.startLuke(args);
118 }
119
120 /***
121 *
122 */
123 protected void options() {
124 MessageBox mb=new MessageBox(getShell(), SWT.ICON_INFORMATION | SWT.OK);
125 mb.setMessage("Coming soon :)");
126 mb.open();
127 }
128
129 /***
130 *
131 */
132 protected void about() {
133 MessageBox mb=new MessageBox(getShell(), SWT.ICON_INFORMATION | SWT.OK);
134 mb.setMessage(Messages.getString("Gumshoe.applicationtitle"));
135 mb.open();
136 }
137
138
139
140
141 protected void processArgs(String[] args) {
142
143 }
144
145 /***
146 *
147 */
148 protected void startIndexing() {
149 if (t==null){
150 t=new Thread(this, "DiskIndexer");
151 t.setDaemon(true);
152 t.setPriority(Thread.MIN_PRIORITY);
153 threadSuspended=false;
154 t.start();
155 }
156 }
157
158
159
160 public void run() {
161 while (true) {
162 try {
163 Thread.sleep(1000L);
164
165 while (threadSuspended){
166 synchronized(this){
167 System.out.println("waiting ...");
168 wait();
169 System.out.println("waiting ended ...");
170 }
171 }
172 } catch (InterruptedException e){
173 System.out.println("interrupted ...");
174 }
175 try {
176 File indexDir = new File(indexStore);
177 File dataDir = new File(searchRoot);
178 new DiskIndexer().index(indexDir, dataDir, true);
179 } catch (Throwable t){
180 logger.log(Level.SEVERE, "indexing failed", t);
181 }
182 threadSuspended=true;
183 }
184 }
185 }