34 |
import java.awt.GridBagLayout; |
import java.awt.GridBagLayout; |
35 |
import java.awt.Insets; |
import java.awt.Insets; |
36 |
import java.awt.Paint; |
import java.awt.Paint; |
37 |
|
import java.awt.Rectangle; |
38 |
|
|
39 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
40 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
49 |
import java.io.FileReader; |
import java.io.FileReader; |
50 |
|
|
51 |
import java.util.Vector; |
import java.util.Vector; |
|
import java.util.logging.Level; |
|
52 |
|
|
53 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
54 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
76 |
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
77 |
import org.jsampler.view.fantasia.basic.FantasiaSubPanel; |
import org.jsampler.view.fantasia.basic.FantasiaSubPanel; |
78 |
|
|
79 |
|
import org.jsampler.view.std.JSBackendLogFrame; |
80 |
import org.jsampler.view.std.JSConnectDlg; |
import org.jsampler.view.std.JSConnectDlg; |
81 |
import org.jsampler.view.std.JSDetailedErrorDlg; |
import org.jsampler.view.std.JSDetailedErrorDlg; |
82 |
import org.jsampler.view.std.JSQuitDlg; |
import org.jsampler.view.std.JSQuitDlg; |
83 |
import org.jsampler.view.std.JSamplerHomeChooser; |
import org.jsampler.view.std.JSamplerHomeChooser; |
84 |
|
import org.jsampler.view.std.StdUtils; |
85 |
|
|
86 |
import static org.jsampler.view.fantasia.A4n.a4n; |
import static org.jsampler.view.fantasia.A4n.a4n; |
87 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
114 |
|
|
115 |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
116 |
private final Vector<String> recentScripts = new Vector<String>(); |
private final Vector<String> recentScripts = new Vector<String>(); |
117 |
|
|
118 |
|
private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame(); |
119 |
|
|
120 |
|
|
121 |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
229 |
|
|
230 |
private void |
private void |
231 |
setSavedSize() { |
setSavedSize() { |
232 |
String s = preferences().getStringProperty("MainFrame.sizeAndLocation"); |
Rectangle r = StdUtils.getWindowBounds("MainFrame"); |
233 |
if(s == null) { |
if(r == null) { |
234 |
setDefaultSizeAndLocation(); |
setDefaultSizeAndLocation(); |
235 |
return; |
return; |
236 |
} |
} |
|
pack(); |
|
|
try { |
|
|
int i = s.indexOf(','); |
|
|
int x = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
i = s.indexOf(','); |
|
|
int y = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
i = s.indexOf(','); |
|
|
int width = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
int height = Integer.parseInt(s); |
|
|
|
|
|
setBounds(x, y, width, height); |
|
|
} catch(Exception x) { |
|
|
String msg = "Parsing of window size and location string failed"; |
|
|
CC.getLogger().log(Level.INFO, msg, x); |
|
|
setDefaultSizeAndLocation(); |
|
|
} |
|
237 |
|
|
238 |
if(preferences().getBoolProperty("MainFrame.windowMaximized")) { |
setBounds(r); |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
|
|
} |
|
239 |
} |
} |
240 |
|
|
241 |
private void |
private void |
273 |
return; |
return; |
274 |
} |
} |
275 |
|
|
276 |
java.awt.Point p = getLocation(); |
StdUtils.saveWindowBounds("MainFrame", getBounds()); |
|
Dimension d = getSize(); |
|
|
StringBuffer sb = new StringBuffer(); |
|
|
sb.append(p.x).append(',').append(p.y).append(','); |
|
|
sb.append(d.width).append(',').append(d.height); |
|
|
preferences().setStringProperty("MainFrame.sizeAndLocation", sb.toString()); |
|
277 |
|
|
278 |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
279 |
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
282 |
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
283 |
} |
} |
284 |
|
|
285 |
|
if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer(); |
286 |
|
if(getLSConsolePane() != null) getLSConsolePane().disconnect(); |
287 |
|
|
288 |
super.onWindowClose(); |
super.onWindowClose(); |
289 |
} |
} |
290 |
|
|
291 |
|
@Override |
292 |
|
public void |
293 |
|
setVisible(boolean b) { |
294 |
|
if(b == isVisible()) return; |
295 |
|
|
296 |
|
super.setVisible(b); |
297 |
|
|
298 |
|
if(b && preferences().getBoolProperty("MainFrame.windowMaximized")) { |
299 |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
300 |
|
} |
301 |
|
} |
302 |
|
|
303 |
private void |
private void |
304 |
addMenu() { |
addMenu() { |
305 |
JMenu m; |
JMenu m; |
479 |
mi.setIcon(null); |
mi.setIcon(null); |
480 |
m.add(mi); |
m.add(mi); |
481 |
|
|
482 |
|
m.addSeparator(); |
483 |
|
|
484 |
|
final JMenuItem mi2 = new JMenuItem(i18n.getMenuLabel("window.backendLog")); |
485 |
|
m.add(mi2); |
486 |
|
mi2.addActionListener(new ActionListener() { |
487 |
|
public void |
488 |
|
actionPerformed(ActionEvent e) { |
489 |
|
if(getBackendLogFrame().isVisible()) { |
490 |
|
getBackendLogFrame().setVisible(false); |
491 |
|
} |
492 |
|
|
493 |
|
getBackendLogFrame().setVisible(true); |
494 |
|
} |
495 |
|
}); |
496 |
|
|
497 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
498 |
|
|
499 |
|
CC.addBackendProcessListener(new ActionListener() { |
500 |
|
public void |
501 |
|
actionPerformed(ActionEvent e) { |
502 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
503 |
|
} |
504 |
|
}); |
505 |
|
|
506 |
|
|
507 |
// Help |
// Help |
508 |
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
594 |
if(manualSelect) { |
if(manualSelect) { |
595 |
JSConnectDlg dlg = new JSConnectDlg(); |
JSConnectDlg dlg = new JSConnectDlg(); |
596 |
dlg.setVisible(true); |
dlg.setVisible(true); |
597 |
|
|
598 |
return dlg.getSelectedServer(); |
return dlg.getSelectedServer(); |
599 |
} |
} |
600 |
|
|
620 |
protected LSConsoleFrame |
protected LSConsoleFrame |
621 |
getLSConsoleFrame() { return lsConsoleFrame; } |
getLSConsoleFrame() { return lsConsoleFrame; } |
622 |
|
|
623 |
|
public JSBackendLogFrame |
624 |
|
getBackendLogFrame() { return backendLogFrame; } |
625 |
|
|
626 |
protected boolean |
protected boolean |
627 |
runScript() { |
runScript() { |
628 |
String s = preferences().getStringProperty("lastScriptLocation"); |
String s = preferences().getStringProperty("lastScriptLocation"); |
639 |
return true; |
return true; |
640 |
} |
} |
641 |
|
|
642 |
private void |
@Override |
643 |
|
public void |
644 |
runScript(String script) { runScript(new File(script)); } |
runScript(String script) { runScript(new File(script)); } |
645 |
|
|
646 |
private void |
private void |