From: U-nishio-PC8\nishio Date: Sun, 28 Aug 2011 09:27:51 +0000 (+0900) Subject: ソフトウェアアップデート通知をするように改良 X-Git-Tag: v0.6~22 X-Git-Url: http://git.osdn.net/view?p=nt-manager%2Fnt-manager.git;a=commitdiff_plain;h=8da00b1716141dfb79d4c2ea9b1143eacad1320b ソフトウェアアップデート通知をするように改良 --- diff --git a/src/twitter/gui/action/TweetMainAction.java b/src/twitter/gui/action/TweetMainAction.java index 9417b1d..7ba4afe 100644 --- a/src/twitter/gui/action/TweetMainAction.java +++ b/src/twitter/gui/action/TweetMainAction.java @@ -76,6 +76,7 @@ import twitter.gui.form.FollowingFollowerDialog; import twitter.gui.form.HashtagSearchDialog; import twitter.gui.form.KeywordSearchDialog; import twitter.gui.form.OutputCSVLogDialog; +import twitter.gui.form.UpdateNotifyDialog; import twitter.gui.form.UserListDialog; import twitter.gui.form.UserSearchDialog; import twitter.log.TwitterLogManager; @@ -191,6 +192,8 @@ public class TweetMainAction { private boolean isTempOpenedSendDMTab = true; //ログを保存するかどうか private boolean saveLog = false; + //update通知をするかどうか + private boolean isUpdateNotify = true; // Tweetの詳細情報を表示する部分 private JLabel userImageLabel = null; @@ -220,6 +223,8 @@ public class TweetMainAction { // 新しく取得したtweetでまだ参照していない数 private int uncheckedTimelineTweetCount = 0; private AboutDialog aboutDialog = null; + //update dialog + private UpdateNotifyDialog updateDialog = null; // アカウント情報表示ダイアログ private AccountDialog accountDialog; // ツイートを表示するテーブル管理 @@ -1328,6 +1333,15 @@ public class TweetMainAction { // dialog.setLocation(loc); dialog.setVisible(true); } + + /** + * 最新クライアント情報通知ダイアログを表示 + */ + public void actionShowUpdateDialog() { + UpdateNotifyDialog dialog = getUpdateNotifyDialog(); + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + } /** * アカウントダイアログを表示 @@ -1806,6 +1820,17 @@ public class TweetMainAction { } return aboutDialog; } + + /** + * update dialog + * @return + */ + public UpdateNotifyDialog getUpdateNotifyDialog() { + if( updateDialog == null ) { + updateDialog = new UpdateNotifyDialog(mainFrame, true, this); + } + return updateDialog; + } /** * テーブルで選択した場所のTweet情報を取得 @@ -1914,6 +1939,12 @@ public class TweetMainAction { //表示可能ツイート数 String nost = this.property.getProperty("numOfShowTweet"); + + //最新クライアント情報を通知するか + String unt = this.property.getProperty("updateNotify"); + if( unt == null ) { + unt = this.isUpdateNotify + ""; + } try { this.newTableColor = new Color(Integer.parseInt(ntrgb)); @@ -1944,6 +1975,9 @@ public class TweetMainAction { //表示可能ツイート数 this.tableElementMaxSize = Integer.parseInt(nost); + + //update notify + this.isUpdateNotify = Boolean.parseBoolean(unt); } catch (NumberFormatException e) { e.printStackTrace(); } @@ -2012,6 +2046,9 @@ public class TweetMainAction { //テーブルに表示可能なツイートの数 this.property.setProperty("numOfShowTweet", this.getTableElementMaxSize() + ""); + + //update notify + this.property.setProperty("updateNotify", this.isUpdateNotify + ""); // プロパティのリストを保存 property.store(new FileOutputStream("./" + PROPERTIES_DIRECTORY + "/" @@ -2163,6 +2200,20 @@ public class TweetMainAction { public void setNotifyDirectMessage(boolean notify) { this.isNotifyDirectMessage = notify; } + + /** + * 最新クライアント情報を通知するかどうか + */ + public boolean isUpdateNotify() { + return this.isUpdateNotify; + } + + /** + * 最新クライアント情報を通知するかどうか設定 + */ + public void setUpdateNotify(boolean notify) { + this.isUpdateNotify = notify; + } /** * diff --git a/src/twitter/gui/form/AboutDialog.form b/src/twitter/gui/form/AboutDialog.form index f53ad7c..182e7cc 100644 --- a/src/twitter/gui/form/AboutDialog.form +++ b/src/twitter/gui/form/AboutDialog.form @@ -58,7 +58,7 @@ - + diff --git a/src/twitter/gui/form/AboutDialog.java b/src/twitter/gui/form/AboutDialog.java index 22de6a8..b207348 100644 --- a/src/twitter/gui/form/AboutDialog.java +++ b/src/twitter/gui/form/AboutDialog.java @@ -12,6 +12,7 @@ package twitter.gui.form; import java.awt.Desktop; import java.net.URL; +import twitter.manage.ClientVersionManager; /** * @@ -26,6 +27,8 @@ public class AboutDialog extends javax.swing.JDialog { //デフォルトボタン this.getRootPane().setDefaultButton(jButton1); + //version情報 + this.jLabel1.setText("Nishio Tweet Manager version " + ClientVersionManager.getInstance().getCurrentversion()); } /** This method is called from within the constructor to @@ -46,7 +49,7 @@ public class AboutDialog extends javax.swing.JDialog { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("About Nishio Tweet Manager"); - jLabel1.setText("Nishio Tweet Manager version 0.6"); + jLabel1.setText("Version Information"); jButton1.setText("OK"); jButton1.addActionListener(new java.awt.event.ActionListener() { @@ -106,7 +109,8 @@ public class AboutDialog extends javax.swing.JDialog { private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed try { // クリック時 - URL url = new URL("http://densan-labs.net/software/ntm"); + String u = ClientVersionManager.getInstance().getNishiotweetmanagerurl(); + URL url = new URL(u); // デフォルトのブラウザを使ってリンク先を表示 Desktop dp = Desktop.getDesktop(); dp.browse(url.toURI()); diff --git a/src/twitter/gui/form/NishioTweetManager.java b/src/twitter/gui/form/NishioTweetManager.java index 6b27eac..bc8c1d1 100644 --- a/src/twitter/gui/form/NishioTweetManager.java +++ b/src/twitter/gui/form/NishioTweetManager.java @@ -40,7 +40,9 @@ import twitter.gui.action.TweetMainAction; import twitter.gui.component.TweetHashtagHyperlinkHandler; import twitter.gui.component.TweetHyperlinkHandler; import twitter.gui.component.TweetTextFieldPopupMenu; +import twitter.manage.ClientVersionManager; import twitter.manage.TweetManager; +import twitter.manage.VersionInfo; import twitter.task.TimerID; /** @@ -1497,6 +1499,18 @@ private void logSaveCheckItemActionPerformed(java.awt.event.ActionEvent evt) {// // フォーカスを一番初めのテーブルに移す this.mainAction.actionRequestFocusToTab(0); } + try { + ClientVersionManager version = ClientVersionManager.getInstance(); + VersionInfo latest = version.getLatestVersionInfo(); + if( latest != null && !latest.getVersion().equals( version.getCurrentversion() )) { + if( this.mainAction.isUpdateNotify() ) { + //最新クライアント情報を通知するかどうか + this.mainAction.actionShowUpdateDialog(); + } + } + }catch(Exception e) { + e.printStackTrace(); + } } /** diff --git a/src/twitter/gui/form/UpdateNotifyDialog.form b/src/twitter/gui/form/UpdateNotifyDialog.form index 36ed2e8..9c75b2f 100644 --- a/src/twitter/gui/form/UpdateNotifyDialog.form +++ b/src/twitter/gui/form/UpdateNotifyDialog.form @@ -124,16 +124,25 @@ + + + + + + + + + diff --git a/src/twitter/gui/form/UpdateNotifyDialog.java b/src/twitter/gui/form/UpdateNotifyDialog.java index addd7c3..67642ee 100644 --- a/src/twitter/gui/form/UpdateNotifyDialog.java +++ b/src/twitter/gui/form/UpdateNotifyDialog.java @@ -10,6 +10,15 @@ */ package twitter.gui.form; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URL; +import java.util.logging.Level; +import java.util.logging.Logger; +import twitter.gui.action.TweetMainAction; +import twitter.manage.ClientVersionManager; +import twitter.manage.VersionInfo; + /** * * @author nishio @@ -17,9 +26,27 @@ package twitter.gui.form; public class UpdateNotifyDialog extends javax.swing.JDialog { /** Creates new form UpdateNotifyDialog */ - public UpdateNotifyDialog(java.awt.Frame parent, boolean modal) { + public UpdateNotifyDialog(java.awt.Frame parent, boolean modal, TweetMainAction mainAction) { super(parent, modal); initComponents(); + this.mainAction = mainAction; + init(); + } + + /** + * 初期化 + */ + public void init() { + ClientVersionManager version = ClientVersionManager.getInstance(); + //現在のバージョン + this.jLabel4.setText(version.getCurrentversion()); + latest = version.getLatestVersionInfo(); + if( latest != null ) { + String newVersion = latest.getVersion(); + this.jLabel5.setText(newVersion); + String log = latest.getLog(); + jTextArea1.setText(log); + } } /** This method is called from within the constructor to @@ -60,10 +87,25 @@ public class UpdateNotifyDialog extends javax.swing.JDialog { jScrollPane1.setViewportView(jTextArea1); jButton1.setText("サイトへ移動"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); jButton2.setText("了解"); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); jCheckBox1.setText("次回からアップデート通知を行わない"); + jCheckBox1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckBox1ActionPerformed(evt); + } + }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); @@ -116,49 +158,38 @@ public class UpdateNotifyDialog extends javax.swing.JDialog { pack(); }// //GEN-END:initComponents - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ +private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + boolean update = jCheckBox1.isSelected(); + this.mainAction.setUpdateNotify(!update); try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(UpdateNotifyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(UpdateNotifyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(UpdateNotifyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(UpdateNotifyDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + this.mainAction.saveProperties(); + } catch (IOException ex) { + Logger.getLogger(UpdateNotifyDialog.class.getName()).log(Level.SEVERE, null, ex); } - // - - /* Create and display the dialog */ - java.awt.EventQueue.invokeLater(new Runnable() { - - public void run() { - UpdateNotifyDialog dialog = new UpdateNotifyDialog(new javax.swing.JFrame(), true); - dialog.addWindowListener(new java.awt.event.WindowAdapter() { - - @Override - public void windowClosing(java.awt.event.WindowEvent e) { - System.exit(0); - } - }); - dialog.setVisible(true); - } - }); + this.setVisible(false); +}//GEN-LAST:event_jButton2ActionPerformed + +private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed +// TODO add your handling code here: +}//GEN-LAST:event_jCheckBox1ActionPerformed + +private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + try { + // クリック時 + ClientVersionManager version = ClientVersionManager.getInstance(); + URL url = new URL( version.getNishiotweetmanagerurl() ); + // デフォルトのブラウザを使ってリンク先を表示 + Desktop dp = Desktop.getDesktop(); + dp.browse(url.toURI()); + } catch (Exception ex) { + ex.printStackTrace(); } +}//GEN-LAST:event_jButton1ActionPerformed + + private TweetMainAction mainAction = null; + //latestVersion + private VersionInfo latest = null; + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; diff --git a/src/twitter/manage/ClientVersionManager.java b/src/twitter/manage/ClientVersionManager.java index 290c3a6..cc6b9b4 100644 --- a/src/twitter/manage/ClientVersionManager.java +++ b/src/twitter/manage/ClientVersionManager.java @@ -94,12 +94,11 @@ public class ClientVersionManager { * クライアントの最新バージョンの情報を取得する * @return */ - public static VersionInfo getLatestVersionInfo() { - ClientVersionManager manager = ClientVersionManager.getInstance(); - String log = manager.getLatestInformation(); + public VersionInfo getLatestVersionInfo() { + String log = getLatestInformation(); VersionInfo info = null; try { - info = manager.XMLToVersionInfo(log); + info = XMLToVersionInfo(log); } catch (SAXParseException e) { e.printStackTrace(); }