import java.io.FilenameFilter;
import java.util.Collection;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.TransferHandler;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
-import org.apache.commons.io.FilenameUtils;
-import yukihane.inqubus.conifg.Properties;
+import yukihane.inqubus.config.Properties;
import yukihane.inqubus.model.Target;
import yukihane.inqubus.model.TargetsTableModel;
public class MainFrame extends javax.swing.JFrame {
private static final long serialVersionUID = 1L;
+ private static final Logger logger = Logger.getLogger(MainFrame.class.getName());
private final TargetsTableModel targetModel = new TargetsTableModel();
/** Creates new form MainFrame */
outputLabel = new javax.swing.JLabel();
outputConvertCheckBox = new javax.swing.JCheckBox();
outputFileField = new javax.swing.JTextField();
- outputFileSelectButton = new javax.swing.JButton();
applyButton = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
useCommentLocalCheckBox.setText("local");
useCommentLocalCheckBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
- useCommentLocalCheckBoxItemStateChanged(evt);
+ useMovieLocalCheckBoxItemStateChanged(evt);
}
});
}
});
- outputFileSelectButton.setText("...");
-
applyButton.setText("適用");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
- .addComponent(outputConvertCheckBox)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(outputFileField, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(outputFileSelectButton))
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addComponent(useCommentLocalCheckBox)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(commentFileField, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(commentFileSelectButton))
- .addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(useMovieLocalCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(movieFileField, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(movieFileSelectButton))
- .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
+ .addComponent(outputConvertCheckBox)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(outputFileField, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addComponent(useCommentLocalCheckBox)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(commentFileField, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(commentFileSelectButton))))
.addComponent(applyButton, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(outputLabel)
.addComponent(outputFileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(outputFileSelectButton)
.addComponent(outputConvertCheckBox))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(applyButton)
@Override
public boolean accept(File dir, String name) {
- return pattern.matcher(name).matches();
+ return pattern.matcher(name).find();
}
});
if (source == useMovieLocalCheckBox) {
btn = movieFileSelectButton;
field = movieFileField;
- dir = p.getMovieDirectory();
- } else{
+ dir = p.getVideoDir();
+ } else {
btn = commentFileSelectButton;
field = commentFileField;
- dir = p.getCommentDirectory();
+ dir = p.getCommentDir();
}
final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
text = "";
}
} else {
- text = p.getFileNamePattern();
+ text = p.getVideoFileNamePattern();
}
field.setText(text);
}//GEN-LAST:event_useMovieLocalCheckBoxItemStateChanged
-private void useCommentLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useCommentLocalCheckBoxItemStateChanged
- final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
- commentFileSelectButton.setEnabled(useLocal);
-
- final Properties p = Properties.INSTANCE;
- String text;
- if (useLocal) {
- final File f = searchFileMatchId(p.getCommentDirectory(), idField.getText());
- if (f != null) {
- text = f.getPath();
- } else {
- text = "";
- }
- } else {
- text = p.getFileNamePattern();
- }
- commentFileField.setText(text);
-}//GEN-LAST:event_useCommentLocalCheckBoxItemStateChanged
-
private void outputConvertCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputConvertCheckBoxItemStateChanged
final boolean convert = (evt.getStateChange() == ItemEvent.SELECTED);
outputFileField.setEnabled(convert);
- outputFileSelectButton.setEnabled(convert);
}//GEN-LAST:event_outputConvertCheckBoxItemStateChanged
private void idFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_idFieldFocusLost
}
if (useMovieLocalCheckBox.isSelected() && movieFileField.getText().isEmpty()) {
- final File dir = p.getMovieDirectory();
+ final File dir = p.getVideoDir();
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 dir = p.getCommentDir();
final File file = searchFileMatchId(dir, id);
if (file != null) {
commentFileField.setText(file.getPath());
private javax.swing.JLabel movieLabel;
private javax.swing.JCheckBox outputConvertCheckBox;
private javax.swing.JTextField outputFileField;
- private javax.swing.JButton outputFileSelectButton;
private javax.swing.JLabel outputLabel;
private javax.swing.JCheckBox useCommentLocalCheckBox;
private javax.swing.JCheckBox useMovieLocalCheckBox;
final Properties p = Properties.INSTANCE;
- final boolean movieLocal = p.getUseMovieFileLocal();
+ final boolean movieLocal = p.getVideoUseLocal();
useMovieLocalCheckBox.setSelected(movieLocal);
movieFileSelectButton.setEnabled(movieLocal);
+ if (!movieLocal) {
+ movieFileField.setText(p.getVideoFileNamePattern());
+ }
- final boolean commentLocal = p.getCommentFileLocal();
+ final boolean commentLocal = p.getCommentUseLocal();
useCommentLocalCheckBox.setSelected(commentLocal);
commentFileSelectButton.setEnabled(commentLocal);
+ if (!commentLocal) {
+ commentFileField.setText(p.getCommentFileNamePattern());
+ }
- final boolean convert = p.getOutputConvert();
+ final boolean convert = p.getOutputEnable();
outputConvertCheckBox.setSelected(convert);
outputFileField.setEnabled(convert);
- outputFileField.setText(p.getOutputFile().toString());
- outputFileSelectButton.setEnabled(convert);
+ outputFileField.setText(p.getOutputFileNamePattern());
}
try {
Transferable transferable = support.getTransferable();
if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
- List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
+ @SuppressWarnings("unchecked")
+ final List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
Collection<Target> targets = Target.from(data);
targetModel.addTarget(targets);
} else if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
}
return false;
} catch (Exception e) {
- e.printStackTrace();
+ logger.log(Level.SEVERE, null, e);
return false;
}
}
}
private class TableTransferHandler extends DownloadListTransferHandler {
+ private static final long serialVersionUID = 1L;
@Override
public boolean canImport(TransferHandler.TransferSupport support) {