1 |
iliev |
1567 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2288 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
1567 |
* |
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.Icon; |
34 |
|
|
import javax.swing.JButton; |
35 |
|
|
import javax.swing.JLabel; |
36 |
|
|
import javax.swing.JPanel; |
37 |
|
|
|
38 |
iliev |
2288 |
import net.sf.juife.swing.EnhancedDialog; |
39 |
|
|
import net.sf.juife.swing.JuifeUtils; |
40 |
iliev |
1567 |
|
41 |
iliev |
2288 |
import org.jsampler.view.swing.SHF; |
42 |
iliev |
1567 |
|
43 |
|
|
import static org.jsampler.view.std.StdI18n.i18n; |
44 |
|
|
|
45 |
|
|
/** |
46 |
|
|
* |
47 |
|
|
* @author Grigor Iliev |
48 |
|
|
*/ |
49 |
|
|
public class JSQuitDlg extends EnhancedDialog { |
50 |
|
|
private final JButton btnExport = new JButton(i18n.getButtonLabel("JSQuitDlg.btnExport")); |
51 |
|
|
private final JButton btnQuit = new JButton(i18n.getButtonLabel("JSQuitDlg.btnQuit")); |
52 |
|
|
private final JButton btnDontQuit = new JButton(i18n.getButtonLabel("JSQuitDlg.btnDontQuit")); |
53 |
|
|
|
54 |
|
|
/** Creates a new instance of <code>JSQuitDlg</code> */ |
55 |
|
|
public |
56 |
|
|
JSQuitDlg(Icon questionIcon) { |
57 |
iliev |
2288 |
super(SHF.getMainFrame()); |
58 |
iliev |
1567 |
getContentPane().setLayout(new BorderLayout()); |
59 |
|
|
|
60 |
|
|
JLabel l = new JLabel(i18n.getMessage("JSQuitDlg.sureToQuit?")); |
61 |
|
|
l.setIcon(questionIcon); |
62 |
|
|
l.setBorder(BorderFactory.createEmptyBorder(12, 12, 0, 12)); |
63 |
|
|
getContentPane().add(l); |
64 |
|
|
|
65 |
|
|
JPanel btnPane = new JPanel(); |
66 |
|
|
btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.X_AXIS)); |
67 |
|
|
btnPane.add(btnExport); |
68 |
|
|
btnPane.add(Box.createRigidArea(new java.awt.Dimension(17, 0))); |
69 |
|
|
btnPane.add(Box.createGlue()); |
70 |
|
|
btnPane.add(btnQuit); |
71 |
|
|
btnPane.add(Box.createRigidArea(new java.awt.Dimension(5, 0))); |
72 |
|
|
btnPane.add(btnDontQuit); |
73 |
|
|
|
74 |
|
|
btnPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); |
75 |
|
|
|
76 |
|
|
getContentPane().add(btnPane, BorderLayout.SOUTH); |
77 |
|
|
pack(); |
78 |
|
|
|
79 |
iliev |
2288 |
setLocation(JuifeUtils.centerLocation(this, SHF.getMainFrame())); |
80 |
iliev |
1567 |
|
81 |
|
|
btnQuit.requestFocus(); |
82 |
iliev |
1585 |
btnQuit.setMnemonic('q'); |
83 |
iliev |
1567 |
|
84 |
iliev |
1585 |
btnExport.setMnemonic('x'); |
85 |
iliev |
1567 |
btnExport.addActionListener(new ActionListener() { |
86 |
|
|
public void |
87 |
|
|
actionPerformed(ActionEvent e) { |
88 |
|
|
StdA4n.a4n.exportSamplerConfig(); |
89 |
|
|
} |
90 |
|
|
}); |
91 |
|
|
|
92 |
|
|
btnQuit.addActionListener(new ActionListener() { |
93 |
|
|
public void |
94 |
|
|
actionPerformed(ActionEvent e) { |
95 |
|
|
onOk(); |
96 |
|
|
} |
97 |
|
|
}); |
98 |
|
|
|
99 |
iliev |
1585 |
btnDontQuit.setMnemonic('n'); |
100 |
iliev |
1567 |
btnDontQuit.addActionListener(new ActionListener() { |
101 |
|
|
public void |
102 |
|
|
actionPerformed(ActionEvent e) { |
103 |
|
|
onCancel(); |
104 |
|
|
} |
105 |
|
|
}); |
106 |
|
|
|
107 |
|
|
setCancelled(true); |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
protected void |
111 |
|
|
onOk() { |
112 |
|
|
setCancelled(false); |
113 |
|
|
setVisible(false); |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
protected void |
117 |
|
|
onCancel() { setVisible(false); } |
118 |
|
|
} |