7 |
24 Aug 07 |
jari |
// $Id$ |
7 |
24 Aug 07 |
jari |
2 |
|
2 |
26 Feb 07 |
jari |
3 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
6 |
*/ |
2 |
26 Feb 07 |
jari |
7 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: Manager.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.16 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/07/05 19:27:32 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
13 |
*/ |
2 |
26 Feb 07 |
jari |
14 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
15 |
|
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.Event; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.Toolkit; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.event.KeyEvent; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
24 |
import java.awt.event.WindowListener; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
26 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
27 |
import java.util.Hashtable; |
2 |
26 Feb 07 |
jari |
28 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
29 |
|
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.ButtonGroup; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.JCheckBoxMenuItem; |
2 |
26 Feb 07 |
jari |
32 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
33 |
import javax.swing.JFileChooser; |
2 |
26 Feb 07 |
jari |
34 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
35 |
import javax.swing.JMenu; |
2 |
26 Feb 07 |
jari |
36 |
import javax.swing.JMenuBar; |
2 |
26 Feb 07 |
jari |
37 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
38 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
39 |
import javax.swing.JRadioButtonMenuItem; |
2 |
26 Feb 07 |
jari |
40 |
import javax.swing.KeyStroke; |
2 |
26 Feb 07 |
jari |
41 |
import javax.swing.SwingUtilities; |
2 |
26 Feb 07 |
jari |
42 |
import javax.swing.ToolTipManager; |
2 |
26 Feb 07 |
jari |
43 |
import javax.swing.UIManager; |
2 |
26 Feb 07 |
jari |
44 |
|
2 |
26 Feb 07 |
jari |
45 |
import org.tigr.util.BrowserLauncher; |
2 |
26 Feb 07 |
jari |
46 |
import org.tigr.util.Query; |
2 |
26 Feb 07 |
jari |
47 |
import org.tigr.util.awt.ActionInfoEvent; |
2 |
26 Feb 07 |
jari |
48 |
import org.tigr.util.awt.ActionInfoListener; |
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.util.awt.ImageScreen; |
2 |
26 Feb 07 |
jari |
50 |
import org.tigr.util.awt.MessageDisplay; |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
public class Manager {//A class to keep track of viewers |
2 |
26 Feb 07 |
jari |
53 |
private static Vector activeComponents; |
2 |
26 Feb 07 |
jari |
54 |
private JFrame frame; |
2 |
26 Feb 07 |
jari |
55 |
private JMenuBar menuBar; |
2 |
26 Feb 07 |
jari |
56 |
private JMenu fileMenu; |
2 |
26 Feb 07 |
jari |
57 |
private JMenuItem newMultipleArrayViewerItem; |
2 |
26 Feb 07 |
jari |
58 |
private JMenuItem newSingleArrayViewerItem; |
2 |
26 Feb 07 |
jari |
59 |
private JMenuItem newPreferencesItem; |
2 |
26 Feb 07 |
jari |
60 |
private JMenuItem loginItem; |
2 |
26 Feb 07 |
jari |
61 |
private JMenuItem quitItem; |
2 |
26 Feb 07 |
jari |
62 |
private JMenu displayMenu; |
2 |
26 Feb 07 |
jari |
63 |
private JRadioButtonMenuItem javaLFItem; |
2 |
26 Feb 07 |
jari |
64 |
private JRadioButtonMenuItem windowsLFItem; |
2 |
26 Feb 07 |
jari |
65 |
private JRadioButtonMenuItem motifLFItem; |
2 |
26 Feb 07 |
jari |
66 |
private JCheckBoxMenuItem toolTipsItem; |
2 |
26 Feb 07 |
jari |
67 |
private static JMenu windowMenu; |
2 |
26 Feb 07 |
jari |
68 |
private JMenu referencesMenu; |
2 |
26 Feb 07 |
jari |
69 |
private JMenuItem systemInfoItem; |
2 |
26 Feb 07 |
jari |
70 |
private JMenuItem acknolMenuItem; |
2 |
26 Feb 07 |
jari |
71 |
private JMenuItem papersMenuItem; |
2 |
26 Feb 07 |
jari |
72 |
private JMenuItem citationMenuItem; |
2 |
26 Feb 07 |
jari |
73 |
private JMenuItem aboutMenuItem; |
2 |
26 Feb 07 |
jari |
74 |
private ButtonGroup buttonGroup; |
2 |
26 Feb 07 |
jari |
//added 9.27.05 vu |
2 |
26 Feb 07 |
jari |
76 |
private JMenu helpMenu; |
2 |
26 Feb 07 |
jari |
77 |
private JMenuItem bugReportMenuItem; |
2 |
26 Feb 07 |
jari |
78 |
private JMenuItem featureReqMenuItem; |
2 |
26 Feb 07 |
jari |
//added by wwang |
2 |
26 Feb 07 |
jari |
80 |
private JMenuItem documentMenuItem; |
2 |
26 Feb 07 |
jari |
81 |
|
2 |
26 Feb 07 |
jari |
82 |
private static EventListener eventListener; |
2 |
26 Feb 07 |
jari |
83 |
|
2 |
26 Feb 07 |
jari |
84 |
public Manager() { |
2 |
26 Feb 07 |
jari |
85 |
try { |
2 |
26 Feb 07 |
jari |
86 |
activeComponents = new Vector(); |
2 |
26 Feb 07 |
jari |
87 |
eventListener = new EventListener(); |
2 |
26 Feb 07 |
jari |
88 |
|
2 |
26 Feb 07 |
jari |
89 |
initializeFrame(); |
2 |
26 Feb 07 |
jari |
90 |
|
2 |
26 Feb 07 |
jari |
91 |
initializeInput(); |
2 |
26 Feb 07 |
jari |
92 |
|
2 |
26 Feb 07 |
jari |
93 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
94 |
System.out.println("Exception (Manager.const()): " + e); |
2 |
26 Feb 07 |
jari |
95 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
96 |
} |
2 |
26 Feb 07 |
jari |
97 |
} |
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
99 |
/* |
2 |
26 Feb 07 |
jari |
public void initializeFrame() { |
2 |
26 Feb 07 |
jari |
frame = new JFrame("MultiExperiment Viewer"); |
2 |
26 Feb 07 |
jari |
frame.addWindowListener(eventListener); |
2 |
26 Feb 07 |
jari |
frame.setVisible(true); |
2 |
26 Feb 07 |
jari |
104 |
|
2 |
26 Feb 07 |
jari |
initializeMenuBar(frame); |
2 |
26 Feb 07 |
jari |
frame.setSize(frame.getPreferredSize()); |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
frame.validate(); |
2 |
26 Feb 07 |
jari |
frame.setResizable(false); |
2 |
26 Feb 07 |
jari |
110 |
} |
2 |
26 Feb 07 |
jari |
111 |
*/ |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
public void initializeFrame() { |
2 |
26 Feb 07 |
jari |
114 |
frame = new JFrame("MultiExperiment Viewer"); |
2 |
26 Feb 07 |
jari |
115 |
frame.addWindowListener(eventListener); |
2 |
26 Feb 07 |
jari |
116 |
|
2 |
26 Feb 07 |
jari |
117 |
initializeMenuBar(frame); |
2 |
26 Feb 07 |
jari |
118 |
frame.setSize(frame.getPreferredSize()); |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
frame.setResizable(false); |
2 |
26 Feb 07 |
jari |
//frame.pack() was required for WindowsXP |
2 |
26 Feb 07 |
jari |
122 |
frame.pack(); |
2 |
26 Feb 07 |
jari |
123 |
frame.setVisible(true); |
2 |
26 Feb 07 |
jari |
124 |
} |
2 |
26 Feb 07 |
jari |
125 |
|
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
127 |
public void initializeMenuBar(JFrame frame) { |
2 |
26 Feb 07 |
jari |
128 |
menuBar = new JMenuBar(); |
2 |
26 Feb 07 |
jari |
129 |
|
2 |
26 Feb 07 |
jari |
130 |
fileMenu = new JMenu("File"); |
2 |
26 Feb 07 |
jari |
131 |
newMultipleArrayViewerItem = new JMenuItem("New Multiple Array Viewer"); |
2 |
26 Feb 07 |
jari |
132 |
newMultipleArrayViewerItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
133 |
newMultipleArrayViewerItem.setMnemonic(KeyEvent.VK_M); |
2 |
26 Feb 07 |
jari |
134 |
fileMenu.add(newMultipleArrayViewerItem); |
2 |
26 Feb 07 |
jari |
135 |
|
2 |
26 Feb 07 |
jari |
136 |
newSingleArrayViewerItem = new JMenuItem("New Single Array Viewer"); |
2 |
26 Feb 07 |
jari |
// newSingleArrayViewerItem.setToolTipText("Temporarily Disabled -- visit www.tigr.org/software/TM4 for update."); |
2 |
26 Feb 07 |
jari |
// newSingleArrayViewerItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
139 |
newSingleArrayViewerItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
140 |
newSingleArrayViewerItem.setMnemonic(KeyEvent.VK_S); |
2 |
26 Feb 07 |
jari |
141 |
fileMenu.add(newSingleArrayViewerItem); |
2 |
26 Feb 07 |
jari |
142 |
|
2 |
26 Feb 07 |
jari |
143 |
fileMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
144 |
|
2 |
26 Feb 07 |
jari |
//newPreferencesItem = new JMenuItem("New Preferences File"); |
2 |
26 Feb 07 |
jari |
//newPreferencesItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
//newPreferencesItem.setMnemonic(KeyEvent.VK_P); |
2 |
26 Feb 07 |
jari |
//fileMenu.add(newPreferencesItem); |
2 |
26 Feb 07 |
jari |
149 |
|
2 |
26 Feb 07 |
jari |
//fileMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
//loginItem = new JMenuItem("Login to Database"); |
2 |
26 Feb 07 |
jari |
//loginItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
//loginItem.setMnemonic(KeyEvent.VK_L); |
2 |
26 Feb 07 |
jari |
//fileMenu.add(loginItem); |
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
//fileMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
158 |
|
2 |
26 Feb 07 |
jari |
159 |
quitItem = new JMenuItem("Quit"); |
2 |
26 Feb 07 |
jari |
160 |
quitItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
161 |
quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.CTRL_MASK)); |
2 |
26 Feb 07 |
jari |
162 |
fileMenu.add(quitItem); |
2 |
26 Feb 07 |
jari |
163 |
|
2 |
26 Feb 07 |
jari |
164 |
menuBar.add(fileMenu); |
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
166 |
displayMenu = new JMenu("Display"); |
2 |
26 Feb 07 |
jari |
167 |
|
2 |
26 Feb 07 |
jari |
168 |
buttonGroup = new ButtonGroup(); |
2 |
26 Feb 07 |
jari |
169 |
|
2 |
26 Feb 07 |
jari |
170 |
javaLFItem = new JRadioButtonMenuItem("Metal L&F"); |
2 |
26 Feb 07 |
jari |
171 |
javaLFItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
172 |
displayMenu.add(javaLFItem); |
2 |
26 Feb 07 |
jari |
173 |
buttonGroup.add(javaLFItem); |
2 |
26 Feb 07 |
jari |
174 |
javaLFItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
175 |
|
2 |
26 Feb 07 |
jari |
176 |
windowsLFItem = new JRadioButtonMenuItem("Windows L&F"); |
2 |
26 Feb 07 |
jari |
177 |
windowsLFItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
178 |
displayMenu.add(windowsLFItem); |
2 |
26 Feb 07 |
jari |
179 |
buttonGroup.add(windowsLFItem); |
2 |
26 Feb 07 |
jari |
180 |
|
2 |
26 Feb 07 |
jari |
181 |
motifLFItem = new JRadioButtonMenuItem("Motif L&F"); |
2 |
26 Feb 07 |
jari |
182 |
motifLFItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
183 |
displayMenu.add(motifLFItem); |
2 |
26 Feb 07 |
jari |
184 |
buttonGroup.add(motifLFItem); |
2 |
26 Feb 07 |
jari |
185 |
|
2 |
26 Feb 07 |
jari |
186 |
toolTipsItem = new JCheckBoxMenuItem("Show ToolTips"); |
2 |
26 Feb 07 |
jari |
187 |
toolTipsItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
188 |
displayMenu.add(toolTipsItem); |
2 |
26 Feb 07 |
jari |
189 |
toolTipsItem.setSelected(true); |
2 |
26 Feb 07 |
jari |
190 |
|
2 |
26 Feb 07 |
jari |
191 |
menuBar.add(displayMenu); |
2 |
26 Feb 07 |
jari |
192 |
|
2 |
26 Feb 07 |
jari |
193 |
windowMenu = new JMenu("Window"); |
2 |
26 Feb 07 |
jari |
194 |
windowMenu.setEnabled(false); //until we meet again... |
2 |
26 Feb 07 |
jari |
195 |
windowMenu.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
196 |
menuBar.add(windowMenu); |
2 |
26 Feb 07 |
jari |
197 |
|
2 |
26 Feb 07 |
jari |
198 |
referencesMenu = new JMenu("About"); |
2 |
26 Feb 07 |
jari |
199 |
|
2 |
26 Feb 07 |
jari |
200 |
acknolMenuItem = new JMenuItem("Credits"); |
2 |
26 Feb 07 |
jari |
201 |
acknolMenuItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
202 |
referencesMenu.add(acknolMenuItem); |
2 |
26 Feb 07 |
jari |
203 |
|
2 |
26 Feb 07 |
jari |
204 |
papersMenuItem = new JMenuItem("Papers / Publications"); |
2 |
26 Feb 07 |
jari |
205 |
papersMenuItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
206 |
referencesMenu.add(papersMenuItem); |
2 |
26 Feb 07 |
jari |
207 |
|
2 |
26 Feb 07 |
jari |
208 |
citationMenuItem = new JMenuItem("Referencing MeV..."); |
2 |
26 Feb 07 |
jari |
209 |
citationMenuItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
210 |
referencesMenu.add(citationMenuItem); |
2 |
26 Feb 07 |
jari |
211 |
|
2 |
26 Feb 07 |
jari |
212 |
referencesMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
213 |
|
2 |
26 Feb 07 |
jari |
214 |
systemInfoItem = new JMenuItem("System Info"); |
2 |
26 Feb 07 |
jari |
215 |
systemInfoItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
216 |
referencesMenu.add(systemInfoItem); |
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
referencesMenu.addSeparator(); |
2 |
26 Feb 07 |
jari |
219 |
|
2 |
26 Feb 07 |
jari |
220 |
aboutMenuItem = new JMenuItem("About MeV"); |
2 |
26 Feb 07 |
jari |
221 |
aboutMenuItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
222 |
referencesMenu.add(aboutMenuItem); |
2 |
26 Feb 07 |
jari |
223 |
|
2 |
26 Feb 07 |
jari |
224 |
menuBar.add(referencesMenu); |
2 |
26 Feb 07 |
jari |
225 |
|
2 |
26 Feb 07 |
jari |
//added 9.21.05 vu |
2 |
26 Feb 07 |
jari |
227 |
helpMenu = new JMenu( "Help" ); |
2 |
26 Feb 07 |
jari |
//added wwang |
2 |
26 Feb 07 |
jari |
229 |
documentMenuItem = new JMenuItem( "Mev Manual" ); |
2 |
26 Feb 07 |
jari |
230 |
documentMenuItem.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
231 |
bugReportMenuItem = new JMenuItem( "Report Bug" ); |
2 |
26 Feb 07 |
jari |
232 |
bugReportMenuItem.addActionListener( eventListener ); |
2 |
26 Feb 07 |
jari |
233 |
helpMenu.add( documentMenuItem ); |
2 |
26 Feb 07 |
jari |
234 |
helpMenu.add( bugReportMenuItem ); |
2 |
26 Feb 07 |
jari |
235 |
|
2 |
26 Feb 07 |
jari |
236 |
featureReqMenuItem = new JMenuItem( "Request a Feature" ); |
2 |
26 Feb 07 |
jari |
237 |
featureReqMenuItem.addActionListener( eventListener ); |
2 |
26 Feb 07 |
jari |
238 |
|
2 |
26 Feb 07 |
jari |
239 |
helpMenu.add( featureReqMenuItem ); |
2 |
26 Feb 07 |
jari |
240 |
|
2 |
26 Feb 07 |
jari |
241 |
menuBar.add( helpMenu ); |
2 |
26 Feb 07 |
jari |
242 |
|
2 |
26 Feb 07 |
jari |
243 |
frame.setJMenuBar(menuBar); |
2 |
26 Feb 07 |
jari |
244 |
|
2 |
26 Feb 07 |
jari |
245 |
menuBar.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width-2, menuBar.getFontMetrics(menuBar.getFont()).getHeight()+5)); |
2 |
26 Feb 07 |
jari |
246 |
} |
2 |
26 Feb 07 |
jari |
247 |
|
2 |
26 Feb 07 |
jari |
248 |
public boolean selectPreferencesFile() { |
2 |
26 Feb 07 |
jari |
249 |
File inputFile = null; |
2 |
26 Feb 07 |
jari |
250 |
String filename = ""; |
2 |
26 Feb 07 |
jari |
251 |
boolean success = false; |
2 |
26 Feb 07 |
jari |
252 |
Dimension screenSize = frame.getToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
253 |
JFileChooser chooser = new JFileChooser(System.getProperty("user.dir")); |
2 |
26 Feb 07 |
jari |
254 |
chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() { |
2 |
26 Feb 07 |
jari |
255 |
public boolean accept(File f) { |
2 |
26 Feb 07 |
jari |
256 |
String extension = ""; |
2 |
26 Feb 07 |
jari |
257 |
if (f.isDirectory()) return true; |
2 |
26 Feb 07 |
jari |
258 |
if (f.getName().endsWith("Preferences")) return true; |
2 |
26 Feb 07 |
jari |
259 |
else if (f.getName().endsWith("preferences")) return true; |
2 |
26 Feb 07 |
jari |
260 |
else if (f.getName().endsWith(".pref")) return true; |
2 |
26 Feb 07 |
jari |
261 |
else return false; |
2 |
26 Feb 07 |
jari |
262 |
} |
2 |
26 Feb 07 |
jari |
263 |
public String getDescription() { |
2 |
26 Feb 07 |
jari |
264 |
return "Preference Files"; |
2 |
26 Feb 07 |
jari |
265 |
} |
2 |
26 Feb 07 |
jari |
266 |
}); |
2 |
26 Feb 07 |
jari |
267 |
chooser.setDialogTitle("Select Preferences File"); |
2 |
26 Feb 07 |
jari |
268 |
chooser.setMultiSelectionEnabled(false); |
2 |
26 Feb 07 |
jari |
269 |
chooser.setCurrentDirectory(TMEV.getFile("preferences/")); |
2 |
26 Feb 07 |
jari |
270 |
|
2 |
26 Feb 07 |
jari |
271 |
if (chooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
272 |
inputFile = chooser.getSelectedFile(); |
2 |
26 Feb 07 |
jari |
273 |
} else { |
2 |
26 Feb 07 |
jari |
274 |
System.out.println("No preference file selected"); |
2 |
26 Feb 07 |
jari |
275 |
return false; |
2 |
26 Feb 07 |
jari |
// inputFile = new File(chooser.getCurrentDirectory(), "TMEV Preferences"); |
2 |
26 Feb 07 |
jari |
277 |
} |
2 |
26 Feb 07 |
jari |
278 |
|
2 |
26 Feb 07 |
jari |
279 |
if (TMEV.readPreferencesFile(inputFile) == false) { |
2 |
26 Feb 07 |
jari |
280 |
message(frame, "Error in preferences file: " + inputFile.getName()); |
2 |
26 Feb 07 |
jari |
281 |
TMEV.quit(); |
2 |
26 Feb 07 |
jari |
282 |
} else { |
2 |
26 Feb 07 |
jari |
283 |
System.out.println("Successfully read preferences file - " + inputFile.getName()); |
2 |
26 Feb 07 |
jari |
284 |
return true; |
2 |
26 Feb 07 |
jari |
285 |
} |
2 |
26 Feb 07 |
jari |
286 |
|
2 |
26 Feb 07 |
jari |
287 |
return false; |
2 |
26 Feb 07 |
jari |
288 |
} |
2 |
26 Feb 07 |
jari |
289 |
|
2 |
26 Feb 07 |
jari |
290 |
public static void addComponent(Component component) { |
2 |
26 Feb 07 |
jari |
291 |
activeComponents.addElement(component); |
2 |
26 Feb 07 |
jari |
292 |
updateWindowMenu(); |
2 |
26 Feb 07 |
jari |
293 |
} |
2 |
26 Feb 07 |
jari |
294 |
|
2 |
26 Feb 07 |
jari |
295 |
public static void updateWindowMenu() { |
2 |
26 Feb 07 |
jari |
296 |
String menuTitle; |
2 |
26 Feb 07 |
jari |
297 |
JMenuItem item; |
2 |
26 Feb 07 |
jari |
298 |
windowMenu.removeAll(); |
2 |
26 Feb 07 |
jari |
299 |
|
2 |
26 Feb 07 |
jari |
300 |
windowMenu.setEnabled(activeComponents.size() > 0); |
2 |
26 Feb 07 |
jari |
301 |
|
2 |
26 Feb 07 |
jari |
302 |
Component component; |
2 |
26 Feb 07 |
jari |
303 |
|
2 |
26 Feb 07 |
jari |
304 |
for(int i = 0; i < activeComponents.size(); i++) { |
2 |
26 Feb 07 |
jari |
305 |
component = (Component)(activeComponents.elementAt(i)); |
2 |
26 Feb 07 |
jari |
306 |
if(component instanceof SingleArrayViewer) { |
2 |
26 Feb 07 |
jari |
307 |
item = new JMenuItem(((SingleArrayViewer)component).getFrame().getTitle()); |
2 |
26 Feb 07 |
jari |
308 |
|
2 |
26 Feb 07 |
jari |
309 |
} else { |
2 |
26 Feb 07 |
jari |
310 |
item = new JMenuItem(((MultipleArrayViewer)component).getFrame().getTitle()); |
2 |
26 Feb 07 |
jari |
311 |
} |
2 |
26 Feb 07 |
jari |
312 |
item.setActionCommand("window-cmd"); |
2 |
26 Feb 07 |
jari |
313 |
item.addActionListener(eventListener); |
2 |
26 Feb 07 |
jari |
314 |
windowMenu.add(item); |
2 |
26 Feb 07 |
jari |
315 |
} |
2 |
26 Feb 07 |
jari |
316 |
} |
2 |
26 Feb 07 |
jari |
317 |
|
2 |
26 Feb 07 |
jari |
318 |
public static Component getLastComponent() { |
2 |
26 Feb 07 |
jari |
319 |
return ( Component ) activeComponents.lastElement(); |
2 |
26 Feb 07 |
jari |
320 |
} |
2 |
26 Feb 07 |
jari |
321 |
|
2 |
26 Feb 07 |
jari |
322 |
public static Component getComponent(int position) { |
2 |
26 Feb 07 |
jari |
323 |
return(Component) activeComponents.elementAt(position); |
2 |
26 Feb 07 |
jari |
324 |
} |
2 |
26 Feb 07 |
jari |
325 |
|
2 |
26 Feb 07 |
jari |
326 |
public static void removeComponent(Component component) { |
2 |
26 Feb 07 |
jari |
327 |
activeComponents.removeElement(component); |
2 |
26 Feb 07 |
jari |
328 |
updateWindowMenu(); |
2 |
26 Feb 07 |
jari |
329 |
} |
2 |
26 Feb 07 |
jari |
330 |
|
2 |
26 Feb 07 |
jari |
331 |
public void initializeInput() { |
2 |
26 Feb 07 |
jari |
332 |
try { |
2 |
26 Feb 07 |
jari |
// String inputPreference = TMEV.getSettingForOption("Input Preference"); |
2 |
26 Feb 07 |
jari |
334 |
String inputPreference = "Only File"; |
2 |
26 Feb 07 |
jari |
335 |
if (inputPreference.equals("Database")) { |
2 |
26 Feb 07 |
jari |
336 |
databaseLogin(); |
2 |
26 Feb 07 |
jari |
337 |
systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
338 |
systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
339 |
} else if (inputPreference.equals("File")) { |
2 |
26 Feb 07 |
jari |
340 |
databaseLogin(); |
2 |
26 Feb 07 |
jari |
341 |
systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
342 |
systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
343 |
} else if (inputPreference.equals("Only File")) { |
2 |
26 Feb 07 |
jari |
344 |
} else { |
2 |
26 Feb 07 |
jari |
345 |
Manager.message(frame, "Error: Invalid Preferences File"); |
2 |
26 Feb 07 |
jari |
346 |
} |
2 |
26 Feb 07 |
jari |
347 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
348 |
System.out.println("Exception (TMEV.initializeInput()): " + e); |
2 |
26 Feb 07 |
jari |
349 |
} |
2 |
26 Feb 07 |
jari |
350 |
} |
2 |
26 Feb 07 |
jari |
351 |
|
2 |
26 Feb 07 |
jari |
352 |
public static void createNewMultipleArrayViewer( int xOffset, int yOffset ) { |
2 |
26 Feb 07 |
jari |
353 |
MultipleArrayViewer mav = new MultipleArrayViewer(); |
2 |
26 Feb 07 |
jari |
354 |
Manager.addComponent(mav); |
2 |
26 Feb 07 |
jari |
355 |
|
2 |
26 Feb 07 |
jari |
//TMEV.clearFieldNames(); |
2 |
26 Feb 07 |
jari |
357 |
mav.getFrame().setSize(1150, 700); |
2 |
26 Feb 07 |
jari |
358 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
359 |
int x = (screenSize.width - mav.getFrame().getSize().width)/2 + xOffset; |
2 |
26 Feb 07 |
jari |
360 |
int y = (screenSize.height - mav.getFrame().getSize().height)/2 + yOffset; |
2 |
26 Feb 07 |
jari |
361 |
mav.getFrame().setLocation(x, y); |
2 |
26 Feb 07 |
jari |
362 |
mav.getFrame().setVisible(true); |
2 |
26 Feb 07 |
jari |
363 |
} |
2 |
26 Feb 07 |
jari |
364 |
|
2 |
26 Feb 07 |
jari |
365 |
public static void createNewMultipleArrayViewer() { |
2 |
26 Feb 07 |
jari |
366 |
MultipleArrayViewer mav = new MultipleArrayViewer(); |
2 |
26 Feb 07 |
jari |
367 |
Manager.addComponent(mav); |
2 |
26 Feb 07 |
jari |
368 |
|
2 |
26 Feb 07 |
jari |
//TMEV.clearFieldNames(); |
2 |
26 Feb 07 |
jari |
//Remove the next two lines (about DB system enabling) |
2 |
26 Feb 07 |
jari |
//mav.systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
//mav.systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
373 |
mav.getFrame().setSize(1150, 700); |
2 |
26 Feb 07 |
jari |
374 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
375 |
mav.getFrame().setLocation((screenSize.width - mav.getFrame().getSize().width)/2, (screenSize.height - mav.getFrame().getSize().height)/2); |
2 |
26 Feb 07 |
jari |
376 |
mav.getFrame().setVisible(true); |
7 |
24 Aug 07 |
jari |
377 |
mav.loadData(); |
2 |
26 Feb 07 |
jari |
378 |
} |
2 |
26 Feb 07 |
jari |
379 |
|
2 |
26 Feb 07 |
jari |
//wwang add for cumstomized toolbar |
2 |
26 Feb 07 |
jari |
381 |
public static void createNewCustomMultipleArrayViewer() { |
2 |
26 Feb 07 |
jari |
//TMEV.customized=true; |
2 |
26 Feb 07 |
jari |
//CustomToolbarInitDialog ctg=new CustomToolbarInitDialog(); |
2 |
26 Feb 07 |
jari |
384 |
MultipleArrayViewer mav = new MultipleArrayViewer(); |
2 |
26 Feb 07 |
jari |
385 |
Manager.addComponent(mav); |
2 |
26 Feb 07 |
jari |
386 |
|
2 |
26 Feb 07 |
jari |
//TMEV.clearFieldNames(); |
2 |
26 Feb 07 |
jari |
//Remove the next two lines (about DB system enabling) |
2 |
26 Feb 07 |
jari |
//mav.systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
//mav.systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
391 |
mav.getFrame().setSize(1150, 700); |
2 |
26 Feb 07 |
jari |
392 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
393 |
mav.getFrame().setLocation((screenSize.width - mav.getFrame().getSize().width)/2, (screenSize.height - mav.getFrame().getSize().height)/2); |
2 |
26 Feb 07 |
jari |
394 |
mav.getFrame().setVisible(true); |
2 |
26 Feb 07 |
jari |
395 |
} |
2 |
26 Feb 07 |
jari |
396 |
|
2 |
26 Feb 07 |
jari |
397 |
|
2 |
26 Feb 07 |
jari |
398 |
public static void createNewMultipleArrayViewer(MultipleArrayData data, String clusterLabel){ |
2 |
26 Feb 07 |
jari |
399 |
MultipleArrayViewer mav = new MultipleArrayViewer(data); |
2 |
26 Feb 07 |
jari |
//Remove the next two lines (about DB system enabling) |
2 |
26 Feb 07 |
jari |
//mav.systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
//mav.systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
403 |
mav.getFrame().setSize(1150, 700); |
2 |
26 Feb 07 |
jari |
404 |
if(clusterLabel != null) |
2 |
26 Feb 07 |
jari |
405 |
mav.getFrame().setTitle("Multiple Array Viewer, "+clusterLabel); |
2 |
26 Feb 07 |
jari |
406 |
Manager.addComponent(mav); |
2 |
26 Feb 07 |
jari |
407 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
408 |
mav.getFrame().setLocation((screenSize.width - mav.getFrame().getSize().width)/2, (screenSize.height - mav.getFrame().getSize().height)/2); |
2 |
26 Feb 07 |
jari |
409 |
mav.getFrame().setVisible(true); |
2 |
26 Feb 07 |
jari |
410 |
} |
2 |
26 Feb 07 |
jari |
411 |
|
2 |
26 Feb 07 |
jari |
412 |
|
2 |
26 Feb 07 |
jari |
413 |
public static void createNewMultipleArrayViewer(MultipleArrayMenubar origMenubar, MultipleArrayData data, String clusterLabel){ |
2 |
26 Feb 07 |
jari |
414 |
|
2 |
26 Feb 07 |
jari |
415 |
MultipleArrayViewer mav = new MultipleArrayViewer(data, origMenubar); |
2 |
26 Feb 07 |
jari |
//Remove the next two lines (about DB system enabling) |
2 |
26 Feb 07 |
jari |
//mav.systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
//mav.systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
419 |
mav.getFrame().setSize(1150, 700); |
2 |
26 Feb 07 |
jari |
420 |
if(clusterLabel != null) |
2 |
26 Feb 07 |
jari |
421 |
mav.getFrame().setTitle("Multiple Array Viewer, "+clusterLabel); |
2 |
26 Feb 07 |
jari |
422 |
Manager.addComponent(mav); |
2 |
26 Feb 07 |
jari |
423 |
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
424 |
mav.getFrame().setLocation((screenSize.width - mav.getFrame().getSize().width)/2, (screenSize.height - mav.getFrame().getSize().height)/2); |
2 |
26 Feb 07 |
jari |
425 |
mav.getFrame().setVisible(true); |
2 |
26 Feb 07 |
jari |
426 |
} |
2 |
26 Feb 07 |
jari |
427 |
|
2 |
26 Feb 07 |
jari |
428 |
public static void createNewSingleArrayViewer() { |
2 |
26 Feb 07 |
jari |
429 |
SingleArrayViewer sav = new SingleArrayViewer(new JFrame("Single Array Viewer")); |
2 |
26 Feb 07 |
jari |
430 |
Manager.addComponent(sav); |
2 |
26 Feb 07 |
jari |
//Remove the next two lines (about DB system enabling) |
2 |
26 Feb 07 |
jari |
432 |
sav.systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
433 |
sav.systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
434 |
sav.getFrame().setSize(650, 650); |
2 |
26 Feb 07 |
jari |
435 |
sav.getFrame().setLocation(100, 100); |
2 |
26 Feb 07 |
jari |
436 |
sav.getFrame().setVisible(true); |
2 |
26 Feb 07 |
jari |
437 |
} |
2 |
26 Feb 07 |
jari |
438 |
|
2 |
26 Feb 07 |
jari |
439 |
public static void createNewSingleArrayViewer(ISlideData preparedArray) { |
2 |
26 Feb 07 |
jari |
440 |
SingleArrayViewer sav = new SingleArrayViewer(new JFrame("Single Array Viewer"), preparedArray); |
2 |
26 Feb 07 |
jari |
441 |
Manager.addComponent(sav); |
2 |
26 Feb 07 |
jari |
//Remove the next two lines (about DB system enabling) |
2 |
26 Feb 07 |
jari |
//sav.systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
//sav.systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
445 |
sav.getFrame().setSize(650, 650); |
2 |
26 Feb 07 |
jari |
446 |
sav.getFrame().setLocation(100, 100); |
2 |
26 Feb 07 |
jari |
447 |
sav.getFrame().setVisible(true); |
2 |
26 Feb 07 |
jari |
448 |
sav.refreshSlide(); |
2 |
26 Feb 07 |
jari |
449 |
} |
2 |
26 Feb 07 |
jari |
450 |
|
2 |
26 Feb 07 |
jari |
451 |
public static void createNewSingleArrayViewer(ISlideData preparedArray, float upperCy3Cutoff, float upperCy5Cutoff) { |
2 |
26 Feb 07 |
jari |
452 |
SingleArrayViewer sav = new SingleArrayViewer(new JFrame("Single Array Viewer"), preparedArray); |
2 |
26 Feb 07 |
jari |
453 |
Manager.addComponent(sav); |
2 |
26 Feb 07 |
jari |
//Remove the next two lines (about DB system enabling) |
2 |
26 Feb 07 |
jari |
455 |
sav.systemEnable(TMEV.DB_AVAILABLE); |
2 |
26 Feb 07 |
jari |
456 |
sav.systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
457 |
sav.setUpperLimits(upperCy3Cutoff, upperCy5Cutoff); |
2 |
26 Feb 07 |
jari |
458 |
sav.panel.setXYScrollbars((long)upperCy3Cutoff, (long)upperCy5Cutoff); |
2 |
26 Feb 07 |
jari |
459 |
sav.getFrame().setSize(650, 650); |
2 |
26 Feb 07 |
jari |
460 |
sav.getFrame().setLocation(100, 100); |
2 |
26 Feb 07 |
jari |
461 |
sav.getFrame().setVisible(true); |
2 |
26 Feb 07 |
jari |
462 |
sav.refreshSlide(); |
2 |
26 Feb 07 |
jari |
463 |
} |
2 |
26 Feb 07 |
jari |
464 |
|
2 |
26 Feb 07 |
jari |
465 |
public static void displaySlideElementInfo(JFrame frame, MultipleArrayData data, int feature, int probe) { |
2 |
26 Feb 07 |
jari |
466 |
new InfoDisplay(frame, data, feature, probe); |
2 |
26 Feb 07 |
jari |
467 |
} |
2 |
26 Feb 07 |
jari |
468 |
|
2 |
26 Feb 07 |
jari |
469 |
public static void displaySlideElementInfo(JFrame frame, ISlideData slideData, ISlideDataElement element, int probe) { |
2 |
26 Feb 07 |
jari |
470 |
new InfoDisplay(frame, slideData, element, probe); |
2 |
26 Feb 07 |
jari |
471 |
} |
2 |
26 Feb 07 |
jari |
472 |
|
2 |
26 Feb 07 |
jari |
473 |
public void systemDisable(int state) { |
2 |
26 Feb 07 |
jari |
474 |
switch (state) { |
2 |
26 Feb 07 |
jari |
475 |
case TMEV.SYSTEM: |
2 |
26 Feb 07 |
jari |
476 |
break; |
2 |
26 Feb 07 |
jari |
477 |
case TMEV.DATA_AVAILABLE: |
2 |
26 Feb 07 |
jari |
478 |
break; |
2 |
26 Feb 07 |
jari |
479 |
case TMEV.DB_AVAILABLE: |
2 |
26 Feb 07 |
jari |
480 |
break; |
2 |
26 Feb 07 |
jari |
481 |
case TMEV.DB_LOGIN: |
2 |
26 Feb 07 |
jari |
482 |
break; |
2 |
26 Feb 07 |
jari |
483 |
} |
2 |
26 Feb 07 |
jari |
484 |
for (int i = 0; i < activeComponents.size(); i++) { |
2 |
26 Feb 07 |
jari |
485 |
((ArrayViewer) activeComponents.elementAt(i)).systemDisable(state); |
2 |
26 Feb 07 |
jari |
486 |
} |
2 |
26 Feb 07 |
jari |
487 |
} |
2 |
26 Feb 07 |
jari |
488 |
|
2 |
26 Feb 07 |
jari |
489 |
public void systemEnable(int state) { |
2 |
26 Feb 07 |
jari |
490 |
switch (state) { |
2 |
26 Feb 07 |
jari |
491 |
case TMEV.SYSTEM: |
2 |
26 Feb 07 |
jari |
492 |
break; |
2 |
26 Feb 07 |
jari |
493 |
case TMEV.DATA_AVAILABLE: |
2 |
26 Feb 07 |
jari |
494 |
break; |
2 |
26 Feb 07 |
jari |
495 |
case TMEV.DB_AVAILABLE: |
2 |
26 Feb 07 |
jari |
496 |
break; |
2 |
26 Feb 07 |
jari |
497 |
case TMEV.DB_LOGIN: |
2 |
26 Feb 07 |
jari |
498 |
break; |
2 |
26 Feb 07 |
jari |
499 |
} |
2 |
26 Feb 07 |
jari |
500 |
for (int i = 0; i < activeComponents.size(); i++) { |
2 |
26 Feb 07 |
jari |
501 |
((ArrayViewer)activeComponents.elementAt(i)).systemEnable(state); |
2 |
26 Feb 07 |
jari |
502 |
} |
2 |
26 Feb 07 |
jari |
503 |
} |
2 |
26 Feb 07 |
jari |
504 |
|
2 |
26 Feb 07 |
jari |
505 |
public void databaseLogin() { |
2 |
26 Feb 07 |
jari |
506 |
DatabaseLoginDialog dld = new DatabaseLoginDialog(frame); |
2 |
26 Feb 07 |
jari |
507 |
dld.addActionInfoListener(new ActionInfoListener() { |
2 |
26 Feb 07 |
jari |
508 |
public void actionInfoPerformed(ActionInfoEvent event) { |
2 |
26 Feb 07 |
jari |
509 |
Hashtable hash = event.getHashtable(); |
2 |
26 Feb 07 |
jari |
510 |
databaseLoad((String) hash.get("username"), (String) hash.get("password")); |
2 |
26 Feb 07 |
jari |
511 |
} |
2 |
26 Feb 07 |
jari |
512 |
}); |
2 |
26 Feb 07 |
jari |
513 |
dld.show(); |
2 |
26 Feb 07 |
jari |
514 |
} |
2 |
26 Feb 07 |
jari |
515 |
|
2 |
26 Feb 07 |
jari |
516 |
public void databaseLoad(String username, String password) { |
2 |
26 Feb 07 |
jari |
517 |
if ((TMEV.getConnection() != null) || TMEV.connect(username, password)) { |
2 |
26 Feb 07 |
jari |
518 |
SetDatabaseDialog sdd = new SetDatabaseDialog(frame); |
2 |
26 Feb 07 |
jari |
519 |
if (sdd.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
520 |
useDatabase(sdd.getDatabase()); |
2 |
26 Feb 07 |
jari |
521 |
} |
2 |
26 Feb 07 |
jari |
522 |
} |
2 |
26 Feb 07 |
jari |
523 |
} |
2 |
26 Feb 07 |
jari |
524 |
|
2 |
26 Feb 07 |
jari |
525 |
public void useDatabase(String database) { |
2 |
26 Feb 07 |
jari |
526 |
try { |
2 |
26 Feb 07 |
jari |
527 |
Query query = new Query("use " + database); |
2 |
26 Feb 07 |
jari |
528 |
query.executeUpdate( TMEV.getConnection( )); |
2 |
26 Feb 07 |
jari |
529 |
for (int i = 0; i < Manager.activeComponents.size(); i++) { |
2 |
26 Feb 07 |
jari |
530 |
((ArrayViewer) activeComponents.elementAt(i)).systemEnable(TMEV.DB_LOGIN); |
2 |
26 Feb 07 |
jari |
531 |
} |
2 |
26 Feb 07 |
jari |
532 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
533 |
System.out.println("Exception (ColumnApplet.useDatabase()): " + e); |
2 |
26 Feb 07 |
jari |
534 |
} |
2 |
26 Feb 07 |
jari |
535 |
} |
2 |
26 Feb 07 |
jari |
536 |
|
2 |
26 Feb 07 |
jari |
537 |
public static void message(JFrame parent, String message) { |
2 |
26 Feb 07 |
jari |
538 |
System.out.println(message); |
2 |
26 Feb 07 |
jari |
539 |
MessageDisplay md = new MessageDisplay(parent, message); |
2 |
26 Feb 07 |
jari |
540 |
md.show(); |
2 |
26 Feb 07 |
jari |
541 |
} |
2 |
26 Feb 07 |
jari |
542 |
|
2 |
26 Feb 07 |
jari |
543 |
public static void message(JFrame parent, Exception e) { |
2 |
26 Feb 07 |
jari |
544 |
message(parent, e.toString()); |
2 |
26 Feb 07 |
jari |
545 |
} |
2 |
26 Feb 07 |
jari |
546 |
|
2 |
26 Feb 07 |
jari |
547 |
public static void exception(JFrame parent, String exception) { |
2 |
26 Feb 07 |
jari |
548 |
System.out.println("EXCEPTION: " + exception); |
2 |
26 Feb 07 |
jari |
549 |
MessageDisplay md = new MessageDisplay(parent, exception); |
2 |
26 Feb 07 |
jari |
550 |
md.show(); |
2 |
26 Feb 07 |
jari |
551 |
} |
2 |
26 Feb 07 |
jari |
552 |
|
2 |
26 Feb 07 |
jari |
553 |
public static void exception(JFrame parent, Exception e) { |
2 |
26 Feb 07 |
jari |
554 |
exception(parent, e.toString()); |
2 |
26 Feb 07 |
jari |
555 |
} |
2 |
26 Feb 07 |
jari |
556 |
|
2 |
26 Feb 07 |
jari |
557 |
private void handleItems(Object target) { |
2 |
26 Feb 07 |
jari |
558 |
} |
2 |
26 Feb 07 |
jari |
559 |
|
2 |
26 Feb 07 |
jari |
560 |
public void setLookAndFeel(String lookAndFeelStr) { |
2 |
26 Feb 07 |
jari |
561 |
try { |
2 |
26 Feb 07 |
jari |
562 |
UIManager.setLookAndFeel(lookAndFeelStr); |
2 |
26 Feb 07 |
jari |
563 |
SwingUtilities.updateComponentTreeUI(frame); |
2 |
26 Feb 07 |
jari |
564 |
for (int i = 0; i < activeComponents.size(); i++) { |
2 |
26 Feb 07 |
jari |
565 |
SwingUtilities.updateComponentTreeUI(((Component) activeComponents.elementAt(i)).getParent()); |
2 |
26 Feb 07 |
jari |
566 |
} |
2 |
26 Feb 07 |
jari |
567 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
568 |
} |
2 |
26 Feb 07 |
jari |
569 |
} |
2 |
26 Feb 07 |
jari |
570 |
|
2 |
26 Feb 07 |
jari |
571 |
private class EventListener implements ActionListener, WindowListener { |
2 |
26 Feb 07 |
jari |
572 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
573 |
Object source = event.getSource(); |
2 |
26 Feb 07 |
jari |
574 |
handleItems(source); |
2 |
26 Feb 07 |
jari |
575 |
if (source == newMultipleArrayViewerItem) { |
2 |
26 Feb 07 |
jari |
576 |
createNewMultipleArrayViewer(); |
2 |
26 Feb 07 |
jari |
577 |
} else if (source == newSingleArrayViewerItem) { |
2 |
26 Feb 07 |
jari |
578 |
createNewSingleArrayViewer(); |
2 |
26 Feb 07 |
jari |
579 |
} else if (source == loginItem) { |
2 |
26 Feb 07 |
jari |
580 |
databaseLogin(); |
2 |
26 Feb 07 |
jari |
581 |
} else if (source == newPreferencesItem) { |
2 |
26 Feb 07 |
jari |
582 |
selectPreferencesFile(); |
2 |
26 Feb 07 |
jari |
583 |
} else if (source == quitItem) { |
2 |
26 Feb 07 |
jari |
584 |
TMEV.quit(); |
2 |
26 Feb 07 |
jari |
585 |
} else if (source == javaLFItem) { |
2 |
26 Feb 07 |
jari |
586 |
try { |
2 |
26 Feb 07 |
jari |
587 |
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); |
2 |
26 Feb 07 |
jari |
588 |
SwingUtilities.updateComponentTreeUI(frame); |
2 |
26 Feb 07 |
jari |
589 |
for (int i = 0; i < activeComponents.size(); i++) { |
2 |
26 Feb 07 |
jari |
590 |
SwingUtilities.updateComponentTreeUI(((Component) activeComponents.elementAt(i)).getParent()); |
2 |
26 Feb 07 |
jari |
591 |
} |
2 |
26 Feb 07 |
jari |
592 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
593 |
} |
2 |
26 Feb 07 |
jari |
594 |
} else if (source == windowsLFItem) { |
2 |
26 Feb 07 |
jari |
595 |
try { |
2 |
26 Feb 07 |
jari |
596 |
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); |
2 |
26 Feb 07 |
jari |
597 |
SwingUtilities.updateComponentTreeUI(frame); |
2 |
26 Feb 07 |
jari |
598 |
for (int i = 0; i < activeComponents.size(); i++) { |
2 |
26 Feb 07 |
jari |
599 |
SwingUtilities.updateComponentTreeUI(((Component) activeComponents.elementAt(i)).getParent()); |
2 |
26 Feb 07 |
jari |
600 |
} |
2 |
26 Feb 07 |
jari |
601 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
602 |
} |
2 |
26 Feb 07 |
jari |
603 |
} else if (source == motifLFItem) { |
2 |
26 Feb 07 |
jari |
604 |
try { |
2 |
26 Feb 07 |
jari |
605 |
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); |
2 |
26 Feb 07 |
jari |
606 |
SwingUtilities.updateComponentTreeUI(frame); |
2 |
26 Feb 07 |
jari |
607 |
for (int i = 0; i < activeComponents.size(); i++) { |
2 |
26 Feb 07 |
jari |
608 |
SwingUtilities.updateComponentTreeUI(((Component) activeComponents.elementAt(i)).getParent()); |
2 |
26 Feb 07 |
jari |
609 |
} |
2 |
26 Feb 07 |
jari |
610 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
611 |
} |
2 |
26 Feb 07 |
jari |
612 |
} else if (source == toolTipsItem) { |
2 |
26 Feb 07 |
jari |
613 |
if (toolTipsItem.isSelected()) { |
2 |
26 Feb 07 |
jari |
614 |
ToolTipManager.sharedInstance().setEnabled(true); |
2 |
26 Feb 07 |
jari |
615 |
} else { |
2 |
26 Feb 07 |
jari |
616 |
ToolTipManager.sharedInstance().setEnabled(false); |
2 |
26 Feb 07 |
jari |
617 |
} |
2 |
26 Feb 07 |
jari |
618 |
} else if(source == acknolMenuItem){ |
2 |
26 Feb 07 |
jari |
619 |
new AcknowlegementDialog(frame, AcknowlegementDialog.createAcknowlegementText()); |
2 |
26 Feb 07 |
jari |
620 |
} else if (source == papersMenuItem) { |
2 |
26 Feb 07 |
jari |
621 |
new PaperReferencesDialog(frame, PaperReferencesDialog.createReferencesText()); |
2 |
26 Feb 07 |
jari |
622 |
} else if(source == citationMenuItem){ |
2 |
26 Feb 07 |
jari |
623 |
new MevCitationDialog(frame, MevCitationDialog.createCitationText()); |
2 |
26 Feb 07 |
jari |
624 |
} else if (source == aboutMenuItem) { |
2 |
26 Feb 07 |
jari |
625 |
ImageScreen is = new ImageScreen(); |
2 |
26 Feb 07 |
jari |
626 |
is.showImageScreen(); |
2 |
26 Feb 07 |
jari |
627 |
} else if (source == systemInfoItem) { |
2 |
26 Feb 07 |
jari |
628 |
int width = 640, height = 550; |
2 |
26 Feb 07 |
jari |
629 |
InformationPanel infoPanel = new InformationPanel(); |
2 |
26 Feb 07 |
jari |
630 |
JFrame frame = new JFrame("System Information"); |
2 |
26 Feb 07 |
jari |
631 |
frame.getContentPane().add(infoPanel); |
2 |
26 Feb 07 |
jari |
632 |
frame.setSize(width, height); |
2 |
26 Feb 07 |
jari |
633 |
Dimension screenSize = frame.getToolkit().getScreenSize(); |
2 |
26 Feb 07 |
jari |
634 |
frame.setLocation(screenSize.width/2 - width/2, screenSize.height/2 - height/2); |
2 |
26 Feb 07 |
jari |
635 |
frame.setResizable(false); |
2 |
26 Feb 07 |
jari |
636 |
frame.setVisible(true); |
2 |
26 Feb 07 |
jari |
637 |
infoPanel.Start(); |
2 |
26 Feb 07 |
jari |
638 |
} else if( source == bugReportMenuItem ) { //added 9.27.05 vu |
2 |
26 Feb 07 |
jari |
639 |
try { |
2 |
26 Feb 07 |
jari |
640 |
BrowserLauncher.openURL( "http://sourceforge.net/tracker/?atid=656691&group_id=110558&func=browse" ); |
2 |
26 Feb 07 |
jari |
641 |
} catch( IOException e ) { |
2 |
26 Feb 07 |
jari |
642 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
//BrowserLauncher doesn't work on this system, display dialog |
2 |
26 Feb 07 |
jari |
644 |
JOptionPane.showMessageDialog( frame, |
2 |
26 Feb 07 |
jari |
645 |
"Go to http://sourceforge.net/tracker/?atid=656691&group_id=110558&func=browse", |
2 |
26 Feb 07 |
jari |
646 |
"Input Error", JOptionPane.ERROR_MESSAGE ); |
2 |
26 Feb 07 |
jari |
647 |
} |
2 |
26 Feb 07 |
jari |
648 |
} else if( source == featureReqMenuItem ) { //added 9.27.05 vu |
2 |
26 Feb 07 |
jari |
649 |
try { |
2 |
26 Feb 07 |
jari |
650 |
BrowserLauncher.openURL( "http://sourceforge.net/tracker/?atid=656694&group_id=110558&func=browse" ); |
2 |
26 Feb 07 |
jari |
651 |
} catch( IOException e ) { |
2 |
26 Feb 07 |
jari |
652 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
//BrowserLauncher doesn't work on this system, display dialog |
2 |
26 Feb 07 |
jari |
654 |
JOptionPane.showMessageDialog( frame, |
2 |
26 Feb 07 |
jari |
655 |
"Go to http://sourceforge.net/tracker/?atid=656694&group_id=110558&func=browse", |
2 |
26 Feb 07 |
jari |
656 |
"Input Error", JOptionPane.ERROR_MESSAGE ); |
2 |
26 Feb 07 |
jari |
657 |
} |
2 |
26 Feb 07 |
jari |
658 |
}else if( source == documentMenuItem ) { //added wwang |
2 |
26 Feb 07 |
jari |
659 |
try { |
2 |
26 Feb 07 |
jari |
660 |
BrowserLauncher.openURL( "ftp://occams.dfci.harvard.edu/pub/bio/MeV/MeV_Manual_4_0.pdf" ); |
2 |
26 Feb 07 |
jari |
661 |
} catch( IOException e ) { |
2 |
26 Feb 07 |
jari |
662 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
//BrowserLauncher doesn't work on this system, display dialog |
2 |
26 Feb 07 |
jari |
664 |
JOptionPane.showMessageDialog( frame, |
2 |
26 Feb 07 |
jari |
665 |
"Go to ftp://occams.dfci.harvard.edu/pub/bio/MeV/MeV_Manual_4_0.pdf", |
2 |
26 Feb 07 |
jari |
666 |
"Input Error", JOptionPane.ERROR_MESSAGE ); |
2 |
26 Feb 07 |
jari |
667 |
} |
2 |
26 Feb 07 |
jari |
668 |
|
2 |
26 Feb 07 |
jari |
669 |
} |
2 |
26 Feb 07 |
jari |
670 |
if (event.getActionCommand().equals("window-cmd")) { |
2 |
26 Feb 07 |
jari |
671 |
int compCount = windowMenu.getItemCount(); |
2 |
26 Feb 07 |
jari |
672 |
JMenuItem item = (JMenuItem)(event.getSource()); |
2 |
26 Feb 07 |
jari |
673 |
|
2 |
26 Feb 07 |
jari |
674 |
for(int i = 0; i < compCount; i++) { |
2 |
26 Feb 07 |
jari |
675 |
if(item == windowMenu.getItem(i)) { |
2 |
26 Feb 07 |
jari |
676 |
JComponent component = (JComponent)activeComponents.elementAt(i); |
2 |
26 Feb 07 |
jari |
677 |
component.requestFocus(); |
2 |
26 Feb 07 |
jari |
678 |
component.setLocation(component.getLocation()); |
2 |
26 Feb 07 |
jari |
679 |
|
2 |
26 Feb 07 |
jari |
680 |
if(component.getClass() == SingleArrayViewer.class) |
2 |
26 Feb 07 |
jari |
681 |
((SingleArrayViewer)component).getFrame().requestFocus(); |
2 |
26 Feb 07 |
jari |
682 |
else |
2 |
26 Feb 07 |
jari |
683 |
((MultipleArrayViewer)component).getFrame().requestFocus(); |
2 |
26 Feb 07 |
jari |
684 |
|
2 |
26 Feb 07 |
jari |
685 |
break; |
2 |
26 Feb 07 |
jari |
686 |
} |
2 |
26 Feb 07 |
jari |
687 |
} |
2 |
26 Feb 07 |
jari |
688 |
} |
2 |
26 Feb 07 |
jari |
689 |
} |
2 |
26 Feb 07 |
jari |
690 |
|
2 |
26 Feb 07 |
jari |
691 |
public void windowClosing(WindowEvent event) { |
2 |
26 Feb 07 |
jari |
692 |
|
2 |
26 Feb 07 |
jari |
//in the event of an active save, inform user of state save |
2 |
26 Feb 07 |
jari |
694 |
if(TMEV.activeSave) { |
2 |
26 Feb 07 |
jari |
695 |
JOptionPane.showMessageDialog(frame, "Analayis save is in progress. "+ |
2 |
26 Feb 07 |
jari |
696 |
"MeV will close when complete.", "Analysis Save in Progress", JOptionPane.INFORMATION_MESSAGE); |
2 |
26 Feb 07 |
jari |
697 |
} |
2 |
26 Feb 07 |
jari |
698 |
|
2 |
26 Feb 07 |
jari |
699 |
frame.dispose(); |
2 |
26 Feb 07 |
jari |
700 |
|
2 |
26 Feb 07 |
jari |
701 |
while(TMEV.activeSave) { |
2 |
26 Feb 07 |
jari |
702 |
try { |
2 |
26 Feb 07 |
jari |
703 |
Thread.sleep(1000); |
2 |
26 Feb 07 |
jari |
704 |
} catch (Exception e) { } |
2 |
26 Feb 07 |
jari |
705 |
} |
2 |
26 Feb 07 |
jari |
706 |
System.exit(0); |
2 |
26 Feb 07 |
jari |
707 |
} |
2 |
26 Feb 07 |
jari |
708 |
|
2 |
26 Feb 07 |
jari |
709 |
|
2 |
26 Feb 07 |
jari |
710 |
public void windowOpened(WindowEvent event) {} |
2 |
26 Feb 07 |
jari |
711 |
public void windowClosed(WindowEvent event) {} |
2 |
26 Feb 07 |
jari |
712 |
public void windowIconified(WindowEvent event) {} |
2 |
26 Feb 07 |
jari |
713 |
public void windowDeiconified(WindowEvent event) {} |
2 |
26 Feb 07 |
jari |
714 |
public void windowActivated(WindowEvent event) {} |
2 |
26 Feb 07 |
jari |
715 |
public void windowDeactivated(WindowEvent event) {} |
2 |
26 Feb 07 |
jari |
716 |
} |
2 |
26 Feb 07 |
jari |
717 |
} |