import twitter.gui.form.UserSearchDialog;
import twitter.log.TwitterLogManager;
import twitter.manage.TweetConfiguration;
+import twitter.manage.TweetFavNotifyManager;
import twitter.manage.TweetManager;
import twitter.manage.URLBitlyConverter;
import twitter.task.ExistTimerIDException;
private boolean isUsingStreaming = true;
//現在streaming apiが開始されているかどうか
private boolean isCurrentUsingStreaming = false;
+ //favられた時に通知をするかどうか
+ private boolean favNotify = true;
// Tweetの詳細情報を表示する部分
private JLabel userImageLabel = null;
mainFrame.setSize(this.mainFrameWidth, this.mainFrameHeight);
mainFrame.setPreferredSize(new Dimension(this.mainFrameWidth,
this.mainFrameHeight));
+ //update通知の更新
+ updateNotifyInformation();
//streaming apiの状態listener設定
this.tweetManager.getStreamManager().addCollectionLifeCycleListener(this);
e.printStackTrace();
}
}
+
+ /**
+ * notify通知ウィンドウ情報の更新
+ */
+ public void updateNotifyInformation() {
+ //streaming api利用時、fav通知
+ if( this.favNotify ) {
+ this.tweetManager.getStreamManager().setFavNotifyManager(new TweetFavNotifyManager(this.trayIcon));
+ }
+ }
/**
* 新しいタブを追加
if( ius == null ) {
ius = this.isUsingStreaming + "";
}
+
+ String fav = this.property.getProperty("isFavNotify");
+ if( fav == null ) {
+ fav = this.favNotify + "";
+ }
try {
this.newTableColor = new Color(Integer.parseInt(ntrgb));
//using streaming
this.isUsingStreaming = Boolean.parseBoolean(ius);
+
+ //fav
+ this.favNotify = Boolean.parseBoolean(fav);
} catch (NumberFormatException e) {
e.printStackTrace();
}
//streaming
this.property.setProperty("isUsingStreaming", this.isUsingStreaming + "");
+
+ //fav通知
+ this.property.setProperty("isFavNotify", this.favNotify + "");
// プロパティのリストを保存
property.store(new FileOutputStream("./" + PROPERTIES_DIRECTORY + "/"
public boolean isStartedStreamingAPI() {
return this.isCurrentUsingStreaming;
}
+
+ /**
+ * Fav通知を行うかどうか
+ * @return
+ */
+ public boolean isFavNotify() {
+ return this.favNotify;
+ }
+
+ /**
+ * fav通知を行うかどうか設定
+ */
+ public void setFavNotify(boolean notify) {
+ this.favNotify = notify;
+ }
}
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
+ <Component id="jCheckBox3" alignment="0" pref="431" max="32767" attributes="0"/>
<Component id="jCheckBox1" alignment="0" pref="431" max="32767" attributes="0"/>
<Component id="jCheckBox2" alignment="0" pref="431" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jSpinner6" alignment="0" pref="290" max="32767" attributes="0"/>
</Group>
</Group>
- <Component id="jCheckBox3" alignment="0" pref="431" max="32767" attributes="0"/>
+ <Component id="jCheckBox4" alignment="0" pref="431" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jCheckBox2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Component id="jCheckBox4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jCheckBox3" min="-2" max="-2" attributes="0"/>
- <EmptySpace min="-2" pref="194" max="-2" attributes="0"/>
+ <EmptySpace min="-2" pref="171" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<Property name="text" type="java.lang.String" value="クライアントの最新情報を通知する"/>
</Properties>
</Component>
+ <Component class="javax.swing.JCheckBox" name="jCheckBox4">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="自分の発言がお気に入りに登録されたら通知する(ストリーミングAPI利用時のみ)"/>
+ </Properties>
+ </Component>
</SubComponents>
</Container>
</SubComponents>
* 読み込んだ情報を反映
*/
public void applyLoadInformation() {
- try {
- // 画面が見えたときに情報更新
- jSpinner1.setValue( mainAction.getGetTimelinePeriod() );
- jSpinner2.setValue( mainAction.getGetMentionPeriod() );
- jSpinner3.setValue( mainAction.getGetDirectMessagePeriod() );
- jSpinner4.setValue( mainAction.getGetSendDirectMessagePeriod() );
-
- jLabel10.setBackground(mainAction.getNewTableColor());
-
- // font関係
- if (mainAction.getTlFontName() != null) {
- jComboBox1.setSelectedItem(mainAction.getTlFontName());
- }
- if (mainAction.getDetailFontName() != null) {
- jComboBox2.setSelectedItem(mainAction.getDetailFontName());
- }
- jComboBox3.setSelectedItem(mainAction.getTlFontSize() + "");
- jComboBox4.setSelectedItem(mainAction.getDetailFontSize() + "");
-
- // 表示
- jSpinner5.setValue(mainAction.getTableElementHeight());
- jCheckBox1.setSelected( mainAction.getNotifyMention() );
- jCheckBox2.setSelected( mainAction.getNotifyDirectMessage() );
- jCheckBox3.setSelected( mainAction.isUpdateNotify() );
-
- //テーブルに表示するツイート数
- jSpinner6.setValue(mainAction.getTableElementMaxSize());
-
- } catch (Exception e) {
- e.printStackTrace();
- }
+ try {
+ // 画面が見えたときに情報更新
+ jSpinner1.setValue( mainAction.getGetTimelinePeriod() );
+ jSpinner2.setValue( mainAction.getGetMentionPeriod() );
+ jSpinner3.setValue( mainAction.getGetDirectMessagePeriod() );
+ jSpinner4.setValue( mainAction.getGetSendDirectMessagePeriod() );
+
+ jLabel10.setBackground(mainAction.getNewTableColor());
+
+ // font関係
+ if (mainAction.getTlFontName() != null) {
+ jComboBox1.setSelectedItem(mainAction.getTlFontName());
+ }
+ if (mainAction.getDetailFontName() != null) {
+ jComboBox2.setSelectedItem(mainAction.getDetailFontName());
+ }
+ jComboBox3.setSelectedItem(mainAction.getTlFontSize() + "");
+ jComboBox4.setSelectedItem(mainAction.getDetailFontSize() + "");
+
+ // 表示
+ jSpinner5.setValue(mainAction.getTableElementHeight());
+ jCheckBox1.setSelected( mainAction.getNotifyMention() );
+ jCheckBox2.setSelected( mainAction.getNotifyDirectMessage() );
+ jCheckBox3.setSelected( mainAction.isUpdateNotify() );
+ jCheckBox4.setSelected( mainAction.isFavNotify() );
+
+ //テーブルに表示するツイート数
+ jSpinner6.setValue(mainAction.getTableElementMaxSize());
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
/**
jSpinner6 = new javax.swing.JSpinner();
jLabel12 = new javax.swing.JLabel();
jCheckBox3 = new javax.swing.JCheckBox();
+ jCheckBox4 = new javax.swing.JCheckBox();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jCheckBox3.setText("クライアントの最新情報を通知する");
+ jCheckBox4.setText("自分の発言がお気に入りに登録されたら通知する(ストリーミングAPI利用時のみ)");
+
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jCheckBox3, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
.addComponent(jCheckBox1, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
.addComponent(jCheckBox2, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSpinner5, javax.swing.GroupLayout.DEFAULT_SIZE, 290, Short.MAX_VALUE)
.addComponent(jSpinner6, javax.swing.GroupLayout.DEFAULT_SIZE, 290, Short.MAX_VALUE)))
- .addComponent(jCheckBox3, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE))
+ .addComponent(jCheckBox4, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
.addComponent(jCheckBox1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(jCheckBox4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jCheckBox3)
- .addGap(194, 194, 194))
+ .addGap(171, 171, 171))
);
jTabbedPane1.addTab("表示", jPanel4);
mainAction.setNotifyMention( jCheckBox1.isSelected() );
mainAction.setNotifyDirectMessage( jCheckBox2.isSelected() );
mainAction.setUpdateNotify( jCheckBox3.isSelected() );
+ //fav通知ウィンドウ変更
+ mainAction.setFavNotify( jCheckBox4.isSelected());
+ mainAction.updateNotifyInformation();
//ツイート表示数
mainAction.setTableElementMaxSize(Integer.parseInt( jSpinner6.getValue().toString() ));
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JCheckBox jCheckBox3;
+ private javax.swing.JCheckBox jCheckBox4;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JComboBox jComboBox3;
--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package twitter.manage;
+
+import java.awt.TrayIcon;
+import java.util.List;
+import twitter4j.Status;
+import twitter4j.User;
+
+/**
+ *
+ * @author nishio
+ */
+public class TweetFavNotifyManager{
+
+ //トレイアイコン
+ protected TrayIcon trayIcon = null;
+ //タイトル
+ protected String title = "お気に入り登録情報";
+
+ public TweetFavNotifyManager(TrayIcon trayIcon) {
+ this.trayIcon = trayIcon;
+ }
+
+ public TweetFavNotifyManager(TrayIcon trayIcon, String title) {
+ this.trayIcon = trayIcon;
+ this.title = title;
+ }
+
+ /**
+ * ツイート情報を通知バーに表示
+ * @param status
+ */
+ public void showNotifyMessage(User source, User target, Status favoritedStatus) {
+ if( trayIcon != null ) {
+ String message = favoritedStatus.getText();
+ if( message.length() > 80) {
+ message = message.substring(0, 80);
+ message = message + "...";
+ }
+ this.trayIcon.displayMessage(title, source.getScreenName() + "さんが、あなたの発言:\n "
+ + message + " をお気に入りに登録しました",TrayIcon.MessageType.INFO);
+ }
+ }
+}
//direct message監視\r
private TweetStreamingListener directMessageListener = null;\r
//mention通知\r
- private TweetNotifyManager mentionNotifyManager = null;\r
- //directmessage通知\r
- private TweetNotifyManager directMessageNotifyManager = null;\r
+ private TweetNotifyManager mentionNotifyManager = null;\r
+ //directmessage通知\r
+ private TweetNotifyManager directMessageNotifyManager = null;\r
+ //fav通知を行うかどうか\r
+ private TweetFavNotifyManager favNotifyManager = null;\r
//ログインユーザ名\r
private String loginUsername = null;\r
//tweet manager\r
public void setMentionNotifyManager(TweetNotifyManager notifyManager) {\r
this.mentionNotifyManager = notifyManager;\r
}\r
+ \r
+ /**\r
+ * お気に入り登録通知\r
+ */\r
+ public void setFavNotifyManager(TweetFavNotifyManager notifyManager) {\r
+ this.favNotifyManager = notifyManager;\r
+ }\r
\r
/**\r
* direct message通知バー\r
}\r
}\r
\r
+ /**\r
+ * お気に入り登録通知\r
+ * @param source\r
+ * @param target\r
+ * @param favoritedStatus \r
+ */\r
@Override\r
public void onFavorite(User source, User target, Status favoritedStatus) {\r
- /*System.out.println(source.getScreenName() + " favorited "\r
- + target.getScreenName() + "'s Status. StatusId: "\r
- + favoritedStatus.getId() );\r
- System.out.println("FAV MESSAGE:" + favoritedStatus.getText());*/\r
+ if( favNotifyManager != null ) {\r
+ favNotifyManager.showNotifyMessage(source, target, favoritedStatus);\r
+ }\r
}\r
\r
@Override\r
public void stopDirectMessageListener() {\r
this.userStream.setDirectMessageListener(null);\r
}\r
+ \r
+ /**\r
+ * Favられた時に通知\r
+ */\r
+ public void setFavNotifyManager(TweetFavNotifyManager notify) {\r
+ this.userStream.setFavNotifyManager(notify);\r
+ }\r
+ \r
+ /**\r
+ * Favられた時の通知をやめる\r
+ */\r
+ public void resetFavNotifyManager() {\r
+ this.userStream.setFavNotifyManager(null);\r
+ }\r
\r
/**\r
* Mentionを監視するリスナー\r