-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplatFrame.java
More file actions
168 lines (144 loc) · 3.84 KB
/
SplatFrame.java
File metadata and controls
168 lines (144 loc) · 3.84 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
/** @author Gergely Kota
SplatFrame is the entry point for Splat.
*/
public class SplatFrame extends JFrame
{
private ArrayList tabs;
private JTabbedPane jtb;
public SplatFrame()
{
// set JFrame stuff
setLocation(200,200);
setSize(800, 600);
setTitle("Splat");
setDefaultCloseOperation(EXIT_ON_CLOSE);
// Make tabs
jtb = new JTabbedPane();
tabs = new ArrayList();
if("true".equals(Config.read("showhome")))
addTab("Home", new BrowserPanel());
addTab("Local Search", new LocalOptionTab());
addTab("Spider Search", new WebSearchOptionTab());
addTab("Author Search", new AuthorOptionTab());
addTab("Saved Search", new SavedOptionTab());
getContentPane().add(jtb);
// create some basic menus
JMenuBar jmb = new JMenuBar();
setJMenuBar(jmb);
JMenu file = new JMenu("File");
JMenuItem quit = new JMenuItem("Quit");
quit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
cleanup();
System.exit(0);
}
});
file.add(quit);
jmb.add(file);
JMenu config = new JMenu("Config");
JMenuItem jmi = new JMenuItem("Configurations");
jmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
// ConfigWindow.showWindow();
ComponentedConfigWindow.showWindow();
}
});
config.add(jmi);
final SpecialCheckBoxMenuItem del = new SpecialCheckBoxMenuItem("Cleanup On Exit");
Config.addActionListener(del);
del.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
Config.write("deleteonexit", "" + del.isSelected());
}
});
// uncomment to put the cleanup on exit button back in the menu
//config.add(del);
jmb.add(config);
JMenu help = new JMenu("Help");
JMenuItem h = new JMenuItem("Help");
h.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
new HelpFrame().goTopic("General").show();
}
});
help.add(h);
JMenuItem email = new JMenuItem("Email Authors");
email.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
EmailWindow.showWindow();
}
});
help.add(email);
JMenuItem l = new JMenuItem("License");
l.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
show("help/license.txt");
}
});
help.add(l);
JMenuItem a = new JMenuItem("About");
a.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
show("help/about.txt");
}
});
help.add(a);
jmb.add(help);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
cleanup();
}
});
}
public void addTab(String title, JPanel ot)
{
jtb.add(title, ot);
tabs.add(ot);
}
private void cleanup()
{
for(int i = 0; i < tabs.size(); i++)
try
{
((OptionTab)tabs.get(i)).cleanup();
}
catch(Exception e) {}
}
public void show(String file)
{
// this needs to read from a file: license.txt
String license;
try
{
BufferedReader br = new BufferedReader(new FileReader(new File(file)));
StringBuffer sb = new StringBuffer();
while(br.ready())
sb.append(br.readLine()).append("\n");
license = sb.toString();
}
catch(Exception e) {license = "Source file not found";}
JOptionPane.showMessageDialog(null, license);
}
private class SpecialCheckBoxMenuItem extends JCheckBoxMenuItem implements ActionListener
{
public SpecialCheckBoxMenuItem(String s)
{
super(s);
boolean b = !"false".equals(Config.read("deleteonexit"));
setSelected(b);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource().equals("deleteonexit"))
setSelected("true".equals(Config.read("deleteonexit")));
}
}
public static void main(String[] args)
{
new SplatFrame().show();
}
}