27 |
import java.awt.Dialog; |
import java.awt.Dialog; |
28 |
import java.awt.Dimension; |
import java.awt.Dimension; |
29 |
import java.awt.Frame; |
import java.awt.Frame; |
30 |
|
import java.awt.Rectangle; |
31 |
|
|
32 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
33 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
38 |
import java.io.FileNotFoundException; |
import java.io.FileNotFoundException; |
39 |
import java.io.FileReader; |
import java.io.FileReader; |
40 |
|
|
|
import java.util.logging.Level; |
|
41 |
import java.util.Vector; |
import java.util.Vector; |
42 |
|
|
43 |
import javax.swing.Action; |
import javax.swing.Action; |
69 |
import org.jsampler.view.JSChannelsPane; |
import org.jsampler.view.JSChannelsPane; |
70 |
import org.jsampler.view.LscpFileFilter; |
import org.jsampler.view.LscpFileFilter; |
71 |
|
|
72 |
|
import org.jsampler.view.std.JSBackendLogFrame; |
73 |
import org.jsampler.view.std.JSConnectDlg; |
import org.jsampler.view.std.JSConnectDlg; |
74 |
import org.jsampler.view.std.JSDetailedErrorDlg; |
import org.jsampler.view.std.JSDetailedErrorDlg; |
75 |
import org.jsampler.view.std.JSQuitDlg; |
import org.jsampler.view.std.JSQuitDlg; |
76 |
import org.jsampler.view.std.JSamplerHomeChooser; |
import org.jsampler.view.std.JSamplerHomeChooser; |
77 |
|
import org.jsampler.view.std.StdUtils; |
78 |
|
|
79 |
import static org.jsampler.view.classic.A4n.a4n; |
import static org.jsampler.view.classic.A4n.a4n; |
80 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
107 |
private final JPanel bottomPane = new JPanel(); |
private final JPanel bottomPane = new JPanel(); |
108 |
private final LSConsolePane lsConsolePane = new LSConsolePane(this); |
private final LSConsolePane lsConsolePane = new LSConsolePane(this); |
109 |
private LSConsoleDlg lsConsoleDlg = null; |
private LSConsoleDlg lsConsoleDlg = null; |
110 |
|
private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame(); |
111 |
|
|
112 |
private final JTabbedPane tabbedPane = |
private final JTabbedPane tabbedPane = |
113 |
new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT); |
new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.SCROLL_TAB_LAYOUT); |
132 |
MainFrame() { |
MainFrame() { |
133 |
setTitle(i18n.getLabel("MainFrame.title")); |
setTitle(i18n.getLabel("MainFrame.title")); |
134 |
|
|
135 |
|
CC.setMainFrame(this); // TODO: |
136 |
|
|
137 |
getContentPane().add(standardBar, BorderLayout.NORTH); |
getContentPane().add(standardBar, BorderLayout.NORTH); |
138 |
getContentPane().add(mainPane); |
getContentPane().add(mainPane); |
139 |
|
|
224 |
); |
); |
225 |
|
|
226 |
setVisible(false); |
setVisible(false); |
227 |
if(ClassicPrefs.getWindowMaximized("Mainframe")) { |
if(ClassicPrefs.getWindowMaximized("MainFrame")) { |
228 |
//setExtendedState(getExtendedState() & ~MAXIMIZED_BOTH); |
//setExtendedState(getExtendedState() & ~MAXIMIZED_BOTH); |
229 |
CC.cleanExit(); |
CC.cleanExit(); |
230 |
return; |
return; |
231 |
} |
} |
232 |
|
|
233 |
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); |
|
|
ClassicPrefs.setWindowSizeAndLocation("Mainframe", sb.toString()); |
|
234 |
|
|
235 |
ClassicPrefs.setHSplitDividerLocation(hSplitPane.getDividerLocation()); |
ClassicPrefs.setHSplitDividerLocation(hSplitPane.getDividerLocation()); |
236 |
} |
} |
263 |
ClassicPrefs.setLSConsolePopOut(isLSConsolePopOut()); |
ClassicPrefs.setLSConsolePopOut(isLSConsolePopOut()); |
264 |
|
|
265 |
ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
ClassicPrefs.setVSplitDividerLocation(vSplitPane.getDividerLocation()); |
266 |
|
|
267 |
|
if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer(); |
268 |
|
if(lsConsolePane != null) lsConsolePane.disconnect(); |
269 |
super.onWindowClose(); |
super.onWindowClose(); |
270 |
} |
} |
271 |
|
|
272 |
|
@Override |
273 |
|
public void |
274 |
|
setVisible(boolean b) { |
275 |
|
if(b == isVisible()) return; |
276 |
|
|
277 |
|
super.setVisible(b); |
278 |
|
|
279 |
|
if(ClassicPrefs.getWindowMaximized("MainFrame")) { |
280 |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
281 |
|
} |
282 |
|
} |
283 |
|
|
284 |
private void |
private void |
285 |
initMainFrame() { |
initMainFrame() { |
286 |
addMenu(); |
addMenu(); |
297 |
|
|
298 |
private void |
private void |
299 |
setSavedSize() { |
setSavedSize() { |
300 |
String s = ClassicPrefs.getWindowSizeAndLocation("Mainframe"); |
Rectangle r = StdUtils.getWindowBounds("MainFrame"); |
301 |
if(s == null) { |
if(r == null) { |
302 |
setDefaultSize(); |
setDefaultSize(); |
303 |
return; |
return; |
304 |
} |
} |
305 |
|
|
306 |
try { |
setBounds(r); |
|
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); |
|
|
setDefaultSize(); |
|
|
} |
|
|
|
|
|
if(ClassicPrefs.getWindowMaximized("Mainframe")) |
|
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
|
307 |
} |
} |
308 |
|
|
309 |
private void |
private void |
631 |
mi.setIcon(null); |
mi.setIcon(null); |
632 |
m.add(mi); |
m.add(mi); |
633 |
|
|
634 |
|
final JMenuItem mi2 = new JMenuItem(i18n.getMenuLabel("window.backendLog")); |
635 |
|
m.add(mi2); |
636 |
|
mi2.addActionListener(new ActionListener() { |
637 |
|
public void |
638 |
|
actionPerformed(ActionEvent e) { |
639 |
|
if(getBackendLogFrame().isVisible()) { |
640 |
|
getBackendLogFrame().setVisible(false); |
641 |
|
} |
642 |
|
|
643 |
|
getBackendLogFrame().setVisible(true); |
644 |
|
} |
645 |
|
}); |
646 |
|
|
647 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
648 |
|
|
649 |
|
CC.addBackendProcessListener(new ActionListener() { |
650 |
|
public void |
651 |
|
actionPerformed(ActionEvent e) { |
652 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
653 |
|
} |
654 |
|
}); |
655 |
|
|
656 |
|
|
657 |
// Help |
// Help |
658 |
m = new JMenu(i18n.getMenuLabel("help")); |
m = new JMenu(i18n.getMenuLabel("help")); |
806 |
protected LSConsoleModel |
protected LSConsoleModel |
807 |
getLSConsoleModel() { return lsConsolePane.getModel(); } |
getLSConsoleModel() { return lsConsolePane.getModel(); } |
808 |
|
|
809 |
|
protected JSBackendLogFrame |
810 |
|
getBackendLogFrame() { return backendLogFrame; } |
811 |
|
|
812 |
/** |
/** |
813 |
* Sets the text color of the LS Console. |
* Sets the text color of the LS Console. |
814 |
* @param c The text color of the LS Console. |
* @param c The text color of the LS Console. |
1154 |
runScript(fc.getSelectedFile()); |
runScript(fc.getSelectedFile()); |
1155 |
} |
} |
1156 |
|
|
1157 |
private void |
@Override |
1158 |
|
public void |
1159 |
runScript(String script) { runScript(new File(script)); } |
runScript(String script) { runScript(new File(script)); } |
1160 |
|
|
1161 |
private void |
private void |