-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDBBrowser.java
More file actions
107 lines (90 loc) · 3.84 KB
/
DBBrowser.java
File metadata and controls
107 lines (90 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* DBBrowser.java
* Copyright (C) 2009-2013 TMate Software Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For information on how to redistribute this software under
* the terms of a license other than GNU General Public License
* contact TMate Software at [email protected]
*/
package org.tmatesoft.sqljet.browser;
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import org.tmatesoft.sqljet.browser.core.BrowserComponentManager;
import org.tmatesoft.sqljet.browser.core.actions.AboutAction;
import org.tmatesoft.sqljet.browser.core.actions.CloseAction;
import org.tmatesoft.sqljet.browser.core.actions.ExitAction;
import org.tmatesoft.sqljet.browser.core.actions.OpenAction;
import org.tmatesoft.sqljet.browser.core.actions.RecentMenu;
/**
* @author TMate Software Ltd.
* @author Sergey Scherbina ([email protected])
*
*/
public class DBBrowser {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame();
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
DBBrowserConfig.saveWindowSize("main", e.getWindow());
e.getWindow().setVisible(false);
e.getWindow().dispose();
System.exit(0);
}
});
frame.getContentPane().setLayout(new BorderLayout());
BrowserComponentManager manager = BrowserComponentManager.create(frame);
frame.setContentPane(manager.getComponent());
JMenuBar mainMenu = createMainMenu(manager);
frame.setJMenuBar(mainMenu);
manager.open(null);
DBBrowserConfig.loadWindowSize("main", frame);
frame.setVisible(true);
}
});
}
private static JMenuBar createMainMenu(BrowserComponentManager manager) {
JMenuBar mainMenu = new JMenuBar();
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic('F');
JMenuItem openItem = fileMenu.add(new OpenAction(manager));
openItem.setAccelerator(KeyStroke.getKeyStroke("control O"));
openItem.setMnemonic('O');
JMenu recentMenu = new JMenu("Open Recent");
recentMenu.addMenuListener(new RecentMenu(manager, recentMenu));
JMenuItem recentItem = fileMenu.add(recentMenu);
recentItem.setMnemonic('R');
JMenuItem closeItem = fileMenu.add(new CloseAction(manager));
closeItem.setMnemonic('C');
fileMenu.add(new JSeparator());
JMenuItem exitItem = fileMenu.add(new ExitAction(manager));
exitItem.setAccelerator(KeyStroke.getKeyStroke("alt X"));
exitItem.setMnemonic('x');
JMenu helpMenu = new JMenu("Help");
helpMenu.setMnemonic('H');
JMenuItem aboutItem = helpMenu.add(new AboutAction(manager));
aboutItem.setMnemonic('A');
mainMenu.add(fileMenu);
mainMenu.add(helpMenu);
return mainMenu;
}
}