1 |
iliev |
1688 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2288 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
1688 |
* |
6 |
|
|
* This file is part of JSampler. |
7 |
|
|
* |
8 |
|
|
* JSampler is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License version 2 |
10 |
|
|
* as published by the Free Software Foundation. |
11 |
|
|
* |
12 |
|
|
* JSampler is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with JSampler; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
|
|
* MA 02111-1307 USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
package org.jsampler.view.std; |
24 |
|
|
|
25 |
|
|
import java.awt.BorderLayout; |
26 |
|
|
|
27 |
|
|
import java.awt.event.ActionEvent; |
28 |
|
|
import java.awt.event.ActionListener; |
29 |
|
|
|
30 |
|
|
import javax.swing.BorderFactory; |
31 |
|
|
import javax.swing.Box; |
32 |
|
|
import javax.swing.BoxLayout; |
33 |
|
|
import javax.swing.JButton; |
34 |
|
|
import javax.swing.JPanel; |
35 |
|
|
|
36 |
iliev |
2288 |
import net.sf.juife.swing.EnhancedDialog; |
37 |
iliev |
1688 |
|
38 |
|
|
import org.jsampler.CC; |
39 |
|
|
import org.jsampler.JSPrefs; |
40 |
|
|
import org.jsampler.Server; |
41 |
iliev |
2288 |
import org.jsampler.view.swing.SHF; |
42 |
iliev |
1688 |
|
43 |
|
|
import static org.jsampler.view.std.StdI18n.i18n; |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
/** |
47 |
|
|
* |
48 |
|
|
* @author Grigor Iliev |
49 |
|
|
*/ |
50 |
|
|
public class JSConnectDlg extends EnhancedDialog { |
51 |
|
|
private final JSConnectionPropsPane.ServerListPane serverListPane = |
52 |
|
|
new JSConnectionPropsPane.ServerListPane(); |
53 |
|
|
|
54 |
|
|
private final JButton btnConnect = |
55 |
|
|
new JButton(i18n.getButtonLabel("JSConnectDlg.btnConnect")); |
56 |
|
|
|
57 |
|
|
/** Creates a new instance of <code>JSConnectDlg</code> */ |
58 |
|
|
public |
59 |
|
|
JSConnectDlg() { |
60 |
iliev |
2288 |
super(SHF.getMainFrame(), i18n.getLabel("JSConnectDlg.title")); |
61 |
iliev |
1688 |
|
62 |
|
|
JPanel mainPane = new JPanel(); |
63 |
|
|
mainPane.setLayout(new BorderLayout()); |
64 |
|
|
|
65 |
|
|
mainPane.add(serverListPane); |
66 |
|
|
|
67 |
|
|
JPanel p = new JPanel(); |
68 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
69 |
|
|
p.add(Box.createGlue()); |
70 |
|
|
p.add(btnConnect); |
71 |
|
|
p.add(Box.createGlue()); |
72 |
|
|
p.setBorder(BorderFactory.createEmptyBorder(12, 0, 0, 0)); |
73 |
|
|
|
74 |
|
|
mainPane.add(p, BorderLayout.SOUTH); |
75 |
|
|
mainPane.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
76 |
|
|
mainPane.setPreferredSize(new java.awt.Dimension(300, 300)); |
77 |
|
|
|
78 |
|
|
btnConnect.addActionListener(new ActionListener() { |
79 |
|
|
public void |
80 |
|
|
actionPerformed(ActionEvent e) { onOk(); } |
81 |
|
|
}); |
82 |
|
|
|
83 |
|
|
getContentPane().add(mainPane); |
84 |
|
|
|
85 |
|
|
pack(); |
86 |
|
|
setMinimumSize(getPreferredSize()); |
87 |
|
|
|
88 |
|
|
btnConnect.requestFocus(); |
89 |
|
|
|
90 |
|
|
setLocationRelativeTo(getOwner()); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
private static JSPrefs |
94 |
|
|
preferences() { return CC.getViewConfig().preferences(); } |
95 |
|
|
|
96 |
|
|
protected void |
97 |
|
|
onOk() { |
98 |
|
|
setVisible(false); |
99 |
|
|
setCancelled(false); |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
protected void |
103 |
|
|
onCancel() { |
104 |
|
|
setVisible(false); |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
/** Returns the server that is selected by the user to connect. */ |
108 |
|
|
public Server |
109 |
|
|
getSelectedServer() { |
110 |
|
|
if(isCancelled()) return null; |
111 |
|
|
return serverListPane.serverTable.getSelectedServer(); |
112 |
|
|
} |
113 |
|
|
} |