• R/O
  • HTTP
  • SSH
  • HTTPS

MIDIChordHelper: Commit

Javaアプリ MIDI Chord Helper のソースコード


Commit MetaInfo

Revision3d2ee402da9526e55bffffdfef98b7da16c39659 (tree)
Time2018-01-08 23:42:07
AuthorAkiyoshi Kamide <kamide@yk.r...>
CommiterAkiyoshi Kamide

Log Message

・シーケンス削除後プレイリストが空になるときIndexOB例外が発生していた問題の修正
・表選択インデックス周りのリファクタリング

Change Summary

Incremental Difference

--- a/src/camidion/chordhelper/ChordHelperApplet.java
+++ b/src/camidion/chordhelper/ChordHelperApplet.java
@@ -266,8 +266,8 @@ public class ChordHelperApplet extends JApplet {
266266 */
267267 public static class VersionInfo {
268268 public static final String NAME = "MIDI Chord Helper";
269- public static final String VERSION = "Ver.20170930.1";
270- public static final String COPYRIGHT = "Copyright (C) 2004-2017";
269+ public static final String VERSION = "Ver.20180108.1";
270+ public static final String COPYRIGHT = "Copyright (C) 2004-2018";
271271 public static final String AUTHER = "@きよし - Akiyoshi Kamide";
272272 public static final String URL = "http://www.yk.rim.or.jp/~kamide/music/chordhelper/";
273273 }
--- a/src/camidion/chordhelper/MidiChordHelper.java
+++ b/src/camidion/chordhelper/MidiChordHelper.java
@@ -70,7 +70,7 @@ public class MidiChordHelper extends JFrame implements AppletStub, AppletContext
7070 setTitle(titleOf(sequencer.getSequenceTrackListTableModel()));
7171 }
7272 private MidiChordHelper(List<File> fileList) {
73- setTitle(ChordHelperApplet.VersionInfo.NAME);
73+ setTitle(titleOf(null));
7474 JLabel startingLabel = new JLabel(
7575 "<html>"
7676 +"<div width=300 height=50 style='font-size: 120%; font-style: italic; text-align: center;'>"
--- a/src/camidion/chordhelper/midieditor/MidiEventTable.java
+++ b/src/camidion/chordhelper/midieditor/MidiEventTable.java
@@ -198,7 +198,7 @@ public class MidiEventTable extends JTable {
198198 eventDialog.midiMessageForm.durationForm.setPPQ(ppq);
199199 tickPositionModel.setSequenceIndex(sequenceTableModel.getSequenceTickIndex());
200200
201- selectedIndex = selectionModel.getMinSelectionIndex();
201+ selectedIndex = getSelectedRow();
202202 selectedMidiEvent = selectedIndex < 0 ? null : trackModel.getMidiEvent(selectedIndex);
203203 currentTick = selectedMidiEvent == null ? 0 : selectedMidiEvent.getTick();
204204 tickPositionModel.setTickPosition(currentTick);
--- a/src/camidion/chordhelper/midieditor/MidiSequenceEditorDialog.java
+++ b/src/camidion/chordhelper/midieditor/MidiSequenceEditorDialog.java
@@ -120,7 +120,7 @@ public class MidiSequenceEditorDialog extends JDialog {
120120 * すでに再生されていた場合、このエディタダイアログを表示します。
121121 */
122122 public void play() {
123- play(playlistTable.getSelectionModel().getMinSelectionIndex());
123+ play(playlistTable.getSelectedRow());
124124 }
125125
126126 static final Icon deleteIcon = new ButtonIcon(ButtonIcon.X_ICON);
--- a/src/camidion/chordhelper/midieditor/PlaylistTable.java
+++ b/src/camidion/chordhelper/midieditor/PlaylistTable.java
@@ -62,10 +62,10 @@ public class PlaylistTable extends JTable {
6262 * @return 選択されたMIDIシーケンスのテーブルモデル(非選択時はnull)
6363 */
6464 private SequenceTrackListTableModel getSelectedSequenceModel() {
65- if( selectionModel.isSelectionEmpty() ) return null;
66- int selectedIndex = selectionModel.getMinSelectionIndex();
65+ int i = getSelectedRow();
66+ if( i < 0 ) return null;
6767 List<SequenceTrackListTableModel> list = getModel().getSequenceModelList();
68- return selectedIndex >= list.size() ? null : list.get(selectedIndex);
68+ return i >= list.size() ? null : list.get(i);
6969 }
7070 /**
7171 * 行が選択されているときだけイネーブルになるアクション
@@ -83,8 +83,7 @@ public class PlaylistTable extends JTable {
8383 setEnebledBySelection();
8484 }
8585 protected void setEnebledBySelection() {
86- int index = selectionModel.getMinSelectionIndex();
87- setEnabled(index >= 0);
86+ setEnabled(getSelectedRow() >= 0);
8887 }
8988 private void init(String tooltip) {
9089 putValue(Action.SHORT_DESCRIPTION, tooltip);
@@ -373,10 +372,15 @@ public class PlaylistTable extends JTable {
373372 "選択したMIDIシーケンスはまだ保存されていません。プレイリストから削除しますか?";
374373 @Override
375374 public void actionPerformed(ActionEvent event) {
375+ int index = getSelectedRow();
376+ if( index < 0 ) return;
376377 PlaylistTableModel model = getModel();
378+ List<SequenceTrackListTableModel> list = model.getSequenceModelList();
379+ if( index >= list.size() ) return;
380+ SequenceTrackListTableModel sequenceModel = list.get(index);
381+ if( sequenceModel == null ) return;
377382 if( midiFileChooser != null ) {
378- SequenceTrackListTableModel sequenceModel = getSelectedSequenceModel();
379- if( sequenceModel != null && sequenceModel.isModified() && JOptionPane.showConfirmDialog(
383+ if( sequenceModel.isModified() && JOptionPane.showConfirmDialog(
380384 ((JComponent)event.getSource()).getRootPane(),
381385 CONFIRM_MESSAGE,
382386 ChordHelperApplet.VersionInfo.NAME,
@@ -384,8 +388,8 @@ public class PlaylistTable extends JTable {
384388 JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION
385389 ) return;
386390 }
387- if( ! selectionModel.isSelectionEmpty() ) try {
388- model.remove(selectionModel.getMinSelectionIndex());
391+ try {
392+ model.remove(index);
389393 } catch (Exception ex) {
390394 JOptionPane.showMessageDialog(
391395 ((JComponent)event.getSource()).getRootPane(), ex,
--- a/src/camidion/chordhelper/midieditor/PlaylistTableModel.java
+++ b/src/camidion/chordhelper/midieditor/PlaylistTableModel.java
@@ -294,7 +294,7 @@ public class PlaylistTableModel extends AbstractTableModel {
294294 if( column != null && ! column.isChanged(event) ) return false;
295295 SequenceTrackListTableModel loadedSequence = sequencerModel.getSequenceTrackListTableModel();
296296 return loadedSequence != null && IntStream.rangeClosed(event.getFirstRow(), event.getLastRow())
297- .anyMatch( index -> index != TableModelEvent.HEADER_ROW && sequenceModelList.get(index) == loadedSequence );
297+ .anyMatch( i -> i >= 0 && i < sequenceModelList.size() && sequenceModelList.get(i) == loadedSequence );
298298 }
299299 /**
300300 * [row, column]にあるセルの値が更新されたことを、すべてのリスナーに通知します。
--- a/src/camidion/chordhelper/midieditor/SequenceTrackListTable.java
+++ b/src/camidion/chordhelper/midieditor/SequenceTrackListTable.java
@@ -80,7 +80,7 @@ public class SequenceTrackListTable extends JTable {
8080 if( event.getValueIsAdjusting() ) return;
8181 deleteTrackAction.setEnabled(! selectionModel.isSelectionEmpty());
8282 eventListTable.setModel(getModel().getSelectedTrackModel(selectionModel));
83- eventListTable.titleLabel.showTrackNumber(selectionModel.getMinSelectionIndex());
83+ eventListTable.titleLabel.showTrackNumber(getSelectedRow());
8484 });
8585 }
8686 /**
Show on old repository browser