-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalOptionTab.java
More file actions
98 lines (84 loc) · 2.21 KB
/
LocalOptionTab.java
File metadata and controls
98 lines (84 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
/** @author Gergely Kota
LocalOptionTabs run a websearch + comparison, and display the result
*/
public class LocalOptionTab extends OptionTab
{
private OptionPanel compare;
private SelectiveInfo file;
public LocalOptionTab()
{
super("Local Comparison");
JPanel center = new JPanel(new BorderLayout());
JPanel north = new JPanel(new GridLayout(2,1));
file = new SelectiveInfo("Directory", false, 80);
JButton browse = new JButton("Browse");
browse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try
{
file.set(FileFrame.getDirectory().getAbsolutePath());
}
catch(Exception e) {}
}
});
JPanel small = new JPanel(new BorderLayout());
small.add(file, BorderLayout.CENTER);
small.add(browse, BorderLayout.EAST);
compare = new ComparisonOptionPanel(this);
center.add(compare, BorderLayout.SOUTH);
JPanel buffer = new JPanel(new BorderLayout());
buffer.add(small, BorderLayout.NORTH);
setCenter(buffer);
setAdvanced(compare);
setDescription("Enter a directory whose contents are to be compared");
}
public void go()
{
SplatFile f = new SplatFile(file.read());
log("*************************");
if(!f.isDirectory())
{
log("Invalid directory entered");
return;
}
new RepaintRunner().start();
}
private class RepaintRunner extends Thread
{
public void run()
{
setWorkingDirectory(new SplatFile(file.read()));
log("Converting to text");
FileConverter fc = new FileConverter(getWorkingDirectory());
fc.addLogger(LocalOptionTab.this);
fc.convert();
log("Starting a new Comparison");
DocumentComparison dc = (DocumentComparison) compare.result();
if(dc == null)
{
log("Could not create DocumentComparison");
return;
}
dc.addLogger(LocalOptionTab.this);
dc.addProgressListener(getProgressBar());
DocumentComparisonResult hdc = dc.getResult();
log("Showing Comparison Result");
launch(hdc);
}
}
public void setup()
{
compare.setup();
}
public static void main(String[] args)
{
JFrame jf = new JFrame();
jf.getContentPane().add(new LocalOptionTab());
jf.pack();
jf.show();
}
}