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
5 import javax.swing.AbstractAction;
6 import javax.swing.Action;
7 import javax.swing.JDialog;
8 import javax.swing.JScrollPane;
9 import javax.swing.JSplitPane;
10
11 import camidion.chordhelper.ButtonIcon;
12
13 /**
14  * MIDIデバイスダイアログ (View)
15  */
16 public class MidiDeviceDialog extends JDialog {
17         /**
18          * MIDIデバイスダイアログを構築します。
19          * @param deviceModelList デバイスモデル(MIDIコネクタリストモデル)のリスト
20          */
21         public MidiDeviceDialog(MidiTransceiverListModelList deviceModelList) {
22                 setTitle(openAction.getValue(Action.NAME).toString());
23                 setBounds( 300, 300, 800, 500 );
24                 MidiDeviceTreeModel deviceTreeModel = new MidiDeviceTreeModel(deviceModelList);
25                 MidiDeviceTreeView deviceTreeView = new MidiDeviceTreeView(deviceTreeModel);
26                 MidiDeviceInfoPane deviceInfoPane = new MidiDeviceInfoPane();
27                 MidiOpenedDevicesView desktopPane = new MidiOpenedDevicesView(deviceTreeView, deviceInfoPane, this);
28                 deviceTreeView.addTreeSelectionListener(deviceInfoPane);
29                 deviceTreeView.addTreeSelectionListener(desktopPane);
30                 add(new JSplitPane(
31                         JSplitPane.HORIZONTAL_SPLIT,
32                         new JSplitPane(
33                                 JSplitPane.VERTICAL_SPLIT,
34                                 new JScrollPane(deviceTreeView),
35                                 new JScrollPane(deviceInfoPane)
36                         ){{
37                                 setDividerLocation(260);
38                         }},
39                         desktopPane
40                 ){{
41                         setOneTouchExpandable(true);
42                         setDividerLocation(250);
43                 }});
44         }
45         /**
46          * MIDIデバイスダイアログを開くアクション
47          */
48         public Action openAction = new AbstractAction() {
49                 {
50                         putValue(NAME, "MIDI device connection");
51                         putValue(SHORT_DESCRIPTION, "MIDIデバイス間の接続を編集");
52                         putValue(LARGE_ICON_KEY, new ButtonIcon(ButtonIcon.MIDI_CONNECTOR_ICON));
53                 }
54                 @Override
55                 public void actionPerformed(ActionEvent event) { setVisible(true); }
56         };
57 }