OSDN Git Service

・MIDIデバイスダイアログに時間リセットボタン追加
[midichordhelper/MIDIChordHelper.git] / src / camidion / chordhelper / mididevice / MidiDeviceDialog.java
1 package camidion.chordhelper.mididevice;
2
3 import java.awt.event.ActionEvent;
4 import java.awt.event.ActionListener;
5
6 import javax.swing.AbstractAction;
7 import javax.swing.Action;
8 import javax.swing.BoxLayout;
9 import javax.swing.JButton;
10 import javax.swing.JDialog;
11 import javax.swing.JPanel;
12 import javax.swing.JScrollPane;
13 import javax.swing.JSplitPane;
14
15 import camidion.chordhelper.ButtonIcon;
16
17 /**
18  * MIDIデバイスダイアログ (View)
19  */
20 public class MidiDeviceDialog extends JDialog {
21         /**
22          * MIDIデバイスダイアログを開くアクション
23          */
24         public Action openAction = new AbstractAction() {
25                 {
26                         putValue(NAME, "MIDI device connection");
27                         putValue(SHORT_DESCRIPTION, "MIDIデバイス間の接続を編集");
28                         putValue(LARGE_ICON_KEY, new ButtonIcon(ButtonIcon.MIDI_CONNECTOR_ICON));
29                 }
30                 @Override
31                 public void actionPerformed(ActionEvent event) { setVisible(true); }
32         };
33         /**
34          * MIDIデバイスダイアログを構築します。
35          * @param deviceModelList デバイスモデル(MIDIコネクタリストモデル)のリスト
36          */
37         public MidiDeviceDialog(final MidiTransceiverListModelList deviceModelList) {
38                 setTitle(openAction.getValue(Action.NAME).toString());
39                 setBounds( 300, 300, 800, 500 );
40                 MidiDeviceTreeModel deviceTreeModel = new MidiDeviceTreeModel(deviceModelList);
41                 MidiDeviceTreeView deviceTreeView = new MidiDeviceTreeView(deviceTreeModel);
42                 final MidiDeviceInfoPane deviceInfoPane = new MidiDeviceInfoPane();
43                 MidiOpenedDevicesView desktopPane = new MidiOpenedDevicesView(deviceTreeView, deviceInfoPane, this);
44                 deviceTreeView.addTreeSelectionListener(deviceInfoPane);
45                 deviceTreeView.addTreeSelectionListener(desktopPane);
46                 deviceTreeView.setSelectionRow(0);
47                 add(new JSplitPane(
48                         JSplitPane.HORIZONTAL_SPLIT,
49                         new JSplitPane(
50                                 JSplitPane.VERTICAL_SPLIT,
51                                 new JScrollPane(deviceTreeView),
52                                 new JPanel() {{
53                                         add(new JScrollPane(deviceInfoPane));
54                                         add(new JButton("Reset time on MIDI devices") {{
55                                                 addActionListener(new ActionListener() {
56                                                         @Override
57                                                         public void actionPerformed(ActionEvent e) {
58                                                                 deviceModelList.resetMicrosecondPosition();
59                                                         }
60                                                 });
61                                         }});
62                                         setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
63                                 }}
64                         ){{
65                                 setDividerLocation(260);
66                         }},
67                         desktopPane
68                 ){{
69                         setOneTouchExpandable(true);
70                         setDividerLocation(250);
71                 }});
72         }
73 }