1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
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.classic; |
24 |
|
25 |
import java.awt.Dimension; |
26 |
import java.awt.Frame; |
27 |
|
28 |
import java.awt.event.ActionEvent; |
29 |
import java.awt.event.ActionListener; |
30 |
|
31 |
import javax.swing.Box; |
32 |
import javax.swing.BoxLayout; |
33 |
import javax.swing.ButtonGroup; |
34 |
import javax.swing.JComboBox; |
35 |
import javax.swing.JLabel; |
36 |
import javax.swing.JPanel; |
37 |
import javax.swing.JRadioButton; |
38 |
|
39 |
import org.jsampler.CC; |
40 |
import org.jsampler.view.JSChannelsPane; |
41 |
|
42 |
import net.sf.juife.swing.OkCancelDialog; |
43 |
|
44 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
45 |
|
46 |
|
47 |
/** |
48 |
* |
49 |
* @author Grigor Iliev |
50 |
*/ |
51 |
public class CloseTabDlg extends OkCancelDialog { |
52 |
private final JLabel l = new JLabel(i18n.getLabel("CloseTabDlg.?")); |
53 |
protected final JRadioButton rbRemove = |
54 |
new JRadioButton(i18n.getButtonLabel("CloseTabDlg.rbRemove")); |
55 |
protected final JRadioButton rbMove = |
56 |
new JRadioButton(i18n.getButtonLabel("CloseTabDlg.rbMove")); |
57 |
protected final JComboBox cbTabs = new JComboBox(); |
58 |
|
59 |
|
60 |
/** Creates a new instance of CloseTabDlg */ |
61 |
public |
62 |
CloseTabDlg(Frame frm) { |
63 |
super(frm); |
64 |
|
65 |
JPanel mainPane = new JPanel(); |
66 |
mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); |
67 |
|
68 |
l.setAlignmentX(LEFT_ALIGNMENT); |
69 |
mainPane.add(l); |
70 |
|
71 |
mainPane.add(Box.createRigidArea(new Dimension(0, 11))); |
72 |
|
73 |
ButtonGroup bg = new ButtonGroup(); |
74 |
bg.add(rbRemove); |
75 |
bg.add(rbMove); |
76 |
rbRemove.setSelected(true); |
77 |
rbRemove.setForeground(new java.awt.Color(0xee3377)); |
78 |
|
79 |
JPanel p = new JPanel(); |
80 |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
81 |
p.add(Box.createRigidArea(new Dimension(12, 0))); |
82 |
p.add(rbRemove); |
83 |
p.setAlignmentX(LEFT_ALIGNMENT); |
84 |
mainPane.add(p); |
85 |
|
86 |
for(JSChannelsPane pane : CC.getMainFrame().getChannelsPaneList()) |
87 |
if(pane != CC.getMainFrame().getSelectedChannelsPane()) |
88 |
cbTabs.addItem(pane); |
89 |
|
90 |
cbTabs.addActionListener(new ActionListener() { |
91 |
public void |
92 |
actionPerformed(ActionEvent e) { rbMove.setSelected(true); } |
93 |
}); |
94 |
|
95 |
p = new JPanel(); |
96 |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
97 |
p.add(Box.createRigidArea(new Dimension(12, 0))); |
98 |
p.add(rbMove); |
99 |
p.add(Box.createRigidArea(new Dimension(5, 0))); |
100 |
p.add(cbTabs); |
101 |
p.setAlignmentX(LEFT_ALIGNMENT); |
102 |
mainPane.add(p); |
103 |
|
104 |
setMainPane(mainPane); |
105 |
} |
106 |
|
107 |
protected void |
108 |
onOk() { |
109 |
setCancelled(false); |
110 |
setVisible(false); |
111 |
} |
112 |
|
113 |
protected void |
114 |
onCancel() { setVisible(false); } |
115 |
|
116 |
public boolean |
117 |
remove() { return rbRemove.isSelected(); } |
118 |
|
119 |
public JSChannelsPane |
120 |
getSelectedChannelsPane() { return (JSChannelsPane)cbTabs.getSelectedItem(); } |
121 |
} |
122 |
|