import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
-public enum Properties implements Config {
+public enum Properties {
INSTANCE;
private final XMLConfiguration config;
/** 投稿者コメントダウンロードディレクトリ */
private String p_ownercomment_directory;
- @Override
public boolean isOwnerCommentDownload() {
return Boolean.valueOf(p_ownercomment_download);
}
p_ownercomment_download = Boolean.toString(download);
}
- @Override
public boolean isCommentDownload() {
return Boolean.valueOf(p_comment_download);
}
p_comment_download = Boolean.toString(download);
}
- @Override
- public String getMovieDirectory() {
- return p_movie_directory;
+ public File getMovieDirectory() {
+ // TODO return new File(p_movie_directory);
+ return new File("out/movie");
+ }
+
+ public File getCommentDirectory() {
+ // TODO
+ return new File("out/comment");
}
public void setMovieDirectory(String dir) {
this.p_movie_directory = dir;
}
- @Override
public boolean isMovieDownload() {
return Boolean.valueOf(p_movie_download);
}
this.p_movie_download = Boolean.toString(download);
}
- @Override
public String getDbLocation() {
return p_nicobrowser_dblocation;
}
this.p_nicobrowser_dblocation = p_nicobrowser_dblocation;
}
- @Override
public boolean isDbUse() {
return Boolean.valueOf(p_nicobrowser_use);
}
this.p_nicobrowser_use = Boolean.toString(use);
}
- @Override
public String getNicoVideoId() {
return p_nicovideo_id;
}
this.p_nicovideo_id = id;
}
- @Override
public String getNicoVideoPassword() {
return p_nicovideo_password;
}
this.p_nicovideo_password = password;
}
- @Override
public String getProxyHost() {
return p_proxy_host;
}
this.p_proxy_host = host;
}
- @Override
public int getP_proxy_port() {
return Integer.parseInt(p_proxy_port);
}
this.p_proxy_port = Integer.toString(port);
}
- @Override
public boolean isProxyUse() {
return Boolean.valueOf(p_proxy_use);
}
import java.awt.datatransfer.Transferable;
import java.awt.event.ItemEvent;
import java.io.File;
+import java.io.FilenameFilter;
import java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
idLabel.setText("ID");
+ idField.addFocusListener(new java.awt.event.FocusAdapter() {
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ idFieldFocusLost(evt);
+ }
+ });
+
movieLabel.setText("動画");
useMovieLocalCheckBox.setText("local");
pack();
}// </editor-fold>//GEN-END:initComponents
+ private File searchFileMatchId(final File dir, final String id) throws UnsupportedOperationException {
+ final File[] lists = dir.listFiles(new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.contains(id);
+ }
+ });
+
+ if (lists.length == 1) {
+ return lists[0];
+ } else if (lists.length > 1) {
+ throw new UnsupportedOperationException();
+ } else {
+ return null;
+ }
+ }
+
private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
movieFileSelectButton.setEnabled(useLocal);
outputFileSelectButton.setEnabled(convert);
}//GEN-LAST:event_outputConvertCheckBoxItemStateChanged
+private void idFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_idFieldFocusLost
+ final Properties p = Properties.INSTANCE;
+ final String id = idField.getText();
+ if (id.isEmpty()) {
+ return;
+ }
+
+ if (useMovieLocalCheckBox.isSelected() && movieFileField.getText().isEmpty()) {
+ final File dir = p.getMovieDirectory();
+ final File file = searchFileMatchId(dir, id);
+ if (file != null) {
+ movieFileField.setText(file.getPath());
+ }
+ }
+
+ if (useCommentLocalCheckBox.isSelected() && commentFileField.getText().isEmpty()) {
+ final File dir = p.getCommentDirectory();
+ final File file = searchFileMatchId(dir, id);
+ if (file != null) {
+ commentFileField.setText(file.getPath());
+ }
+ }
+
+}//GEN-LAST:event_idFieldFocusLost
+
/**
* @param args the command line arguments
*/