annotate SMART/Java/Smart.java @ 34:529e3e6a0954

Deleted selected files
author m-zytnicki
date Tue, 30 Apr 2013 14:35:27 -0400
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 /**
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 * Copyright INRA-URGI 2009-2010
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5 * This software is governed by the CeCILL license under French law and
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 * abiding by the rules of distribution of free software. You can use,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 * modify and/ or redistribute the software under the terms of the CeCILL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 * license as circulated by CEA, CNRS and INRIA at the following URL
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 * "http://www.cecill.info".
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 * As a counterpart to the access to the source code and rights to copy,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 * modify and redistribute granted by the license, users are provided only
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 * with a limited warranty and the software's author, the holder of the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14 * economic rights, and the successive licensors have only limited
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 * liability.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 * In this respect, the user's attention is drawn to the risks associated
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 * with loading, using, modifying and/or developing or reproducing the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 * software by the user in light of its specific status of free software,
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20 * that may mean that it is complicated to manipulate, and that also
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 * therefore means that it is reserved for developers and experienced
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 * professionals having in-depth computer knowledge. Users are therefore
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 * encouraged to load and test the software's suitability as regards their
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 * requirements in conditions enabling the security of their systems and/or
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 * data to be ensured and, more generally, to use and operate it in the
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 * same conditions as regards security.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 * The fact that you are presently reading this means that you have had
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 * knowledge of the CeCILL license and that you accept its terms.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30 *
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 */
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 import java.util.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 import java.awt.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 import java.awt.event.ActionEvent;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 import java.awt.event.ActionListener;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36 import java.awt.event.WindowEvent;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 import java.awt.event.WindowAdapter;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 import java.io.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 import javax.swing.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40 import javax.swing.filechooser.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 import javax.swing.border.*;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 import javax.swing.SwingUtilities;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 import java.util.prefs.BackingStoreException;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 public class Smart extends JPanel implements ActionListener {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 String version = "1.1.0";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 JFrame mainFrame;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 JButton openButton;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 JButton resetFileButton;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 JComboBox formatTypes;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 JComboBox fileFormats;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56 String[] emptyFormats = {"Choose a type first..."};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 JFrame askFrame;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 JButton pythonButton;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
60 JButton mySqlButton;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
61 JButton rButton;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
62
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
63 HashMap <JButton, Program> callingProgram;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
64
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
65 static JList fileList;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
66 static JTextArea logArea;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
67
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
68 // progress bar
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
69 static JLabel messageField;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
70 static JProgressBar progressBar;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
71 static JLabel etaField;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
72
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
73 // process
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
74 Program currentProgram;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
75 Process process;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
76 javax.swing.Timer processTimer;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
77
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
78
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
79 int previousStatus;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
80
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
81 public Smart() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
82 super(new BorderLayout());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
83
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
84 callingProgram = new HashMap <JButton, Program> ();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
85
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
86 previousStatus = -1;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
87
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
88 processTimer = new javax.swing.Timer(1000, this);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
89 processTimer.stop();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
90
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
91 // Ask frame buttons
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
92 pythonButton = new JButton("find...");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
93 mySqlButton = new JButton("find...");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
94 rButton = new JButton("find...");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
95
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
96 // Get available formats
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
97 FormatsReader formatReader = new FormatsReader(Global.smartFormatsFileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
98 if (! formatReader.read()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
99 System.out.println("Something was wrong while reading file format...");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
100 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
101
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
102 // Get screen size
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
103 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
104
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
105 // Log
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
106 logArea = new JTextArea(512, Global.logAreaSize);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
107 logArea.setPreferredSize(new Dimension(screenSize.width, (int) (screenSize.height * 0.22)));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
108 logArea.setFont(new Font("Monospaced", logArea.getFont().getStyle(), logArea.getFont().getSize()));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
109 JScrollPane logScroll = new JScrollPane(logArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
110 TitledBorder logBorder = BorderFactory.createTitledBorder("Log");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
111 logScroll.setBorder(logBorder);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
112 logArea.append("Using S-MART " + version + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
113
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
114 GridLayout horizontalLayout = new GridLayout(1, 0);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
115
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
116 // check configuration
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
117 this.readConfigurationFile();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
118 if (System.getProperty("os.name").matches("(?i).*Windows.*")) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
119 if (! this.checkDefaultDir()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
120 this.checkRegistries();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
121 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
122 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
123 this.checkConfiguration();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
124
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
125 // Tabs
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
126 JTabbedPane tabbedPane = new JTabbedPane();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
127 tabbedPane.setPreferredSize(new Dimension(screenSize.width, (int) (screenSize.height * 0.75)));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
128
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
129 // File panel
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
130 JPanel filePanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
131 filePanel.setLayout(new FlowLayout());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
132 tabbedPane.add("Files", filePanel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
133
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
134 // Format sub-panel
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
135 JPanel formatComboPanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
136 JPanel formatPanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
137 Vector<String> formatTypesString = Global.formats.getFormatTypes();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
138 formatPanel.setLayout(horizontalLayout);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
139 formatTypesString.insertElementAt("Choose the format type", 0);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
140 JLabel formatLabel = new JLabel("Format");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
141 formatTypes = new JComboBox(formatTypesString);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
142 fileFormats = new JComboBox(emptyFormats);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
143 formatLabel.setLabelFor(fileFormats);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
144 formatTypes.addActionListener(this);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
145 formatComboPanel.add(formatTypes);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
146 formatComboPanel.add(fileFormats);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
147
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
148 formatPanel.add(formatLabel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
149 formatPanel.add(formatComboPanel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
150
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
151 // File chooser sub-panel
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
152 JPanel fileChooserPanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
153 fileChooserPanel.setLayout(horizontalLayout);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
154 JLabel fileLabel = new JLabel("File");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
155 openButton = new JButton("Open a File...");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
156 openButton.addActionListener(this);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
157
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
158 fileChooserPanel.add(fileLabel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
159 fileChooserPanel.add(openButton);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
160
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
161 // File list sub-panel
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
162 JPanel existingFilesPanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
163 existingFilesPanel.setLayout(horizontalLayout);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
164 existingFilesPanel.setMinimumSize(new Dimension(10000, 10000));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
165 JLabel existingFilesLabel = new JLabel("Existing files");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
166 Box fileListBox = Box.createHorizontalBox();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
167 fileListBox.add(Box.createRigidArea(new Dimension(0, 100)));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
168 fileList = new JList(new DefaultListModel());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
169 fileList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
170 fileList.setVisibleRowCount(4);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
171 JScrollPane listScroller = new JScrollPane(fileList);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
172 fileListBox.add(listScroller);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
173
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
174 existingFilesPanel.add(existingFilesLabel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
175 existingFilesPanel.add(fileListBox);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
176
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
177 // Reset sub-panel
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
178 JPanel resetFilePanel = new JPanel(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
179 resetFileButton = new JButton("Reset");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
180 resetFileButton.addActionListener(this);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
181
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
182 // File panel layout
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
183 Box box = Box.createVerticalBox();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
184 box.add(formatPanel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
185 box.add(fileChooserPanel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
186 box.add(existingFilesPanel);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
187 box.add(resetFileButton);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
188 filePanel.add(box);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
189
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
190 // Program panels
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
191 TreeMap < String, JTabbedPane > panels = new TreeMap < String, JTabbedPane >();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
192 PythonProgramFinder programFinder = new PythonProgramFinder("Python");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
193 String comments = programFinder.findPrograms();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
194 if (comments != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
195 logArea.append(comments);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
196 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
197 for (int i = 0; i < programFinder.getPrograms().size(); i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
198 Program program = programFinder.getPrograms().get(i);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
199 JPanel programPanel = program.getPanel();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
200 String section = program.getSection();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
201 JTabbedPane sectionPane = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
202 if (panels.containsKey(section)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
203 sectionPane = panels.get(section);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
204 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
205 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
206 sectionPane = new JTabbedPane();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
207 tabbedPane.addTab(section, sectionPane);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
208 panels.put(section, sectionPane);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
209 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
210
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
211 JScrollPane programScroll = new JScrollPane(programPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
212 sectionPane.addTab(program.getName(), programScroll);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
213
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
214 JButton button = program.getButton();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
215 button.addActionListener(this);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
216 callingProgram.put(button, program);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
217 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
218
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
219 // Progress bar
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
220 JPanel progressPanel = new JPanel(new GridLayout(1, 0), false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
221 progressPanel.setPreferredSize(new Dimension(screenSize.width, (int) (screenSize.height * 0.02)));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
222 messageField = new JLabel();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
223 progressBar = new JProgressBar(0, 100);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
224 etaField = new JLabel();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
225 messageField.setHorizontalAlignment(JLabel.LEFT);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
226 progressBar.setValue(0);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
227 etaField.setHorizontalAlignment(JLabel.RIGHT);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
228 progressBar.setStringPainted(true);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
229 progressPanel.add(messageField);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
230 progressPanel.add(progressBar);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
231 progressPanel.add(etaField);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
232
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
233 add(tabbedPane, BorderLayout.PAGE_START);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
234 add(logScroll, BorderLayout.CENTER);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
235 add(progressPanel, BorderLayout.PAGE_END);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
236 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
237
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
238
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
239 public String checkSubKey(int hkey, String key, String subKey, String trace) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
240 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
241 for (String currentSubKey: WindowsRegistry.readStringSubKeys(hkey, key)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
242 trace += "Looking at sub-key " + currentSubKey;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
243 if (currentSubKey.matches(subKey)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
244 trace += " OK";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
245 return subKey;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
246 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
247 trace += "\n";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
248 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
249 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
250 catch (Exception e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
251 final Writer writer = new StringWriter();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
252 final PrintWriter printWriter = new PrintWriter(writer);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
253 e.printStackTrace(printWriter);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
254 trace += writer.toString();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
255 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
256 return null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
257 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
258
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
259 public void debugRegistry(int hkey, String keys[], String valueName, String trace) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
260 String concatenatedKeys = "";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
261 String selectedKey = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
262 for (String key: keys) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
263 selectedKey = checkSubKey(hkey, concatenatedKeys, key, trace);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
264 if (selectedKey != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
265 concatenatedKeys += "\\" + selectedKey;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
266 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
267 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
268 return;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
269 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
270 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
271 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
272
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
273
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
274 public String checkRegistry(int hkey, String key, String valueName, String trace) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
275 String result = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
276 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
277 result = WindowsRegistry.readString(hkey, key, valueName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
278 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
279 catch (Exception e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
280 final Writer writer = new StringWriter();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
281 final PrintWriter printWriter = new PrintWriter(writer);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
282 e.printStackTrace(printWriter);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
283 trace += result.toString();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
284 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
285 return result;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
286 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
287
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
288
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
289 public boolean checkDefaultDir() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
290 String defaultPythonPath = System.getProperty("user.dir") + "\\Apps\\Python\\python.exe";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
291 java.io.File defaultPythonFile = new java.io.File(defaultPythonPath);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
292 String defaultRPath = System.getProperty("user.dir") + "\\Apps\\R\\bin\\R.exe";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
293 java.io.File defaultRFile = new java.io.File(defaultRPath);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
294 if (defaultPythonFile.exists()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
295 Global.pythonCommand = defaultPythonPath;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
296 logArea.append("Python found in default directory: " + defaultPythonPath + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
297 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
298 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
299 logArea.append("Python not found in default directory: " + defaultPythonPath + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
300 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
301 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
302 if (defaultRFile.exists()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
303 logArea.append("R found in default directory: " + defaultRPath + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
304 Global.rCommand = defaultRPath;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
305 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
306 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
307 logArea.append("Python not found in default directory: " + defaultPythonPath + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
308 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
309 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
310
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
311
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
312 public boolean checkRegistries() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
313 String pythonDir = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
314 String validValue = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
315 String rDir;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
316 String[] pythonFlavors = {"2.5", "2.6", "2.7"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
317 String[] pythonDirectories = {"Python25", "Python26", "Python27"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
318 String[] rDirectories = {"R-2.11.0", "R-2.11.0-x64"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
319 String trace = "";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
320 for (String pythonFlavor: pythonFlavors) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
321 pythonDir = checkRegistry(WindowsRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Python\\PythonCore\\" + pythonFlavor + "\\InstallPath", "", trace);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
322 if (pythonDir != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
323 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
324 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
325 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
326 if (pythonDir == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
327 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
328 logArea.append("Using OS: " + WindowsRegistry.readString(WindowsRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "ProductName") + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
329 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
330 catch (Exception e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
331 logArea.append("Cannot do simple registry test. Strange...\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
332 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
333 String keys[] = {"SOFTWARE", "Python", "PythonCore", "2.[567]", "InstallPath"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
334 debugRegistry(WindowsRegistry.HKEY_LOCAL_MACHINE, keys, "", trace);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
335 logArea.append("S-MART cannot find Python installation directory using registry. Trying desperate move...\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
336 for (String currentDirectory: pythonDirectories) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
337 String fileName = "C:\\" + currentDirectory;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
338 java.io.File file = new java.io.File(fileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
339 if (file.exists()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
340 pythonDir = fileName;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
341 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
342 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
343 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
344 if (pythonDir == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
345 logArea.append("S-MART cannot find Python installation directory despite all my efforts...\n" + trace);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
346 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
347 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
348 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
349 rDir = checkRegistry(WindowsRegistry.HKEY_LOCAL_MACHINE, "SOFTWARE\\R-core\\R", "InstallPath", trace);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
350 if (rDir == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
351 logArea.append("S-MART cannot find R installation directory using registry. Trying desperate move...\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
352 for (String currentDirectory: rDirectories) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
353 String fileName = "C:\\Program Files\\R\\" + currentDirectory;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
354 java.io.File file = new java.io.File(fileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
355 if (file.exists()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
356 rDir = fileName;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
357 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
358 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
359 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
360 if (rDir == null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
361 logArea.append("S-MART cannot find R installation directory despite all my efforts...\n" + trace);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
362 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
363 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
364 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
365 Global.pythonCommand = pythonDir + "\\" + "python.exe";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
366 Global.rCommand = rDir + "\\" + "bin\\R.exe";
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
367 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
368 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
369
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
370
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
371 public boolean checkConfiguration() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
372 int status = this.testConfiguration();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
373
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
374 if (status == previousStatus) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
375 logArea.append("S-MART does not seem to work properly... Tried to manage it by myself, unsuccessfully... Check documentation for further explanation...\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
376 return false;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
377 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
378
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
379 switch (status) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
380 case 0:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
381 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
382 case 1:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
383 logArea.append("S-MART does not seem to work properly... Check documentation for further explanation...\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
384 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
385 case 3:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
386 this.askWhereIsProgram("python");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
387 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
388 case 4:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
389 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
390 case 5:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
391 this.askWhereIsProgram("mySQL");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
392 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
393 case 6:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
394 this.askWhereIsProgram("R");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
395 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
396 case 7:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
397 logArea.append("Please install 'ColorBrewer' R package...\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
398 break;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
399 default:
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
400 logArea.append("Weird configuration test status: " + status + "...\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
401 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
402 previousStatus = status;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
403 return true;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
404 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
405
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
406
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
407 public int testConfiguration() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
408 String[] command = {Global.pythonCommand, "Python" + java.io.File.separator + "testInstall.py"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
409 ProgramLauncher launcher = new ProgramLauncher(command, logArea, messageField, progressBar, etaField);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
410 String line;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
411 launcher.execute();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
412 return launcher.getExitValue();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
413 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
414
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
415
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
416 public void readConfigurationFile() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
417 java.io.File file = new java.io.File(Global.smartConfFileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
418 String line = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
419
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
420 if (! file.exists()) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
421 return;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
422 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
423
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
424 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
425 BufferedReader reader = new BufferedReader(new FileReader(file));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
426
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
427 while ((line = reader.readLine()) != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
428 line = line.trim();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
429 if (line.startsWith("python:")) Global.pythonCommand = line.substring("python:".length()).trim();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
430 else if (line.startsWith("mysql:")) Global.mysqlCommand = line.substring("mysql:".length()).trim();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
431 else if (line.startsWith("r:")) Global.rCommand = line.substring("r:".length()).trim();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
432 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
433 reader.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
434 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
435 catch (FileNotFoundException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
436 logArea.append("Configuration file is empty: " + e.getMessage() + "!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
437 return;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
438 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
439 catch (IOException e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
440 logArea.append("Weird with configuration file: " + e.getMessage() + "!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
441 return;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
442 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
443 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
444
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
445
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
446 public void askWhereIsProgram(String program) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
447 askFrame = new JFrame("Where is " + program + "?");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
448 askFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
449 JLabel label = new JLabel("Where is your " + program + " (or " + program + ".exe) file?");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
450 JButton button = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
451 if ("python".equals(program)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
452 button = pythonButton;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
453 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
454 else if ("mySQL".equals(program)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
455 button = mySqlButton;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
456 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
457 else if ("R".equals(program)) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
458 button = rButton;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
459 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
460 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
461 logArea.append("Problem with the button!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
462 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
463 askFrame.getContentPane().add(label, BorderLayout.WEST);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
464 askFrame.getContentPane().add(button, BorderLayout.EAST);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
465 button.addActionListener(this);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
466 askFrame.pack();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
467 askFrame.setVisible(true);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
468 askFrame.setAlwaysOnTop(true);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
469 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
470
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
471
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
472 public void actionPerformed(ActionEvent e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
473
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
474 // Python command chooser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
475 if (e.getSource() == pythonButton) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
476 JFileChooser chooser = new JFileChooser();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
477 if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
478 Global.pythonCommand = chooser.getSelectedFile().getPath();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
479 askFrame.setVisible(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
480 askFrame.dispose();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
481 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
482 BufferedWriter out = new BufferedWriter(new FileWriter(Global.smartConfFileName, true));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
483 out.write("python: " + Global.pythonCommand + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
484 out.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
485 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
486 catch (IOException exception) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
487 logArea.append("Cannot write configuration file!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
488 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
489 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
490 this.checkConfiguration();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
491 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
492 // MySQL command chooser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
493 else if (e.getSource() == mySqlButton) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
494 JFileChooser chooser = new JFileChooser();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
495 if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
496 Global.mysqlCommand = chooser.getSelectedFile().getPath();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
497 askFrame.setVisible(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
498 askFrame.dispose();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
499 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
500 BufferedWriter out = new BufferedWriter(new FileWriter(Global.smartConfFileName, true));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
501 out.write("mysql: " + Global.mysqlCommand + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
502 out.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
503 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
504 catch (IOException exception) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
505 logArea.append("Cannot write configuration file!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
506 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
507 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
508 this.checkConfiguration();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
509 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
510 // R command chooser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
511 else if (e.getSource() == rButton) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
512 JFileChooser chooser = new JFileChooser();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
513 if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
514 Global.rCommand = chooser.getSelectedFile().getPath();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
515 askFrame.setVisible(false);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
516 askFrame.dispose();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
517 try {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
518 BufferedWriter out = new BufferedWriter(new FileWriter(Global.smartConfFileName, true));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
519 out.write("r: " + Global.rCommand + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
520 out.close();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
521 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
522 catch (IOException exception) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
523 logArea.append("Cannot write configuration file!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
524 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
525 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
526 this.checkConfiguration();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
527 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
528 // Format type
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
529 else if (e.getSource() == formatTypes) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
530 if (((String) formatTypes.getSelectedItem()).startsWith("Choose")) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
531 return;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
532 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
533 fileFormats.removeAllItems();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
534 Vector < String > selectedFormats = Global.formats.getFormats((String) formatTypes.getSelectedItem()).getFormats();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
535 for (int i = 0; i < selectedFormats.size(); i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
536 fileFormats.addItem(selectedFormats.get(i));
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
537 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
538 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
539 // Main file chooser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
540 else if (e.getSource() == openButton) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
541 if (((String) formatTypes.getSelectedItem()).startsWith("Choose")) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
542 logArea.append("Please choose a type and format before selecting a file!\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
543 return;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
544 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
545 JFileChooser chooser = new JFileChooser();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
546 if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
547 String fileName = chooser.getSelectedFile().getPath();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
548 Global.fileNames.addElement(fileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
549 Global.files.addFile(fileName, (String) formatTypes.getSelectedItem(), (String) fileFormats.getSelectedItem());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
550 DefaultListModel defaultListModel = (DefaultListModel) fileList.getModel();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
551 defaultListModel.addElement(fileName);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
552 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
553 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
554 // Reset file chooser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
555 else if (e.getSource() == resetFileButton) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
556 Global.files.clear();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
557 Global.fileNames.clear();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
558 DefaultListModel defaultListModel = (DefaultListModel) fileList.getModel();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
559 defaultListModel.clear();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
560 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
561 // Other file choosers
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
562 else if (Global.otherFilesChooser.containsKey(e.getSource())) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
563 JTextField textField = Global.otherFilesChooser.get(e.getSource());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
564 JFileChooser chooser = new JFileChooser();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
565 if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
566 textField.setText(chooser.getSelectedFile().getPath());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
567 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
568 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
569 // Other directories choosers
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
570 else if (Global.otherDirectoriesChooser.containsKey(e.getSource())) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
571 JTextField textField = Global.otherDirectoriesChooser.get(e.getSource());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
572 JFileChooser chooser = new JFileChooser();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
573 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
574 if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
575 textField.setText(chooser.getSelectedFile().getPath());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
576 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
577 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
578 else if (Global.otherFileConcatenationChooser.containsKey(e.getSource())) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
579 JTextField textField = Global.otherDirectoriesChooser.get(e.getSource());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
580 JFileChooser chooser = new JFileChooser();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
581 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
582 if (chooser.showOpenDialog(mainFrame) == JFileChooser.APPROVE_OPTION) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
583 String text = textField.getText();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
584 if ((text == null) || ("".equals(text))) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
585 textField.setText(chooser.getSelectedFile().getPath());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
586 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
587 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
588 textField.setText(text + "," + chooser.getSelectedFile().getPath());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
589 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
590 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
591 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
592 // Programs
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
593 else {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
594 currentProgram = callingProgram.get(e.getSource());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
595 String comment = currentProgram.checkValues();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
596 if (comment != null) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
597 logArea.append(comment);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
598 return;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
599 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
600 LinkedList <String> command = currentProgram.getCommand();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
601 ProgramLauncher launcher = new ProgramLauncher(command, logArea, messageField, progressBar, etaField);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
602 launcher.execute();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
603 Vector < File > outputFiles = currentProgram.getOutputFiles();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
604 for (int i = 0; i < outputFiles.size(); i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
605 File file = outputFiles.get(i);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
606 if (file.getFormatType().compareToIgnoreCase("other") != 0) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
607 Global.fileNames.addElement(file.getName());
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
608 Global.files.addFile(file);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
609 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
610 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
611 currentProgram = null;
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
612 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
613 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
614
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
615
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
616 private static void removeTmpFiles() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
617 logArea.append("You want to quit already?\nRemoving temporary files...");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
618 String[] command = {Global.pythonCommand, "Python" + java.io.File.separator + "removeAllTmpTables.py"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
619 ProgramLauncher launcher = new ProgramLauncher(command, logArea, messageField, progressBar, etaField);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
620 launcher.execute();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
621 logArea.append(" done.\nNow quitting.\nBye!");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
622 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
623
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
624
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
625 private static void printJavaVersions() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
626 String[] pro = {"java.version", "java.vm.version", "java.runtime.version"};
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
627
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
628 Properties properties = System.getProperties();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
629 for (int i = 0; i < pro.length; i++) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
630 logArea.append(pro[i] + ": " + properties.getProperty(pro[i]) + "\n");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
631 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
632 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
633
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
634 private static void createAndShowGUI() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
635 // Create and set up the window.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
636 JFrame mainFrame = new JFrame("S-Mart");
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
637 mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
638
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
639 //Create and set up the content pane.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
640 JComponent newContentPane = new Smart();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
641 newContentPane.setOpaque(true);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
642 mainFrame.setContentPane(newContentPane);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
643
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
644 // Display the window.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
645 mainFrame.pack();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
646 mainFrame.setVisible(true);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
647 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
648 mainFrame.setBounds(0, 0, screenSize.width, screenSize.height);
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
649 printJavaVersions();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
650
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
651 // Remove tmp file while quitting.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
652 mainFrame.addWindowListener(new WindowAdapter() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
653 @Override
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
654 public void windowClosing(WindowEvent e) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
655 removeTmpFiles();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
656 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
657 });
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
658 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
659
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
660
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
661 public static void main(String[] args) {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
662 javax.swing.SwingUtilities.invokeLater(new Runnable() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
663 public void run() {
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
664 createAndShowGUI();
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
665 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
666 });
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
667 }
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
668 }