• R/O
  • SSH
  • HTTPS

damstation-dl: Commit


Commit MetaInfo

Revision17 (tree)
Time2008-09-25 10:00:54
Authornomico

Log Message

・TodoDataクラスを追加
・フォームで選択したTODOによって、処理を変化させるように修正

Change Summary

Incremental Difference

--- DamStationDownloader/src/jp/sourceforge/damstation_dl/DownloadThread.java (revision 16)
+++ DamStationDownloader/src/jp/sourceforge/damstation_dl/DownloadThread.java (revision 17)
@@ -35,6 +35,7 @@
3535 private final SongDataList songData;
3636 private final ResultDataList resultData;
3737 private final ResultData2List resultData2;
38+ private final TodoData todoData;
3839
3940 /**
4041 * コンストラクタ
@@ -44,7 +45,7 @@
4445 * @param songData
4546 * @param resultData
4647 */
47- public DownloadThread(JButton button, JTextArea textArea, ConfigData configData, SongDataList songData, ResultDataList resultData, ResultData2List resultData2) {
48+ public DownloadThread(JButton button, JTextArea textArea, ConfigData configData, SongDataList songData, ResultDataList resultData, ResultData2List resultData2, TodoData todoData) {
4849 if ((button == null) || (textArea == null) || (configData == null)
4950 || (songData == null) || (resultData == null) || (resultData2 == null)) {
5051 throw new NullPointerException("DownloadThread.DownloadThread");
@@ -56,6 +57,7 @@
5657 this.songData = songData;
5758 this.resultData = resultData;
5859 this.resultData2 = resultData2;
60+ this.todoData = todoData;
5961
6062 button.setEnabled(false);
6163 }
@@ -91,7 +93,7 @@
9193 TextDownloader downloader = new TextDownloader(
9294 this.configData.getConnectTimeout(), this.configData.getReadTimeout(), this.configData.getProxy());
9395
94- // ログイン
96+ // ログインページに接続する
9597 this.publish("ログインページに接続します。\n");
9698 source = this.getLoginPageSource(downloader);
9799
@@ -101,6 +103,7 @@
101103 return null;
102104 }
103105
106+ // ログインに成功したかどうか調べる
104107 if (!this.isLogin(source)) {
105108 this.publish("エラー:ログインに失敗しました。\n");
106109 this.publish("エラー:処理を中断しました。\n");
@@ -114,44 +117,50 @@
114117 return null;
115118 }
116119
117- // 精密採点ページ取得
118- for (int page = 1; page <= 10; page++) {
119- this.publish("精密採点の" + page + "ページ目に接続します。\n");
120- source = this.getSeimitsuPageSource(downloader, page);
121-
122- // キャンセル判定
123- if (this.isCancelled()) {
124- this.publish("エラー:処理を中断しました。\n");
125- return null;
120+ if (this.todoData.isDownloadSeimitsu()) {
121+ for (int page = 1; page <= 10; page++) {
122+ // 精密採点ページに接続する
123+ this.publish("精密採点の" + page + "ページ目に接続します。\n");
124+ source = this.getSeimitsuPageSource(downloader, page);
125+
126+ // キャンセル判定
127+ if (this.isCancelled()) {
128+ this.publish("エラー:処理を中断しました。\n");
129+ return null;
130+ }
131+
132+ // 精密採点のソースを解析してデータに追加する
133+ this.updateResultData(source, page);
134+
135+ // キャンセル判定
136+ if (this.isCancelled()) {
137+ this.publish("エラー:処理を中断しました。\n");
138+ return null;
139+ }
126140 }
127-
128- this.updateResultData(source, page);
129-
130- // キャンセル判定
131- if (this.isCancelled()) {
132- this.publish("エラー:処理を中断しました。\n");
133- return null;
134- }
135141 }
136142
137- // 精密採点IIページ取得
138- for (int page = 1; page <= 10; page++) {
139- this.publish("精密採点IIの" + page + "ページ目に接続します。\n");
140- source = this.getSeimitsu2PageSource(downloader, page);
141-
142- // キャンセル判定
143- if (this.isCancelled()) {
144- this.publish("エラー:処理を中断しました。\n");
145- return null;
143+ if (this.todoData.isDownloadSeimitsu2()) {
144+ for (int page = 1; page <= 10; page++) {
145+ // 精密採点IIページに接続する
146+ this.publish("精密採点IIの" + page + "ページ目に接続します。\n");
147+ source = this.getSeimitsu2PageSource(downloader, page);
148+
149+ // キャンセル判定
150+ if (this.isCancelled()) {
151+ this.publish("エラー:処理を中断しました。\n");
152+ return null;
153+ }
154+
155+ // 精密採点IIのソースを解析して、データに追加する
156+ this.updateResultData2(source, page);
157+
158+ // キャンセル判定
159+ if (this.isCancelled()) {
160+ this.publish("エラー:処理を中断しました。\n");
161+ return null;
162+ }
146163 }
147-
148- this.updateResultData2(source, page);
149-
150- // キャンセル判定
151- if (this.isCancelled()) {
152- this.publish("エラー:処理を中断しました。\n");
153- return null;
154- }
155164 }
156165 } catch (Exception e) {
157166 this.publish("エラー:例外が発生しました。\n");
--- DamStationDownloader/src/jp/sourceforge/damstation_dl/TodoData.java (nonexistent)
+++ DamStationDownloader/src/jp/sourceforge/damstation_dl/TodoData.java (revision 17)
@@ -0,0 +1,30 @@
1+/*
2+ * To change this template, choose Tools | Templates
3+ * and open the template in the editor.
4+ */
5+
6+package jp.sourceforge.damstation_dl;
7+
8+/**
9+ *
10+ * @author d
11+ */
12+public class TodoData {
13+ private boolean downloadSeimitsu;
14+ private boolean downloadSeimitsu2;
15+
16+ public TodoData (boolean downloadSeimitsu, boolean downloadSeimitsu2) {
17+ this.downloadSeimitsu = downloadSeimitsu;
18+ this.downloadSeimitsu2 = downloadSeimitsu2;
19+ }
20+
21+ public boolean isDownloadSeimitsu() {
22+ return downloadSeimitsu;
23+ }
24+
25+ public boolean isDownloadSeimitsu2() {
26+ return downloadSeimitsu2;
27+ }
28+
29+
30+}
--- DamStationDownloader/src/jp/sourceforge/damstation_dl/MainWindow.java (revision 16)
+++ DamStationDownloader/src/jp/sourceforge/damstation_dl/MainWindow.java (revision 17)
@@ -40,6 +40,7 @@
4040 cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); // ALLじゃないと動かない…
4141 CookieHandler.setDefault(cookieManager);
4242
43+ // 各種データの初期化
4344 this.configData = new ConfigData(GlobalData.CONFIG_FILE_IN);
4445 this.songData = new SongDataList(GlobalData.SONG_FILE_IN);
4546 this.resultData = new ResultDataList(GlobalData.RESULT_FILE_IN);
@@ -95,8 +96,9 @@
9596 jTodoSeimitsu2CheckBox.setBackground(java.awt.Color.white);
9697 jTodoSeimitsu2CheckBox.setText("精密採点II");
9798
98- jTodoFixSongDataCheckBox.setBackground(java.awt.Color.yellow);
99+ jTodoFixSongDataCheckBox.setBackground(java.awt.Color.gray);
99100 jTodoFixSongDataCheckBox.setText("曲データ修正");
101+ jTodoFixSongDataCheckBox.setEnabled(false);
100102
101103 javax.swing.GroupLayout jTodoPanelLayout = new javax.swing.GroupLayout(jTodoPanel);
102104 jTodoPanel.setLayout(jTodoPanelLayout);
@@ -149,8 +151,6 @@
149151 }
150152 });
151153
152- jPasswordField.setEchoChar('\uff0a');
153-
154154 javax.swing.GroupLayout jConfigPanelLayout = new javax.swing.GroupLayout(jConfigPanel);
155155 jConfigPanel.setLayout(jConfigPanelLayout);
156156 jConfigPanelLayout.setHorizontalGroup(
@@ -220,16 +220,44 @@
220220 pack();
221221 }// </editor-fold>//GEN-END:initComponents
222222
223+ /**
224+ * 開始ボタンを押した時の動作
225+ * @param evt
226+ */
223227 private void jStartButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jStartButtonActionPerformed
228+ // SwingWorkerが実行中でない時は処理を開始させる
224229 if((this.thread == null) || this.thread.isDone()) {
230+ // カード番号とパスワード取得
225231 this.getFieldValue();
226- this.thread = new DownloadThread(this.jStartButton, this.jTextArea, this.configData, this.songData, this.resultData, this.resultData2);
232+
233+ // TODOの状態を取得
234+ TodoData todoData = new TodoData(
235+ this.jTodoSeimitsuCheckBox.isSelected(),
236+ this.jTodoSeimitsu2CheckBox.isSelected()
237+ );
238+
239+ // SwingWorker動作開始
240+ this.thread = new DownloadThread(
241+ this.jStartButton,
242+ this.jTextArea,
243+ this.configData,
244+ this.songData,
245+ this.resultData,
246+ this.resultData2,
247+ todoData
248+ );
227249 this.thread.execute();
228250 }
229251 }//GEN-LAST:event_jStartButtonActionPerformed
230252
253+ /**
254+ * 中止ボタンを押した時の動作
255+ * @param evt
256+ */
231257 private void jStopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jStopButtonActionPerformed
258+ // SwingWorkerが実行中の時は中止させる
232259 if((this.thread != null) && !this.thread.isDone()) {
260+ // 中止
233261 this.thread.cancel(true);
234262 }
235263 }//GEN-LAST:event_jStopButtonActionPerformed
@@ -320,11 +348,17 @@
320348 });
321349 }
322350
351+ /**
352+ * カード番号とパスワードをフォームにセットする
353+ */
323354 private void setFieldValue() {
324355 this.jCardNumberField.setText(this.configData.getCardNumber());
325356 this.jPasswordField.setText(PasswordUtility.decode(this.configData.getPassword()));
326357 }
327358
359+ /**
360+ * カード番号とパスワードをフォームから取得する
361+ */
328362 private void getFieldValue() {
329363 this.configData.setCardNumber(this.jCardNumberField.getText());
330364 this.configData.setPassword(PasswordUtility.encode(new String(this.jPasswordField.getPassword())));
Show on old repository browser