*/
package yukihane.inqubus.gui;
+import java.awt.Image;
import java.awt.ItemSelectable;
+import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
+import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FilenameFilter;
+import java.net.URL;
+import java.util.ArrayList;
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.BorderFactory;
+import javax.swing.DropMode;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.TransferHandler;
-import javax.swing.UIManager;
-import javax.swing.UIManager.LookAndFeelInfo;
-import yukihane.inqubus.config.Properties;
+import javax.swing.WindowConstants;
+import org.apache.commons.lang.StringUtils;
+import saccubus.MainFrame_AboutBox;
+import saccubus.worker.Download;
+import saccubus.worker.profile.CommentProfile;
+import saccubus.worker.profile.DownloadProfile;
+import saccubus.worker.profile.GeneralProfile;
+import saccubus.worker.profile.LoginProfile;
+import saccubus.worker.profile.ProxyProfile;
+import saccubus.worker.profile.VideoProfile;
+import yukihane.Util;
+import yukihane.inqubus.Config;
import yukihane.inqubus.model.Target;
import yukihane.inqubus.model.TargetsTableModel;
*
* @author yuki
*/
-public class MainFrame extends javax.swing.JFrame {
+public class MainFrame extends JFrame {
private static final long serialVersionUID = 1L;
private static final Logger logger = Logger.getLogger(MainFrame.class.getName());
/** Creates new form MainFrame */
public MainFrame() {
- initComponents();
- initInputPanel();
- jPanel1.setTransferHandler(new DownloadListTransferHandler());
- jTable1.setTransferHandler(new TableTransferHandler());
- }
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents() {
-
- jPanel1 = new javax.swing.JPanel();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTable1 = new javax.swing.JTable();
- jPanel2 = new javax.swing.JPanel();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jButton4 = new javax.swing.JButton();
- jPanel3 = new javax.swing.JPanel();
- idLabel = new javax.swing.JLabel();
- idField = new javax.swing.JTextField();
- movieLabel = new javax.swing.JLabel();
- useMovieLocalCheckBox = new javax.swing.JCheckBox();
- movieFileField = new javax.swing.JTextField();
- movieFileSelectButton = new javax.swing.JButton();
- commentLabel = new javax.swing.JLabel();
- useCommentLocalCheckBox = new javax.swing.JCheckBox();
- commentFileField = new javax.swing.JTextField();
- commentFileSelectButton = new javax.swing.JButton();
- outputLabel = new javax.swing.JLabel();
- outputConvertCheckBox = new javax.swing.JCheckBox();
- outputFileField = new javax.swing.JTextField();
- applyButton = new javax.swing.JButton();
- jMenuBar1 = new javax.swing.JMenuBar();
- jMenu1 = new javax.swing.JMenu();
- jMenu2 = new javax.swing.JMenu();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
-
- jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-
- jTable1.setModel(targetModel);
- jTable1.setDropMode(javax.swing.DropMode.INSERT_ROWS);
- jScrollPane1.setViewportView(jTable1);
-
- jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-
- jButton2.setText("開始");
-
- jButton3.setText("停止");
-
- jButton4.setText("選択解除");
-
- javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
- jPanel2.setLayout(jPanel2Layout);
- jPanel2Layout.setHorizontalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
+ final URL url = MainFrame_AboutBox.class.getResource("icon.png");
+ final Image icon1 = Toolkit.getDefaultToolkit().createImage(url);
+ final URL url32 = MainFrame_AboutBox.class.getResource("icon32.png");
+ final Image icon2 = Toolkit.getDefaultToolkit().createImage(url32);
+ final List<Image> images = new ArrayList<Image>(2);
+ images.add(icon1);
+ images.add(icon2);
+ setIconImages(images);
+
+ final JPanel pnlMain = new JPanel();
+ final JScrollPane scrDisplay = new JScrollPane();
+ tblDisplay = new JTable();
+ final JPanel pnlButton = new JPanel();
+ btnStart = new JButton();
+ btnStop = new JButton();
+ btnDeselect = new JButton();
+ final JPanel pnlInputMain = new JPanel();
+ final JLabel lblId = new JLabel();
+ fldId = new JTextField();
+ final JLabel lblVideo = new JLabel();
+ cbVideoLocal = new JCheckBox();
+ fldVideo = new JTextField();
+ btnVideo = new JButton();
+ final JLabel lblComment = new JLabel();
+ cbCommentLocal = new JCheckBox();
+ fldComment = new JTextField();
+ btnComment = new JButton();
+ final JLabel lblOutput = new JLabel();
+ cbOutputEnable = new JCheckBox();
+ fldOutput = new JTextField();
+
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ btnApply.addActionListener(new ApplyActionListener());
+
+ pnlMain.setBorder(BorderFactory.createEtchedBorder());
+
+ tblDisplay.setModel(targetModel);
+ tblDisplay.setDropMode(DropMode.INSERT_ROWS);
+ scrDisplay.setViewportView(tblDisplay);
+
+ pnlButton.setBorder(BorderFactory.createEtchedBorder());
+
+ btnStart.setText("開始");
+
+ btnStop.setText("停止");
+
+ btnDeselect.setText("選択解除");
+
+ GroupLayout gl_pnlButton = new GroupLayout(pnlButton);
+ pnlButton.setLayout(gl_pnlButton);
+ gl_pnlButton.setHorizontalGroup(
+ gl_pnlButton.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlButton.createSequentialGroup()
.addContainerGap()
- .addComponent(jButton2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
- .addComponent(jButton4)
+ .addComponent(btnStart)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(btnStop)
+ .addPreferredGap(ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
+ .addComponent(btnDeselect)
.addContainerGap())
);
- jPanel2Layout.setVerticalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
+ gl_pnlButton.setVerticalGroup(
+ gl_pnlButton.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlButton.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton2)
- .addComponent(jButton3)
- .addComponent(jButton4))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(gl_pnlButton.createParallelGroup(Alignment.BASELINE)
+ .addComponent(btnStart)
+ .addComponent(btnStop)
+ .addComponent(btnDeselect))
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
- jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+ pnlInputMain.setBorder(BorderFactory.createEtchedBorder());
- idLabel.setText("ID");
+ lblId.setText("ID");
+
+ fldId.addFocusListener(new java.awt.event.FocusAdapter() {
- idField.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
idFieldFocusLost(evt);
}
});
- movieLabel.setText("動画");
+ lblVideo.setText("動画");
+
+ cbVideoLocal.setText("local");
+ cbVideoLocal.addItemListener(new java.awt.event.ItemListener() {
- useMovieLocalCheckBox.setText("local");
- useMovieLocalCheckBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
useMovieLocalCheckBoxItemStateChanged(evt);
}
});
- movieFileSelectButton.setText("...");
+ btnVideo.setText("...");
+
+ lblComment.setText("コメント");
- commentLabel.setText("コメント");
+ cbCommentLocal.setText("local");
+ cbCommentLocal.addItemListener(new java.awt.event.ItemListener() {
- useCommentLocalCheckBox.setText("local");
- useCommentLocalCheckBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
useMovieLocalCheckBoxItemStateChanged(evt);
}
});
- commentFileSelectButton.setText("...");
+ btnComment.setText("...");
- outputLabel.setText("出力");
+ lblOutput.setText("出力");
+
+ cbOutputEnable.setText("変換");
+ cbOutputEnable.addItemListener(new java.awt.event.ItemListener() {
- outputConvertCheckBox.setText("変換");
- outputConvertCheckBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
outputConvertCheckBoxItemStateChanged(evt);
}
});
- applyButton.setText("適用");
- javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
- jPanel3.setLayout(jPanel3Layout);
- jPanel3Layout.setHorizontalGroup(
- jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
+ GroupLayout gl_pnlInputMain = new GroupLayout(pnlInputMain);
+ pnlInputMain.setLayout(gl_pnlInputMain);
+ gl_pnlInputMain.setHorizontalGroup(
+ gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlInputMain.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(commentLabel)
- .addComponent(movieLabel)
- .addComponent(idLabel)
- .addComponent(outputLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .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)
- .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))
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlInputMain.createSequentialGroup()
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addComponent(lblComment)
+ .addComponent(lblVideo)
+ .addComponent(lblId)
+ .addComponent(lblOutput))
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlInputMain.createSequentialGroup()
+ .addComponent(cbVideoLocal)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(fldVideo, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(btnVideo))
+ .addComponent(fldId, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
+ .addGroup(Alignment.TRAILING, gl_pnlInputMain.createSequentialGroup()
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.TRAILING)
+ .addGroup(Alignment.LEADING, gl_pnlInputMain.createSequentialGroup()
+ .addComponent(cbOutputEnable)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(fldOutput, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
+ .addGroup(gl_pnlInputMain.createSequentialGroup()
+ .addComponent(cbCommentLocal)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(fldComment, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)))
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(btnComment))))
+ .addComponent(btnApply, Alignment.TRAILING))
.addContainerGap())
);
- jPanel3Layout.setVerticalGroup(
- jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
+ gl_pnlInputMain.setVerticalGroup(
+ gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlInputMain.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(idLabel))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(movieLabel)
- .addComponent(movieFileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(movieFileSelectButton)
- .addComponent(useMovieLocalCheckBox))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(commentLabel)
- .addComponent(commentFileField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(commentFileSelectButton)
- .addComponent(useCommentLocalCheckBox))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .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(outputConvertCheckBox))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(applyButton)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+ .addComponent(fldId, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblId))
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+ .addComponent(lblVideo)
+ .addComponent(fldVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(btnVideo)
+ .addComponent(cbVideoLocal))
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+ .addComponent(lblComment)
+ .addComponent(fldComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(btnComment)
+ .addComponent(cbCommentLocal))
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+ .addComponent(lblOutput)
+ .addComponent(fldOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(cbOutputEnable))
+ .addPreferredGap(ComponentPlacement.UNRELATED)
+ .addComponent(btnApply)
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+ GroupLayout gl_pnlMain = new GroupLayout(pnlMain);
+ pnlMain.setLayout(gl_pnlMain);
+ gl_pnlMain.setHorizontalGroup(
+ gl_pnlMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
- .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(gl_pnlMain.createParallelGroup(Alignment.TRAILING)
+ .addComponent(pnlInputMain, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(scrDisplay, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
+ .addComponent(pnlButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+ gl_pnlMain.setVerticalGroup(
+ gl_pnlMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
.addContainerGap()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(scrDisplay, GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(pnlButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(pnlInputMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(24, 24, 24))
);
- jMenu1.setText("File");
- jMenuBar1.add(jMenu1);
-
- jMenu2.setText("Edit");
- jMenuBar1.add(jMenu2);
- setJMenuBar(jMenuBar1);
+ JMenuBar menuBar = initMenuBar();
+ setJMenuBar(menuBar);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ layout.createParallelGroup(Alignment.LEADING)
+ .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ layout.createParallelGroup(Alignment.LEADING)
+ .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
+ initInputPanel();
+ pnlMain.setTransferHandler(new DownloadListTransferHandler());
+ tblDisplay.setTransferHandler(new TableTransferHandler());
+ }
+
+ private class ApplyActionListener implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ final DownloadProfile prof = new InqubusDownloadProfile();
+ final String id = Util.getVideoId(fldId.getText());
+
+ new Download(prof, id).execute();
+ }
+ }
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
}// </editor-fold>//GEN-END:initComponents
private File searchFileMatchId(final File dir, final String id) throws UnsupportedOperationException {
}
}
-private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
- final Properties p = Properties.INSTANCE;
-
- final ItemSelectable source = evt.getItemSelectable();
-
- JButton btn;
- JTextField field;
- File dir;
- if (source == useMovieLocalCheckBox) {
- btn = movieFileSelectButton;
- field = movieFileField;
- dir = p.getMovieDirectory();
- } else {
- btn = commentFileSelectButton;
- field = commentFileField;
- dir = p.getCommentDirectory();
- }
+ private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
+ final Config p = Config.INSTANCE;
- final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
- btn.setEnabled(useLocal);
+ final ItemSelectable source = evt.getItemSelectable();
- String text;
- if (useLocal) {
- final File f = searchFileMatchId(dir, idField.getText());
- if (f != null) {
- text = f.getPath();
+ JButton btn;
+ JTextField field;
+ File dir;
+ if (source == cbVideoLocal) {
+ btn = btnVideo;
+ field = fldVideo;
+ dir = new File(p.getVideoDir());
} else {
- text = "";
+ btn = btnComment;
+ field = fldComment;
+ dir = new File(p.getCommentDir());
}
- } else {
- text = p.getFileNamePattern();
- }
- field.setText(text);
-}//GEN-LAST:event_useMovieLocalCheckBoxItemStateChanged
-
-private void outputConvertCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputConvertCheckBoxItemStateChanged
- final boolean convert = (evt.getStateChange() == ItemEvent.SELECTED);
- outputFileField.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());
- }
- }
+ final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
+ btn.setEnabled(useLocal);
- if (useCommentLocalCheckBox.isSelected() && commentFileField.getText().isEmpty()) {
- final File dir = p.getCommentDirectory();
- final File file = searchFileMatchId(dir, id);
- if (file != null) {
- commentFileField.setText(file.getPath());
+ String text;
+ if (useLocal) {
+ final File f = searchFileMatchId(dir, fldId.getText());
+ if (f != null) {
+ text = f.getPath();
+ } else {
+ text = "";
+ }
+ } else {
+ text = p.getVideoFileNamePattern();
}
- }
+ field.setText(text);
+ }//GEN-LAST:event_useMovieLocalCheckBoxItemStateChanged
-}//GEN-LAST:event_idFieldFocusLost
+ private void outputConvertCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputConvertCheckBoxItemStateChanged
+ final boolean convert = (evt.getStateChange() == ItemEvent.SELECTED);
+ fldOutput.setEnabled(convert);
+ }//GEN-LAST:event_outputConvertCheckBoxItemStateChanged
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- try {
- for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (Exception e) {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception ex) {
+ private void idFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_idFieldFocusLost
+ final Config p = Config.INSTANCE;
+ final String id = fldId.getText();
+ if (id.isEmpty()) {
+ return;
+ }
+
+ if (cbVideoLocal.isSelected() && fldVideo.getText().isEmpty()) {
+ final File dir = new File(p.getVideoDir());
+ final File file = searchFileMatchId(dir, id);
+ if (file != null) {
+ fldVideo.setText(file.getPath());
}
}
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new MainFrame().setVisible(true);
+ if (cbCommentLocal.isSelected() && fldComment.getText().isEmpty()) {
+ final File dir = new File(p.getCommentDir());
+ final File file = searchFileMatchId(dir, id);
+ if (file != null) {
+ fldComment.setText(file.getPath());
}
- });
- }
+ }
+
+ }//GEN-LAST:event_idFieldFocusLost
// Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton applyButton;
- private javax.swing.JTextField commentFileField;
- private javax.swing.JButton commentFileSelectButton;
- private javax.swing.JLabel commentLabel;
- private javax.swing.JTextField idField;
- private javax.swing.JLabel idLabel;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JMenu jMenu1;
- private javax.swing.JMenu jMenu2;
- private javax.swing.JMenuBar jMenuBar1;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JPanel jPanel3;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTable jTable1;
- private javax.swing.JTextField movieFileField;
- private javax.swing.JButton movieFileSelectButton;
- private javax.swing.JLabel movieLabel;
- private javax.swing.JCheckBox outputConvertCheckBox;
- private javax.swing.JTextField outputFileField;
- private javax.swing.JLabel outputLabel;
- private javax.swing.JCheckBox useCommentLocalCheckBox;
- private javax.swing.JCheckBox useMovieLocalCheckBox;
+ private final JTable tblDisplay;
+ // ボタン領域
+ private final JButton btnStart;
+ private final JButton btnStop;
+ private final JButton btnDeselect;
+ //入力領域 - 標準
+ private final JTextField fldId;
+ private final JCheckBox cbVideoLocal;
+ private final JTextField fldVideo;
+ private final JButton btnVideo;
+ private final JCheckBox cbCommentLocal;
+ private final JTextField fldComment;
+ private final JButton btnComment;
+ private final JCheckBox cbOutputEnable;
+ private final JTextField fldOutput;
+ // 適用
+ private final JButton btnApply = new JButton("適用");
// End of variables declaration//GEN-END:variables
private void initInputPanel() {
- idField.setText("");
+ fldId.setText("");
- final Properties p = Properties.INSTANCE;
+ final Config p = Config.INSTANCE;
- final boolean movieLocal = p.getUseMovieFileLocal();
- useMovieLocalCheckBox.setSelected(movieLocal);
- movieFileSelectButton.setEnabled(movieLocal);
+ final boolean movieLocal = p.getVideoUseLocal();
+ cbVideoLocal.setSelected(movieLocal);
+ btnVideo.setEnabled(movieLocal);
if (!movieLocal) {
- movieFileField.setText(p.getFileNamePattern());
+ fldVideo.setText(p.getVideoFileNamePattern());
}
- final boolean commentLocal = p.getCommentFileLocal();
- useCommentLocalCheckBox.setSelected(commentLocal);
- commentFileSelectButton.setEnabled(commentLocal);
+ final boolean commentLocal = p.getCommentUseLocal();
+ cbCommentLocal.setSelected(commentLocal);
+ btnComment.setEnabled(commentLocal);
if (!commentLocal) {
- commentFileField.setText(p.getFileNamePattern());
+ fldComment.setText(p.getCommentFileNamePattern());
}
- final boolean convert = p.getOutputConvert();
- outputConvertCheckBox.setSelected(convert);
- outputFileField.setEnabled(convert);
- outputFileField.setText(p.getFileNamePattern());
+ final boolean convert = p.getOutputEnable();
+ cbOutputEnable.setSelected(convert);
+ fldOutput.setEnabled(convert);
+ fldOutput.setText(p.getOutputFileNamePattern());
}
+ private JMenuBar initMenuBar() {
+ final JMenuBar menuBar = new JMenuBar();
+
+ final JMenu mnFile = new JMenu("ファイル(F)");
+ menuBar.add(mnFile);
+
+ final JMenuItem itExit = new JMenuItem("終了(X)", KeyEvent.VK_X);
+ itExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
+ itExit.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ });
+ mnFile.add(itExit);
+
+ final JMenu mnTool = new JMenu("ツール(T)");
+ menuBar.add(mnTool);
+
+ final JMenuItem itOption = new JMenuItem("オプション(O)...", KeyEvent.VK_O);
+ // TODO ショートカットキー
+ itOption.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ final yukihane.inqubus.gui.ConfigDialog dlg = new yukihane.inqubus.gui.ConfigDialog(MainFrame.this);
+ dlg.setLocationRelativeTo(MainFrame.this);
+ dlg.setModal(true);
+ dlg.setVisible(true);
+ }
+ });
+ mnTool.add(itOption);
+
+ final JMenu mnHelp = new JMenu("ヘルプ(H)");
+ menuBar.add(mnHelp);
+
+ final JMenuItem itAbout = new JMenuItem("このソフトウェアについて(A)...", KeyEvent.VK_A);
+ itAbout.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ MainFrame_AboutBox dlg = new MainFrame_AboutBox(MainFrame.this);
+ dlg.pack();
+ dlg.setLocationRelativeTo(MainFrame.this);
+ dlg.setModal(true);
+ dlg.setVisible(true);
+ }
+ });
+ mnHelp.add(itAbout);
+
+ return menuBar;
+ }
+
private class DownloadListTransferHandler extends TransferHandler {
private static final long serialVersionUID = 1L;
}
private class TableTransferHandler extends DownloadListTransferHandler {
+
private static final long serialVersionUID = 1L;
@Override
return super.importData(support);
}
}
+
+
+ private class InqubusDownloadProfile implements DownloadProfile {
+
+ private final LoginProfile loginProfile;
+ private final ProxyProfile proxyProfile;
+
+ private InqubusDownloadProfile() {
+ this.loginProfile = new InqubusLoginProfile();
+ this.proxyProfile = new InqubusProxyProfile();
+ }
+
+ @Override
+ public LoginProfile getLoginInfo() {
+ return this.loginProfile;
+ }
+
+ @Override
+ public ProxyProfile getProxyProfile() {
+ return this.proxyProfile;
+ }
+
+ @Override
+ public VideoProfile getVideoProfile() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public CommentProfile getCommentProfile() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public GeneralProfile getGeneralProfile() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+
+ private class InqubusLoginProfile implements LoginProfile {
+ private final String mail;
+ private final String password;
+
+ private InqubusLoginProfile(){
+ final Config p = Config.INSTANCE;
+ this.mail = p.getId();
+ this.password = p.getPassword();
+ }
+
+ @Override
+ public String getMail() {
+ return this.mail;
+ }
+
+ @Override
+ public String getPassword() {
+ return this.password;
+ }
+ }
+
+ private class InqubusProxyProfile implements ProxyProfile {
+ private final boolean use;
+ private final String host;
+ private final int port;
+
+ private InqubusProxyProfile(){
+ final Config p = Config.INSTANCE;
+ this.use = p.getProxyUse();
+ this.host = p.getProxyHost();
+ final String pp = p.getProxyPort();
+ this.port = StringUtils.isBlank(pp) ? -1 : Integer.parseInt(pp);
+ }
+
+ @Override
+ public boolean use() {
+ return this.use;
+ }
+
+ @Override
+ public String getHost() {
+ return this.host;
+ }
+
+ @Override
+ public int getPort() {
+ return this.port;
+ }
+ }
}