From 9826cd66f7f0b35b0184aad4c6326deabe6f3b59 Mon Sep 17 00:00:00 2001 From: Akiyoshi Kamide Date: Fri, 20 May 2016 01:38:21 +0900 Subject: [PATCH 1/1] =?utf8?q?=E3=83=BB=E3=82=A2=E3=83=97=E3=83=AA?= =?utf8?q?=E8=B5=B7=E5=8B=95=E6=99=82=E3=81=AB=E5=BA=95=E8=BE=BA=E3=81=AE?= =?utf8?q?=E3=82=B9=E3=83=86=E3=83=BC=E3=82=BF=E3=82=B9=E3=83=90=E3=83=BC?= =?utf8?q?=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84?= =?utf8?q?=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7=E5=BE=A9?= =?utf8?q?=E6=B4=BB=20=E3=83=BB=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?utf8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/camidion/chordhelper/ChordHelperApplet.java | 21 ++++------ src/camidion/chordhelper/MidiChordHelper.java | 46 +++++++++++----------- .../chordhelper/midieditor/MidiSequenceEditor.java | 4 +- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/src/camidion/chordhelper/ChordHelperApplet.java b/src/camidion/chordhelper/ChordHelperApplet.java index f99df71..6641944 100644 --- a/src/camidion/chordhelper/ChordHelperApplet.java +++ b/src/camidion/chordhelper/ChordHelperApplet.java @@ -289,7 +289,7 @@ public class ChordHelperApplet extends JApplet { */ public static class VersionInfo { public static final String NAME = "MIDI Chord Helper"; - public static final String VERSION = "Ver.20160518.1"; + public static final String VERSION = "Ver.20160519.1"; public static final String COPYRIGHT = "Copyright (C) 2004-2016"; public static final String AUTHER = "@きよし - Akiyoshi Kamide"; public static final String URL = "http://www.yk.rim.or.jp/~kamide/music/chordhelper/"; @@ -368,21 +368,15 @@ public class ChordHelperApplet extends JApplet { } }; } - // 終了してよいか確認する - public boolean isConfirmedToExit() { - return ! isModified() || JOptionPane.showConfirmDialog( - this, - "MIDI file not saved, exit anyway ?\n保存されていないMIDIファイルがありますが、終了してよろしいですか?", - VersionInfo.NAME, - JOptionPane.YES_NO_OPTION, - JOptionPane.WARNING_MESSAGE - ) == JOptionPane.YES_OPTION ; - } /** - * アプリケーションのアイコンイメージ + * アプリケーションのイメージアイコン */ public ImageIcon imageIcon; /** + * アプリケーションのアイコンイメージ + */ + public Image iconImage; + /** * ボタンの余白を詰めたいときに setMargin() の引数に指定するインセット */ public static final Insets ZERO_INSETS = new Insets(0,0,0,0); @@ -416,12 +410,11 @@ public class ChordHelperApplet extends JApplet { URL imageIconUrl = getClass().getResource(imageIconPath); if( imageIconUrl == null ) { System.out.println("Icon image "+imageIconPath+" not found"); - imageIcon = null; } else { imageIcon = new ImageIcon(imageIconUrl); + iconImage = imageIcon.getImage(); } - Image iconImage = (imageIcon == null) ? null : imageIcon.getImage(); rootPaneDefaultBgcolor = getContentPane().getBackground(); chordMatrix = new ChordMatrix() {{ addChordMatrixListener(new ChordMatrixListener(){ diff --git a/src/camidion/chordhelper/MidiChordHelper.java b/src/camidion/chordhelper/MidiChordHelper.java index c4ce3f1..e2321a3 100644 --- a/src/camidion/chordhelper/MidiChordHelper.java +++ b/src/camidion/chordhelper/MidiChordHelper.java @@ -11,6 +11,7 @@ import java.awt.Image; import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -30,6 +31,7 @@ import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import camidion.chordhelper.mididevice.MidiSequencerModel; +import camidion.chordhelper.midieditor.MidiSequenceEditor; import camidion.chordhelper.midieditor.PlaylistTableModel; import camidion.chordhelper.midieditor.SequenceTrackListTableModel; @@ -68,30 +70,31 @@ public class MidiChordHelper { } }); } - private static class AppletFrame extends JFrame - implements AppletStub, AppletContext - { - JLabel status_; - ChordHelperApplet applet; + private static class AppletFrame extends JFrame implements AppletStub, AppletContext { + private JLabel status_ = new JLabel("Welcome to "+ChordHelperApplet.VersionInfo.NAME) { + { setFont(getFont().deriveFont(Font.PLAIN)); } + }; + private ChordHelperApplet applet; + private WindowListener windowListener = new WindowAdapter() { + @Override + public void windowClosing(WindowEvent evt) { + MidiSequenceEditor ed = applet.deviceModelList.getEditorDialog(); + if( ! ed.sequenceListTable.getModel().isModified() || ed.confirm( + "MIDI file not saved, exit anyway ?\n"+ + "保存されていないMIDIファイルがありますが、終了してよろしいですか?" + )) System.exit(0); + } + }; public AppletFrame(ChordHelperApplet applet) { + this.applet = applet; setTitle(ChordHelperApplet.VersionInfo.NAME); - (status_ = new JLabel()).setFont( - status_.getFont().deriveFont(Font.PLAIN) - ); - add( this.applet = applet, BorderLayout.CENTER ); + add( applet, BorderLayout.CENTER ); add( status_, BorderLayout.SOUTH ); applet.setStub(this); applet.init(); - Image iconImage = applet.imageIcon == null ? null : applet.imageIcon.getImage(); - setIconImage(iconImage); + setIconImage(applet.iconImage); setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent evt) { - if( AppletFrame.this.applet.isConfirmedToExit() ) - System.exit(0); - } - }); + addWindowListener(windowListener); new TitleUpdater(applet); pack(); setLocationRelativeTo(null); @@ -102,7 +105,7 @@ public class MidiChordHelper { * タイトルバー更新器 */ private class TitleUpdater implements ChangeListener, TableModelListener { - MidiSequencerModel sequencerModel; + private MidiSequencerModel sequencerModel; /** * タイトルバー更新器の構築 * @param applet 対象アプレット @@ -118,10 +121,7 @@ public class MidiChordHelper { @Override public void tableChanged(TableModelEvent e) { int col = e.getColumn(); - if( col == PlaylistTableModel.Column.FILENAME.ordinal() ) { - setFilenameToTitle(); - } - if( col == TableModelEvent.ALL_COLUMNS ) { + if( col == PlaylistTableModel.Column.FILENAME.ordinal() || col == TableModelEvent.ALL_COLUMNS ) { setFilenameToTitle(); } } diff --git a/src/camidion/chordhelper/midieditor/MidiSequenceEditor.java b/src/camidion/chordhelper/midieditor/MidiSequenceEditor.java index 0b5e75d..3b5aa6a 100644 --- a/src/camidion/chordhelper/midieditor/MidiSequenceEditor.java +++ b/src/camidion/chordhelper/midieditor/MidiSequenceEditor.java @@ -135,7 +135,7 @@ public class MidiSequenceEditor extends JDialog { * @param message 確認メッセージ * @return 確認OKのときtrue */ - boolean confirm(String message) { + public boolean confirm(String message) { return JOptionPane.showConfirmDialog(this, message, ChordHelperApplet.VersionInfo.NAME, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ; } @@ -1135,7 +1135,7 @@ public class MidiSequenceEditor extends JDialog { /** * 新しい {@link MidiSequenceEditor} を構築します。 - * @param deviceModelList MIDIデバイスモデルリスト + * @param sequencerModel シーケンサーモデル */ public MidiSequenceEditor(MidiSequencerModel sequencerModel) { sequenceListTable = new SequenceListTable(new PlaylistTableModel(sequencerModel)); -- 2.11.0