From be55e99c6a16a93d1c823bb11d5f439646e7706b Mon Sep 17 00:00:00 2001 From: yukihane Date: Sat, 20 Aug 2011 14:11:02 +0900 Subject: [PATCH] =?utf8?q?=E7=A2=BA=E5=AE=9F=E3=81=AB=E4=B8=8D=E8=A6=81?= =?utf8?q?=E3=81=AB=E3=81=AA=E3=82=8B=E3=82=AF=E3=83=A9=E3=82=B9=E3=82=92?= =?utf8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- frontend/src/saccubus/MainFrame.java | 1682 -------------------- frontend/src/saccubus/MainFrame_AboutBox.java | 20 +- frontend/src/saccubus/Saccubus.java | 11 +- .../classic/profile/InputFileSetting.java | 2 +- .../classic/profile/OutputFileSetting.java | 9 +- .../saccubus/converter/classic/profile/SFile.java | 43 - .../converter/filegetter/CommentFileWebGetter.java | 48 - .../saccubus/converter/filegetter/FileGetter.java | 19 - .../converter/filegetter/FileInstanciator.java | 201 --- .../saccubus/converter/filegetter/FileLocator.java | 84 - .../converter/filegetter/TcommFileWebGetter.java | 39 - .../converter/filegetter/VideoFileWebGetter.java | 32 - .../converter/filegetter/WebFileInstanciator.java | 107 -- frontend/src/saccubus/prompt/Prompt.java | 80 +- frontend/src/saccubus/properties/SProperties.java | 280 ---- .../converter/profile/InputFileSetting.java | 12 - .../saccubus/converter/profile/OutputProfile.java | 2 - .../yukihane/saccubus/converter/profile/SFile.java | 14 - frontend/test/saccubus/SaccubusTest.java | 643 -------- 19 files changed, 60 insertions(+), 3268 deletions(-) delete mode 100644 frontend/src/saccubus/MainFrame.java delete mode 100644 frontend/src/saccubus/converter/classic/profile/SFile.java delete mode 100644 frontend/src/saccubus/converter/filegetter/CommentFileWebGetter.java delete mode 100644 frontend/src/saccubus/converter/filegetter/FileGetter.java delete mode 100644 frontend/src/saccubus/converter/filegetter/FileInstanciator.java delete mode 100644 frontend/src/saccubus/converter/filegetter/FileLocator.java delete mode 100644 frontend/src/saccubus/converter/filegetter/TcommFileWebGetter.java delete mode 100644 frontend/src/saccubus/converter/filegetter/VideoFileWebGetter.java delete mode 100644 frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java delete mode 100644 frontend/src/saccubus/properties/SProperties.java delete mode 100644 frontend/src/yukihane/saccubus/converter/profile/InputFileSetting.java delete mode 100644 frontend/src/yukihane/saccubus/converter/profile/SFile.java delete mode 100644 frontend/test/saccubus/SaccubusTest.java diff --git a/frontend/src/saccubus/MainFrame.java b/frontend/src/saccubus/MainFrame.java deleted file mode 100644 index d50d5d4..0000000 --- a/frontend/src/saccubus/MainFrame.java +++ /dev/null @@ -1,1682 +0,0 @@ -package saccubus; - -import java.io.IOException; -import saccubus.converter.Converter; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Image; -import java.awt.Insets; -import java.awt.Toolkit; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DropTarget; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.File; -import java.util.concurrent.FutureTask; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.GroupLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPasswordField; -import javax.swing.JRadioButton; -import javax.swing.JTabbedPane; -import javax.swing.JTextField; -import javax.swing.LayoutStyle.ComponentPlacement; -import javax.swing.SwingUtilities; -import nicobrowser.entity.NicoContent; -import nicobrowser.main.Main; -import org.apache.commons.lang.StringUtils; -import saccubus.ConvertStopFlag.State; -import saccubus.converter.classic.profile.FfmpegOption; -import saccubus.converter.classic.profile.NgSetting; -import saccubus.net.TextProgressListener; -import saccubus.properties.BasicSetting; -import saccubus.properties.ConvertSetting; -import saccubus.properties.InputCommentSetting; -import saccubus.properties.InputVideoSetting; -import saccubus.properties.SProperties; -import saccubus.properties.InputTcommentSetting; -import saccubus.properties.MovieSetting; -import saccubus.properties.OutputVideoSetting; -import saccubus.util.FileDropTarget; -import saccubus.util.PopupRightClick; -import saccubus.util.WayBackTimeParser; -import yukihane.Util; -import yukihane.nicovideo.NicoDBFinder; - -/** - *

- * タイトル: さきゅばす - *

- * - *

- * 説明: ニコニコ動画の動画をコメントつきで保存 - *

- * - *

- * 著作権: Copyright (c) 2007 PSI - *

- * - *

- * 会社名: - *

- * - * @author 未入力 - * @version 1.0 - */ -public class MainFrame extends JFrame { - - private static final long serialVersionUID = 2564486741331062989L; - public static final String PRODUCT_NAME = "いんきゅばす"; - public static final String VERSION = "1.7.2 (NicoBrowser" + Main.VERSION + ")"; - public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource( - "icon32.png")); - // TODO GUIが無いためフィールドに保持. - private File tempDir; - JPanel contentPane; - BorderLayout borderLayout1 = new BorderLayout(); - JMenuBar jMenuBar1 = new JMenuBar(); - JMenu jMenuFile = new JMenu(); - JMenuItem jMenuFileExit = new JMenuItem(); - JMenu jMenuHelp = new JMenu(); - JMenuItem jMenuHelpAbout = new JMenuItem(); - JLabel statusBar = new JLabel(); - JTabbedPane mainTabbedPane = new JTabbedPane(); - JPanel SavingInfoTabPanel = new JPanel(); - JPanel FFMpegTabPanel = new JPanel(); - // メインウィンドウ - private JPanel videoInfoPanel = new JPanel(); - private JPanel opPanel = new JPanel(); - private JLabel videoIdLabel = new JLabel(); - private JTextField videoIdField = new JTextField(); - private JLabel wayBackLabel = new JLabel(); - private JTextField wayBackField = new JTextField(); - private JCheckBox reduceCommentCheckBox = new JCheckBox(); - private JButton doButton = new JButton(); - public static final String DoButtonDefString = "変換"; - public static final String DoButtonStopString = "停止"; - public static final String DoButtonWaitString = "待機"; - JPanel UserInfoPanel = new JPanel(); - GridBagLayout gridBagLayout3 = new GridBagLayout(); - // ユーザ設定 - JLabel mailAddressLabel = new JLabel(); - JTextField mailAddressField = new JTextField(); - JLabel passwordLabel = new JLabel(); - JPasswordField passwordField = new JPasswordField(); - GridBagLayout gridBagLayout4 = new GridBagLayout(); - GridBagLayout gridBagLayout6 = new GridBagLayout(); - ButtonGroup CommentSaveButtonGroup = new ButtonGroup(); - ButtonGroup ConvSaveButtonGroup = new ButtonGroup(); - - private class FfmpegOptionCheckBoxListener implements ActionListener{ - - @Override - public void actionPerformed(ActionEvent e) { - setFFMpegOptionCheckbox(); - } - } - private final FfmpegOptionCheckBoxListener ffmpegOptionCheckBoxListener = new FfmpegOptionCheckBoxListener(); - - private void setFFMpegOptionCheckbox() { - boolean resizable = (resizeCheckBox.isEnabled() && resizeCheckBox.isSelected()); - resizeWidthField.setEnabled(resizable); - resizeHeigitField.setEnabled(resizable); - adjustRatioCheckBox.setEnabled(resizable); - - } - - private void setNames() { - mainTabbedPane.setName("mainTabbedPane"); - - mailAddressField.setName("mailAddressField"); - passwordField.setName("passwordField"); - - ffmpegPathField.setName("ffmpegPathField"); - vhookPathField.setName("vhookPathField"); - - mainOptionField.setName("mainOptionField"); - inputOptionField.setName("inputOptionField"); - outputOptionField.setName("outputOptionField"); - - fontPathField.setName("fontPathField"); - fontIndexField.setName("fontIndexField"); - showConvVideoCheckBox.setName("showConvVideoCheckBox"); - } - - public MainFrame() { - setNames(); - - videoSaveInfoPanel = savePanel.getVideoSaveInfoPanel(); - - try { - setDefaultCloseOperation(EXIT_ON_CLOSE); - jbInit(); - setPopup(); - setDropTarget(); - SProperties setting = SProperties.loadSetting(null, - null); - this.setSetting(setting); - } catch (Exception exception) { - exception.printStackTrace(); - } - } - - /** - * メイン画面最上部(ID/URL, 過去ログ, 変換ボタン)のパネルを初期化します. - */ - private void initVideoInfoPanel() { - - videoIdLabel.setText("URL/ID"); - wayBackLabel.setText("過去ログ"); - videoIdField.setText("http://www.nicovideo.jp/watch/"); - reduceCommentCheckBox.setText("旧仕様コメント数"); - - final GroupLayout oppLayout = new GroupLayout(opPanel); - opPanel.setLayout(oppLayout); - - oppLayout.setHorizontalGroup(oppLayout.createSequentialGroup() - .addGroup(oppLayout.createParallelGroup() - .addComponent(videoIdLabel) - .addComponent(wayBackLabel)) - .addGroup(oppLayout.createParallelGroup() - .addComponent(videoIdField) - .addGroup(oppLayout.createSequentialGroup() - .addComponent(wayBackField) - .addComponent(reduceCommentCheckBox))) - ); - - oppLayout.setVerticalGroup(oppLayout.createSequentialGroup() - .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(videoIdLabel) - .addComponent(videoIdField)) - .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(wayBackLabel) - .addComponent(wayBackField) - .addComponent(reduceCommentCheckBox)) - ); - - doButton.setText(DoButtonDefString); - doButton.addActionListener(new MainFrame_DoButton_actionAdapter(this)); - - final GroupLayout vipLayout = new GroupLayout(videoInfoPanel); - videoInfoPanel.setLayout(vipLayout); - - vipLayout.setHorizontalGroup(vipLayout.createSequentialGroup() - .addComponent(opPanel).addComponent(doButton)); - - vipLayout.setVerticalGroup(vipLayout.createParallelGroup() - .addComponent(opPanel).addComponent(doButton, 10, 20, 50)); - } - - /** - * コンポーネントの初期化。 - * - * @throws java.lang.Exception - */ - private void jbInit() throws Exception { - - initVideoInfoPanel(); - - GridBagConstraints gridBagConstraints74 = new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0); - gridBagConstraints74.gridwidth = 2; - GridBagConstraints gridBagConstraints73 = new GridBagConstraints(); - gridBagConstraints73.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints73.gridy = 6; - gridBagConstraints73.weightx = 1.0; - gridBagConstraints73.gridwidth = 4; - gridBagConstraints73.insets = new Insets(0, 0, 0, 5); - gridBagConstraints73.gridx = 1; - GridBagConstraints gridBagConstraints72 = new GridBagConstraints(); - gridBagConstraints72.gridx = 0; - gridBagConstraints72.anchor = GridBagConstraints.WEST; - gridBagConstraints72.insets = new Insets(0, 5, 0, 5); - gridBagConstraints72.fill = GridBagConstraints.NONE; - gridBagConstraints72.gridwidth = 1; - gridBagConstraints72.gridy = 6; - ShadowKindLabel = new JLabel(); - ShadowKindLabel.setText("影の種類"); - ShadowKindLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED); - GridBagConstraints gridBagConstraints66 = new GridBagConstraints(); - gridBagConstraints66.gridx = 0; - gridBagConstraints66.insets = new Insets(0, 5, 5, 5); - gridBagConstraints66.anchor = GridBagConstraints.WEST; - gridBagConstraints66.gridwidth = 2; - gridBagConstraints66.gridy = 1; - ViewCommentLabel = new JLabel(); - ViewCommentLabel.setText("表示コメント数"); - GridBagConstraints gridBagConstraints65 = new GridBagConstraints(); - gridBagConstraints65.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints65.gridy = 1; - gridBagConstraints65.weightx = 1.0; - gridBagConstraints65.gridwidth = 6; - gridBagConstraints65.insets = new Insets(0, 5, 5, 5); - gridBagConstraints65.gridx = 3; - GridBagConstraints gridBagConstraints64 = new GridBagConstraints(1, 1, - 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0); - gridBagConstraints64.gridy = 3; - gridBagConstraints64.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints64.gridx = 4; - GridBagConstraints gridBagConstraints63 = new GridBagConstraints(0, 4, - 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0); - gridBagConstraints63.gridy = 7; - gridBagConstraints63.gridx = 0; - gridBagConstraints63.gridwidth = 5; - GridBagConstraints gridBagConstraints62 = new GridBagConstraints(0, 3, - 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0); - gridBagConstraints62.gridy = 5; - gridBagConstraints62.gridx = 1; - gridBagConstraints62.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints62.insets = new Insets(0, 0, 5, 5); - gridBagConstraints62.gridwidth = 4; - GridBagConstraints gridBagConstraints61 = new GridBagConstraints(0, 2, - 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0); - gridBagConstraints61.gridy = 5; - gridBagConstraints61.gridx = 0; - gridBagConstraints61.fill = GridBagConstraints.VERTICAL; - gridBagConstraints61.anchor = GridBagConstraints.WEST; - gridBagConstraints61.gridwidth = 1; - GridBagConstraints gridBagConstraints60 = new GridBagConstraints(0, 1, - 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0); - gridBagConstraints60.gridy = 3; - gridBagConstraints60.gridx = 1; - gridBagConstraints60.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints60.insets = new Insets(0, 0, 0, 5); - gridBagConstraints60.gridwidth = 3; - GridBagConstraints gridBagConstraints59 = new GridBagConstraints(0, 0, - 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0); - gridBagConstraints59.gridy = 3; - gridBagConstraints59.insets = new Insets(5, 5, 5, 5); - gridBagConstraints59.gridx = 0; - gridBagConstraints59.fill = GridBagConstraints.NONE; - gridBagConstraints59.anchor = GridBagConstraints.WEST; - gridBagConstraints59.weightx = 0.0; - gridBagConstraints59.gridwidth = 1; - GridBagConstraints gridBagConstraints58 = new GridBagConstraints(); - gridBagConstraints58.gridx = 0; - gridBagConstraints58.anchor = GridBagConstraints.WEST; - gridBagConstraints58.insets = new Insets(0, 5, 5, 5); - gridBagConstraints58.gridwidth = 5; - gridBagConstraints58.weightx = 1.0; - gridBagConstraints58.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints58.gridy = 0; - - GridBagConstraints gridBagConstraints54 = new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0); - gridBagConstraints54.gridwidth = 3; - - GridBagConstraints gridBagConstraints33 = new GridBagConstraints(); - gridBagConstraints33.gridx = 0; - gridBagConstraints33.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints33.weightx = 1.0; - gridBagConstraints33.insets = new Insets(0, 5, 5, 5); - gridBagConstraints33.gridwidth = 5; - gridBagConstraints33.gridy = 9; - - GridBagConstraints gridBagConstraints14 = new GridBagConstraints(); - gridBagConstraints14.gridx = 0; - gridBagConstraints14.anchor = GridBagConstraints.WEST; - gridBagConstraints14.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints14.weightx = 1.0; - gridBagConstraints14.gridwidth = 5; - gridBagConstraints14.insets = new Insets(0, 5, 0, 5); - gridBagConstraints14.gridy = 8; - GridBagConstraints gridBagConstraints7 = new GridBagConstraints(0, 0, - 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, - GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0); - gridBagConstraints7.weighty = 0.0; - GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); - gridBagConstraints6.gridx = 0; - gridBagConstraints6.weighty = 1.0; - gridBagConstraints6.weightx = 1.0; - gridBagConstraints6.insets = new Insets(0, 5, 0, 5); - gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints6.anchor = GridBagConstraints.NORTH; - gridBagConstraints6.gridy = 1; - GridBagConstraints gridBagConstraints1 = new GridBagConstraints(0, 1, - 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0); - gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints1.anchor = GridBagConstraints.NORTH; - gridBagConstraints1.weighty = 1.0; - - this.setIconImage(WinIcon); - contentPane = (JPanel) this.getContentPane(); - contentPane.setLayout(borderLayout1); - setSize(new Dimension(400, 450)); - setTitle(PRODUCT_NAME + " " + VERSION); - this.addWindowListener(new MainFrame_this_windowAdapter(this)); - statusBar.setText(" "); - jMenuFile.setText("ファイル"); - jMenuFileExit.setText("終了"); - jMenuFileExit.addActionListener(new MainFrame_jMenuFileExit_ActionAdapter( - this)); - jMenuHelp.setText("ヘルプ"); - jMenuHelpAbout.setText("バージョン情報"); - jMenuHelpAbout.addActionListener(new MainFrame_jMenuHelpAbout_ActionAdapter( - this)); - SavingInfoTabPanel.setLayout(new GridLayout()); - UserInfoPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "ユーザ設定")); - UserInfoPanel.setLayout(gridBagLayout3); - mailAddressLabel.setText("メールアドレス"); - passwordLabel.setText("パスワード"); - - setListenerToSavePanelButton(); - - FFMpegTabPanel.setLayout(gridBagLayout6); - PathSettingPanel.setBorder(BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "プログラムの位置の設定")); - PathSettingPanel.setLayout(gridBagLayout7); - FFmpegPathLabel.setText("FFmpeg"); - SettingFFmpegPathButton.setText("参照"); - SettingFFmpegPathButton.addActionListener(new MainFrame_SettingFFmpegPathButton_actionAdapter( - this)); - VhookPathLabel.setText("拡張vhookライブラリ"); - SettingVhookPathButton.setText("参照"); - SettingVhookPathButton.addActionListener(new MainFrame_SettingVhookPathButton_actionAdapter( - this)); - VhookSettingPanel.setLayout(gridBagLayout8); - VhookSettingPanel.setBorder(BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "拡張vhookライブラリの設定")); - FFmpegSettingPanel.setBorder(BorderFactory.createTitledBorder( - BorderFactory.createEtchedBorder(), "FFmpegの設定")); - FFmpegSettingPanel.setLayout(gblFFmpegSettingPanel); - FontPathLabel.setText("フォントパス"); - SettingFontPathButton.setText("参照"); - SettingFontPathButton.addActionListener(new MainFrame_SettingFontPathButton_actionAdapter( - this)); - showConvVideoCheckBox.setText("変換中の画像を表示する"); - - extOptionLabel.setText("出力動画の拡張子"); - inputOptionLabel.setText("入力オプション"); - outputOptionLabel.setText("出力オプション"); - mainOptionLabel.setText("メインオプション"); - avfilterOptionLabel.setText("avfilterオプション"); - - FontIndexLabel.setText("フォント番号"); - - BasicInfoTabPanel.setLayout(gridBagLayout12); - jMenuBar1.add(jMenuFile); - jMenuFile.add(jMenuFileExit); - jMenuBar1.add(jMenuHelp); - jMenuHelp.add(jMenuHelpAbout); - setJMenuBar(jMenuBar1); - - contentPane.add(statusBar, BorderLayout.SOUTH); - contentPane.add(mainTabbedPane, java.awt.BorderLayout.CENTER); - contentPane.add(videoInfoPanel, java.awt.BorderLayout.NORTH); - UserInfoPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, - 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(0, 5, 5, 5), 0, 0)); - UserInfoPanel.add(mailAddressField, new GridBagConstraints(1, 0, 1, 1, - 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(0, 5, 5, 5), 0, 0)); - UserInfoPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, - 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, - new Insets(0, 5, 5, 0), 0, 0)); - UserInfoPanel.add(mailAddressLabel, new GridBagConstraints(0, 0, 1, 1, - 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, - new Insets(0, 5, 5, 0), 0, 0)); - PathSettingPanel.add(ffmpegPathField, new GridBagConstraints(0, 1, 1, - 1, 1.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0)); - PathSettingPanel.add(SettingFFmpegPathButton, gridBagConstraints74); - PathSettingPanel.add(FFmpegPathLabel, new GridBagConstraints(0, 0, 2, - 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, - new Insets(0, 5, 5, 5), 0, 0)); - PathSettingPanel.add(vhookPathField, new GridBagConstraints(0, 3, 1, 1, - 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(0, 5, 5, 5), 0, 0)); - PathSettingPanel.add(SettingVhookPathButton, new GridBagConstraints(1, - 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0)); - PathSettingPanel.add(VhookPathLabel, gridBagConstraints54); - - - final GroupLayout layout = new GroupLayout(FFmpegSettingPanel); - FFmpegSettingPanel.setLayout(layout); - - layout.setHorizontalGroup(layout.createParallelGroup() - .addComponent(getFFmpegOptionComboBoxPanel()) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup() - .addComponent(extOptionLabel) - .addComponent(mainOptionLabel) - .addComponent(inputOptionLabel) - .addComponent(outputOptionLabel) - .addComponent(avfilterOptionLabel) - ) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup() - .addComponent(extOptionField) - .addComponent(mainOptionField) - .addComponent(inputOptionField) - .addComponent(outputOptionField) - .addComponent(avfilterOptionField) - ) - ) - .addGroup(layout.createParallelGroup() - .addGroup(layout.createSequentialGroup() - .addComponent(resizeCheckBox) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(resizeWidthLabel) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(resizeWidthField) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(resizeHeightLabel) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(resizeHeigitField) - ) - ) - .addGroup(layout.createSequentialGroup() - .addGap(10) - .addComponent(adjustRatioCheckBox)) - .addGroup(layout.createSequentialGroup() - .addGap(20) - ) - ); - - layout.setVerticalGroup(layout.createSequentialGroup() - .addComponent(getFFmpegOptionComboBoxPanel()) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(extOptionLabel) - .addComponent(extOptionField)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(mainOptionLabel) - .addComponent(mainOptionField)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(inputOptionLabel) - .addComponent(inputOptionField)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(outputOptionLabel) - .addComponent(outputOptionField)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(avfilterOptionLabel) - .addComponent(avfilterOptionField)) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(resizeCheckBox) - .addComponent(resizeWidthLabel) - .addComponent(resizeWidthField) - .addComponent(resizeHeightLabel) - .addComponent(resizeHeigitField)) - .addComponent(adjustRatioCheckBox) - ) - ); - - resizeCheckBox.addActionListener(ffmpegOptionCheckBoxListener); - adjustRatioCheckBox.addActionListener(ffmpegOptionCheckBoxListener); - setFFMpegOptionCheckbox(); - - - - mainTabbedPane.add(BasicInfoTabPanel, "基本設定"); - mainTabbedPane.add(SavingInfoTabPanel, "保存設定"); - mainTabbedPane.add(FFMpegTabPanel, "動画設定"); - mainTabbedPane.addTab("変換設定", null, getConvertingSettingPanel(), null); - SavingInfoTabPanel.add(savePanel); - BasicInfoTabPanel.add(UserInfoPanel, gridBagConstraints7); - BasicInfoTabPanel.add(getProxyInfoPanel(), gridBagConstraints6); - VhookSettingPanel.add(FontPathLabel, gridBagConstraints59); - VhookSettingPanel.add(showConvVideoCheckBox, gridBagConstraints63); - VhookSettingPanel.add(fontPathField, gridBagConstraints60); - VhookSettingPanel.add(fontIndexField, gridBagConstraints62); - VhookSettingPanel.add(FontIndexLabel, gridBagConstraints61); - VhookSettingPanel.add(SettingFontPathButton, gridBagConstraints64); - VhookSettingPanel.add(getFixFontSizeCheckBox(), gridBagConstraints14); - VhookSettingPanel.add(getOpaqueCommentCheckBox(), gridBagConstraints33); - VhookSettingPanel.add(getNotUseVhookCheckBox(), gridBagConstraints58); - VhookSettingPanel.add(getViewCommentField(), gridBagConstraints65); - VhookSettingPanel.add(ViewCommentLabel, gridBagConstraints66); - VhookSettingPanel.add(ShadowKindLabel, gridBagConstraints72); - VhookSettingPanel.add(getShadowComboBox(), gridBagConstraints73); - - FFMpegTabPanel.add(PathSettingPanel, new GridBagConstraints(0, 0, 1, 1, - 1.0, 0.0, GridBagConstraints.NORTHEAST, - GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0)); - FFMpegTabPanel.add(FFmpegSettingPanel, gridBagConstraints1); - } - - /** - * 保存設定パネル内のボタンにアクションリスナを割り当てる. - */ - private void setListenerToSavePanelButton() { - ActionListener al; - al = new InputVideoPanelButtonListener(); - videoSaveInfoPanel.getShowSavingVideoFolderDialogButton().addActionListener(al); - videoSaveInfoPanel.getShowSavingVideoFileDialogButton().addActionListener(al); - videoSaveInfoPanel.getNibrFileChooserButton().addActionListener(al); - - al = new VideoUseRadioButtonListener(); - videoSaveInfoPanel.getVideoNoSaveButton().addActionListener(al); - videoSaveInfoPanel.getVideoSaveButton().addActionListener(al); - videoSaveInfoPanel.getVideoUseNiBrButton().addActionListener(al); - - al = new InputCommentPanelButtonListener(); - savePanel.getShowSavingCommentFolderDialogButton().addActionListener(al); - savePanel.getShowSavingCommentFileDialogButton().addActionListener(al); - - al = new OutputVideoPanelButtonListener(); - savePanel.getShowSavingConvertedVideoFolderDialogButton().addActionListener(al); - savePanel.getShowSavingConvertedVideoFileDialogButton().addActionListener(al); - } - - private void setPopup() { - mainOptionField.addMouseListener(new PopupRightClick( - this.mainOptionField)); - inputOptionField.addMouseListener(new PopupRightClick( - this.inputOptionField)); - outputOptionField.addMouseListener(new PopupRightClick( - this.outputOptionField)); - savePanel.getCommentNumField().addMouseListener(new PopupRightClick( - savePanel.getCommentNumField())); - - savePanel.getCommentSavedFileField().addMouseListener(new PopupRightClick( - savePanel.getCommentSavedFileField())); - savePanel.getCommentSavedFolderField().addMouseListener(new PopupRightClick( - savePanel.getCommentSavedFolderField())); - - savePanel.getConvertedVideoSavedFileField().addMouseListener(new PopupRightClick( - savePanel.getConvertedVideoSavedFileField())); - savePanel.getConvertedVideoSavedFolderField().addMouseListener(new PopupRightClick( - savePanel.getConvertedVideoSavedFolderField())); - - videoSaveInfoPanel.getVideoSavedFileField().addMouseListener(new PopupRightClick( - videoSaveInfoPanel.getVideoSavedFileField())); - videoSaveInfoPanel.getVideoSavedFolderField().addMouseListener(new PopupRightClick( - videoSaveInfoPanel.getVideoSavedFolderField())); - videoSaveInfoPanel.getNibrFileField().addMouseListener( - new PopupRightClick(videoSaveInfoPanel.getNibrFileField())); - - ffmpegPathField.addMouseListener(new PopupRightClick( - this.ffmpegPathField)); - vhookPathField.addMouseListener(new PopupRightClick(this.vhookPathField)); - videoIdField.addMouseListener(new PopupRightClick( - this.videoIdField)); - viewCommentField.addMouseListener(new PopupRightClick( - this.viewCommentField)); - fontPathField.addMouseListener(new PopupRightClick(this.fontPathField)); - mailAddressField.addMouseListener(new PopupRightClick(this.mailAddressField)); - passwordField.addMouseListener(new PopupRightClick(this.passwordField)); - wayBackField.addMouseListener(new PopupRightClick(this.wayBackField)); - - proxyTextField.addMouseListener(new PopupRightClick(this.proxyTextField)); - proxyPortTextField.addMouseListener(new PopupRightClick( - this.proxyPortTextField)); - - fontIndexField.addMouseListener(new PopupRightClick(this.fontIndexField)); - - ngWordTextField.addMouseListener(new PopupRightClick( - this.ngWordTextField)); - ngIdTextField.addMouseListener(new PopupRightClick(this.ngIdTextField)); - } - - private void setDropTarget() { - addTarget(videoSaveInfoPanel.getVideoSavedFileField(), false); - addTarget(videoSaveInfoPanel.getVideoSavedFolderField(), true); - addTarget(videoSaveInfoPanel.getNibrFileField(), false); - - addTarget(savePanel.getCommentSavedFileField(), false); - addTarget(savePanel.getCommentSavedFolderField(), true); - - addTarget(savePanel.getConvertedVideoSavedFileField(), false); - addTarget(savePanel.getConvertedVideoSavedFolderField(), true); - - addTarget(ffmpegPathField, false); - addTarget(vhookPathField, false); - addTarget(fontPathField, false); - - } - - /** - * テキストフィールドに対しドロップを行った場合にファイルもしくはディレクトリの文字列を設定できるようにする. - * @param c 設定対象のテキストフィールドオブジェクト. - * @param isDir ディレクトリを設定する場合はtrue, ファイルの場合はfalse. - * @return ドロップターゲット(用途無し). - */ - private DropTarget addTarget(JTextField c, boolean isDir) { - return new DropTarget(c, DnDConstants.ACTION_COPY, new FileDropTarget( - c, isDir), true); - } - private File CurrentDir = new File("."); - private JPanel PathSettingPanel = new JPanel(); - private JLabel FFmpegPathLabel = new JLabel(); - private GridBagLayout gridBagLayout7 = new GridBagLayout(); - private JTextField ffmpegPathField = new JTextField(); - private JButton SettingFFmpegPathButton = new JButton(); - private JLabel VhookPathLabel = new JLabel(); - private JTextField vhookPathField = new JTextField(); - private JButton SettingVhookPathButton = new JButton(); - private JPanel VhookSettingPanel = new JPanel(); - private GridBagLayout gridBagLayout8 = new GridBagLayout(); - private JPanel FFmpegSettingPanel = new JPanel(); - private GridBagLayout gblFFmpegSettingPanel = new GridBagLayout(); - private JLabel FontPathLabel = new JLabel(); - private JTextField fontPathField = new JTextField(); - private JButton SettingFontPathButton = new JButton(); - private JCheckBox showConvVideoCheckBox = new JCheckBox(); - - private void showSaveDialog(String title, JTextField field, boolean isSave, - boolean isDir) { - JFileChooser chooser = new JFileChooser(CurrentDir); - chooser.setDialogTitle(title); - int code = 0; - if (isDir) { - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - } - if (isSave) { - code = chooser.showSaveDialog(this); - } else { - code = chooser.showOpenDialog(this); - } - if (code == JFileChooser.APPROVE_OPTION) { - if (isDir) { - CurrentDir = chooser.getSelectedFile(); - field.setText(CurrentDir.getAbsolutePath()); - } else { - File selected = chooser.getSelectedFile(); - CurrentDir = chooser.getCurrentDirectory(); - field.setText(selected.getAbsolutePath()); - } - } - } - - private SProperties getSetting() { - SProperties setting = new SProperties( - getBasicSetting(), - getInputVideoSetting(), - getInputCommentSetting(), - getTcommentSetting(), - getOutputVideoSetting(), - getMovieSetting(), - getConvertSetting()); - return setting; - } - - /** - * 設定を画面に反映する. - * @param setting 反映する設定. - */ - private void setSetting(SProperties setting) { - // 基本設定 - final BasicSetting basic = setting.getBasicSetting(); - tempDir = basic.getTempDir(); - mailAddressField.setText(basic.getUser().getMail()); - passwordField.setText(basic.getUser().getPassword()); - // プロキシ関連 - useProxyCheckBox.setSelected(basic.isProxyUse()); - proxyTextField.setText(basic.getProxyHost()); - int proxy_port = basic.getProxyPort(); - if (proxy_port >= 0 && proxy_port <= 65535) { - proxyPortTextField.setText(Integer.toString(proxy_port)); - } else { - proxyPortTextField.setText(""); - } - - // 保存設定 - 入力動画 - final InputVideoSetting inVideo = setting.getInputVideoSetting(); - JRadioButton activeButton; - switch (inVideo.getProcessKind()) { - case NO_SAVE: - activeButton = videoSaveInfoPanel.getVideoNoSaveButton(); - break; - case NICOBROWSER: - activeButton = videoSaveInfoPanel.getVideoUseNiBrButton(); - break; - case SAVE: - default: - activeButton = videoSaveInfoPanel.getVideoSaveButton(); - break; - } - activeButton.doClick(); - - videoSaveInfoPanel.getVideoSavedFileField().setText(inVideo.getFile().getPath()); - videoSaveInfoPanel.getVideoSavedFolderField().setText(inVideo.getFolder().getPath()); - videoSaveInfoPanel.getDelVideoCheckBox().setSelected(inVideo.isDeleteAfterConvert()); - final boolean videoFixName = inVideo.isAutoNaming(); - videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName); - videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName); - videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath()); - - // 保存設定 - 入力コメント - final InputCommentSetting inputComment = setting.getInputCommentSetting(); - savePanel.getSavingCommentCheckBox().setSelected(inputComment.getProcessKind()); - savePanel.getCommentSavedFileField().setText(inputComment.getFile().getPath()); - savePanel.getDelCommentCheckBox().setSelected(inputComment.isDeleteAfterConvert()); - savePanel.getCommentSavedFolderField().setText(inputComment.getFolder().getPath()); - savePanel.getCommentNumField().setText(Integer.toString(inputComment.getNumOfComment())); - savePanel.getFixCommentNumCheckBox().setSelected(inputComment.isSelfAdjustNumOfComment()); - boolean commentFixName = inputComment.isAutoNaming(); - savePanel.getCommentSaveFileRadioButton().setSelected(!commentFixName); - savePanel.getCommentSaveFolderRadioButton().setSelected(commentFixName); - - // 投稿者コメント - InputTcommentSetting tcom = setting.getInputTcommentSetting(); - savePanel.setTcommentDownload(tcom.getProcessKind()); - savePanel.setTcommentDelete(tcom.isDeleteAfterConvert()); - savePanel.setTcommentAutoFileName(tcom.isAutoNaming()); - savePanel.setTcommentDirectoryName(tcom.getFolder().getPath()); - savePanel.setTcommentFileName(tcom.getFile().getPath()); - - // 保存設定 - 出力コメント付き動画 - final OutputVideoSetting outputVideo = setting.getOutputVideoSetting(); - savePanel.getSavingConvertedVideoCheckBox().setSelected(outputVideo.getProcessKind()); - savePanel.getAddCommentCheckBox().setSelected(outputVideo.isAddComment()); - savePanel.getAddTcommentCheckBox().setSelected(outputVideo.isAddTcomment()); - savePanel.getConvertedVideoSavedFileField().setText(outputVideo.getFile().getPath()); - savePanel.getConvertedVideoSavedFolderField().setText(outputVideo.getFolder().getPath()); - savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(outputVideo.isCutIdName()); - boolean convFixName = outputVideo.isAutoNaming(); - savePanel.getConvSaveFileRadioButton().setSelected(!convFixName); - savePanel.getConvSaveFolderRadioButton().setSelected(convFixName); - - // 動画設定 - final MovieSetting movie = setting.getMovieSetting(); - ffmpegPathField.setText(movie.getFfmpeg().toString()); - vhookPathField.setText(movie.getVhook().toString()); - extOptionField.setText(movie.getFfmpegOption().getExtOption()); - mainOptionField.setText(movie.getFfmpegOption().getMainOption()); - inputOptionField.setText(movie.getFfmpegOption().getInOption()); - outputOptionField.setText(movie.getFfmpegOption().getOutOption()); - avfilterOptionField.setText(movie.getFfmpegOption().getAvfilterOption()); - resizeCheckBox.setSelected(movie.getFfmpegOption().isResize()); - resizeWidthField.setText(Integer.toString(movie.getFfmpegOption().getResizeWidth())); - resizeHeigitField.setText(Integer.toString(movie.getFfmpegOption().getResizeHeight())); - adjustRatioCheckBox.setSelected(movie.getFfmpegOption().isAdjustRatio()); - FFmpegOptionModel.reload(movie.getOptionFile()); - - // 変換設定 - final ConvertSetting conv = setting.getConvertSetting(); - disableVhookCheckBox.setSelected(conv.isVhookDisabled()); - viewCommentField.setText(Integer.toString(conv.getMaxNumOfComment())); - fontPathField.setText(conv.getFont().toString()); - fontIndexField.setText(Integer.toString(conv.getFontIndex())); - shadowComboBox.setSelectedIndex(conv.getShadowIndex()); - showConvVideoCheckBox.setSelected(conv.isShowConverting()); - fixFontSizeCheckBox.setSelected(conv.isSelfAdjustFontSize()); - opaqueCommentCheckBox.setSelected(conv.isCommentOpaque()); - ngWordTextField.setText(conv.getNgSetting().getWord()); - ngIdTextField.setText(conv.getNgSetting().getId()); - } - - /** - * [ファイル|終了] アクションが実行されました。 - * - * @param actionEvent - * ActionEvent - */ - void jMenuFileExit_actionPerformed(ActionEvent actionEvent) { - try { - SProperties setting = getSetting(); - SProperties.saveSetting(setting); - } catch (Throwable t) { - Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "設定保存に失敗", t); - } - System.exit(0); - } - - /** - * [ヘルプ|バージョン情報] アクションが実行されました。 - * - * @param actionEvent - * ActionEvent - */ - void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) { - MainFrame_AboutBox dlg = new MainFrame_AboutBox(this); - dlg.pack(); - dlg.setLocationRelativeTo(this); - dlg.setVisible(true); - } - - /* 変換・保存する */ - private Converter Converter = null; - // FFmpegの設定 ここから - private final JLabel extOptionLabel = new JLabel(); - private final JTextField extOptionField = new JTextField(); - private JLabel mainOptionLabel = new JLabel(); - private JTextField mainOptionField = new JTextField(); - private JLabel inputOptionLabel = new JLabel(); - private JTextField inputOptionField = new JTextField(); - private JLabel outputOptionLabel = new JLabel(); - private JTextField outputOptionField = new JTextField(); - private final JLabel avfilterOptionLabel = new JLabel(); - private final JTextField avfilterOptionField = new JTextField(); - private final JCheckBox resizeCheckBox = new JCheckBox("次のサイズに収まるよう縮小(-s)"); - private final JLabel resizeWidthLabel = new JLabel("横"); - private final JTextField resizeWidthField = new NumberFormattedTextField(); - private final JLabel resizeHeightLabel = new JLabel("縦"); - private final JTextField resizeHeigitField = new NumberFormattedTextField(); - private final JCheckBox adjustRatioCheckBox = new JCheckBox("アスペクト比を維持"); - // FFmpegの設定 ここまで - private JLabel FontIndexLabel = new JLabel(); - private JTextField fontIndexField = new JTextField(); - private JPanel BasicInfoTabPanel = new JPanel(); - private GridBagLayout gridBagLayout12 = new GridBagLayout(); - private JPanel ConvertingSettingPanel = null; - private JPanel NGWordSettingPanel = null; - private JLabel NGWordLabel = null; - private JTextField ngWordTextField = null; - private JLabel NGIDLabel = null; - private JTextField ngIdTextField = null; - // プロキシ設定 - private JPanel ProxyInfoPanel = null; - private JCheckBox useProxyCheckBox = null; - private JLabel proxyLabel = null; - private JTextField proxyTextField = null; - private JLabel proxyPortLabel = null; - private JTextField proxyPortTextField = null; - // - private JCheckBox fixFontSizeCheckBox = null; - private JCheckBox opaqueCommentCheckBox = null; - private final SavePanel savePanel = new SavePanel(); - private final VideoSaveInfoPanel videoSaveInfoPanel; - private JComboBox FFmpegOptionComboBox = null; - private JButton FFmpegOptionReloadButton = null; - private JPanel FFmpegOptionComboBoxPanel = null; - - public void DoButton_actionPerformed(ActionEvent e) { - if (Converter == null || Converter.isConverted()) { - try { - executeConvert(); - } catch (Exception ex) { - String text = ex.getMessage(); - if (StringUtils.isEmpty(text)) { - text = "予期しないエラーのため中断しました。"; - } - ex.printStackTrace(); - statusBar.setText(text); - } - } else { /* 開始しているので、ストップする。 */ - final ConvertStopFlag flag = Converter.getStopFlag(); - if (!flag.needStop()) { /* まだストップしていない。 */ - flag.requestStop(); - } - } - } - - private void executeConvert() throws IOException { - String url; - - // NicoBrowserファイルを利用する場合は、ファイル名からビデオIDを特定. - if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) { - try { - String fileName = videoSaveInfoPanel.getNibrFileField().getText(); - NicoDBFinder finder = NicoDBFinder.getInstance(); - NicoContent info = finder.findNicoContent(fileName); - if (info != null) { - url = info.getNicoId(); - } else { - // TODO これはダメ…だけどそのうちこの処理自体削除になる - url = ""; - } - } catch (Exception ex) { - JOptionPane.showMessageDialog(this, ex.getMessage(), "エラー", JOptionPane.ERROR_MESSAGE); - return; - } - } else { - url = videoIdField.getText(); - } - - TextProgressListener sl = new TextProgressListener() { - - public void setText(final String text) { - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - statusBar.setText(text); - } - }); - } - }; - - ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() { - - public void changeState(final State s) { - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - switch (s) { - case STOPPING: - doButton.setText(DoButtonWaitString); - break; - case FINISHED: - doButton.setText(DoButtonDefString); - } - } - }); - } - }; - - final String id = Util.getVideoId(url); - Converter = new Converter(id, getSetting().toProfile(), sl, - new ConvertStopFlag(scl)); - doButton.setText(DoButtonStopString); - FutureTask task = new FutureTask(Converter); - new Thread(task).start(); - - } - - /* FFmpegへのパス */ - public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) { - showSaveDialog("FFmpegへのパス", ffmpegPathField, false, false); - } - - public void SettingVhookPathButton_actionPerformed(ActionEvent e) { - showSaveDialog("拡張vhookライブラリへのパス", vhookPathField, false, false); - } - - public void SettingFontPathButton_actionPerformed(ActionEvent e) { - showSaveDialog("フォントへのパス", fontPathField, false, false); - } - - public void this_windowClosing(WindowEvent e) { - this.jMenuFileExit_actionPerformed(null); - } - - /** - * This method initializes ConvertingSettingPanel - * - * @return javax.swing.JPanel - */ - private JPanel getConvertingSettingPanel() { - if (ConvertingSettingPanel == null) { - GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); - gridBagConstraints11.weighty = 1.0; - gridBagConstraints11.weightx = 1.0; - gridBagConstraints11.insets = new Insets(0, 5, 0, 5); - gridBagConstraints11.gridy = 1; - gridBagConstraints11.gridx = 0; - gridBagConstraints11.anchor = GridBagConstraints.NORTH; - gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL; - GridBagConstraints gridBagConstraints = new GridBagConstraints(0, - 2, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, - GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0); - gridBagConstraints.gridx = 0; - gridBagConstraints.anchor = GridBagConstraints.CENTER; - gridBagConstraints.weighty = 0.0; - gridBagConstraints.gridy = 0; - ConvertingSettingPanel = new JPanel(); - ConvertingSettingPanel.setLayout(new GridBagLayout()); - ConvertingSettingPanel.add(getNGWordSettingPanel(), - gridBagConstraints11); - ConvertingSettingPanel.add(VhookSettingPanel, gridBagConstraints); - } - return ConvertingSettingPanel; - } - - /** - * This method initializes NGWordSettingPanel - * - * @return javax.swing.JPanel - */ - private JPanel getNGWordSettingPanel() { - if (NGWordSettingPanel == null) { - GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); - gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints5.gridy = 1; - gridBagConstraints5.weightx = 1.0; - gridBagConstraints5.insets = new Insets(0, 5, 5, 5); - gridBagConstraints5.gridx = 1; - GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); - gridBagConstraints4.gridx = 0; - gridBagConstraints4.anchor = GridBagConstraints.WEST; - gridBagConstraints4.insets = new Insets(0, 5, 5, 0); - gridBagConstraints4.gridy = 1; - NGIDLabel = new JLabel(); - NGIDLabel.setText("NG ID"); - GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); - gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints3.gridy = 0; - gridBagConstraints3.weightx = 1.0; - gridBagConstraints3.insets = new Insets(0, 5, 5, 5); - gridBagConstraints3.gridx = 1; - GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); - gridBagConstraints2.gridx = 0; - gridBagConstraints2.insets = new Insets(0, 5, 5, 0); - gridBagConstraints2.gridy = 0; - NGWordLabel = new JLabel(); - NGWordLabel.setText("NGワード"); - NGWordSettingPanel = new JPanel(); - NGWordSettingPanel.setLayout(new GridBagLayout()); - NGWordSettingPanel.setBorder(BorderFactory.createTitledBorder(null, - "NGワード・ID設定(半角スペース区切りで複数入力)")); - NGWordSettingPanel.add(NGWordLabel, gridBagConstraints2); - NGWordSettingPanel.add(getNGWordTextField(), gridBagConstraints3); - NGWordSettingPanel.add(NGIDLabel, gridBagConstraints4); - NGWordSettingPanel.add(getNGIDTextField(), gridBagConstraints5); - } - return NGWordSettingPanel; - } - - /** - * This method initializes NGWordTextField - * - * @return javax.swing.JTextField - */ - private JTextField getNGWordTextField() { - if (ngWordTextField == null) { - ngWordTextField = new JTextField(); - ngWordTextField.setName("ngWordTextField"); - } - return ngWordTextField; - } - - /** - * This method initializes NGIDTextField - * - * @return javax.swing.JTextField - */ - private JTextField getNGIDTextField() { - if (ngIdTextField == null) { - ngIdTextField = new JTextField(); - ngIdTextField.setName("ngIdTextField"); - } - return ngIdTextField; - } - - /** - * This method initializes ProxyInfoPanel - * - * @return javax.swing.JPanel - */ - private JPanel getProxyInfoPanel() { - if (ProxyInfoPanel == null) { - GridBagConstraints gridBagConstraints13 = new GridBagConstraints(); - gridBagConstraints13.gridx = 0; - gridBagConstraints13.gridwidth = 2; - gridBagConstraints13.weightx = 1.0; - gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints13.insets = new Insets(0, 5, 0, 5); - gridBagConstraints13.gridy = 0; - GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); - gridBagConstraints12.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints12.gridy = 2; - gridBagConstraints12.weightx = 1.0; - gridBagConstraints12.insets = new Insets(5, 0, 5, 5); - gridBagConstraints12.gridx = 1; - GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); - gridBagConstraints10.gridx = 0; - gridBagConstraints10.insets = new Insets(5, 5, 5, 5); - gridBagConstraints10.gridy = 2; - proxyPortLabel = new JLabel(); - proxyPortLabel.setText("ポート番号"); - GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); - gridBagConstraints9.fill = GridBagConstraints.BOTH; - gridBagConstraints9.gridy = 1; - gridBagConstraints9.weightx = 1.0; - gridBagConstraints9.insets = new Insets(0, 0, 0, 5); - gridBagConstraints9.gridx = 1; - GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); - gridBagConstraints8.gridx = 0; - gridBagConstraints8.insets = new Insets(0, 5, 0, 5); - gridBagConstraints8.fill = GridBagConstraints.NONE; - gridBagConstraints8.anchor = GridBagConstraints.EAST; - gridBagConstraints8.gridy = 1; - proxyLabel = new JLabel(); - proxyLabel.setText("プロキシ"); - ProxyInfoPanel = new JPanel(); - ProxyInfoPanel.setLayout(new GridBagLayout()); - ProxyInfoPanel.setBorder(BorderFactory.createTitledBorder(null, - "プロキシ設定")); - ProxyInfoPanel.add(proxyLabel, gridBagConstraints8); - ProxyInfoPanel.add(getProxyTextField(), gridBagConstraints9); - ProxyInfoPanel.add(proxyPortLabel, gridBagConstraints10); - ProxyInfoPanel.add(getProxyPortTextField(), gridBagConstraints12); - ProxyInfoPanel.add(getUseProxyCheckBox(), gridBagConstraints13); - } - return ProxyInfoPanel; - } - - /** - * This method initializes ProxyTextField - * - * @return javax.swing.JTextField - */ - private JTextField getProxyTextField() { - if (proxyTextField == null) { - proxyTextField = new JTextField(); - proxyTextField.setName("proxyTextField"); - } - return proxyTextField; - } - - /** - * This method initializes ProxyPortTextField - * - * @return javax.swing.JTextField - */ - private JTextField getProxyPortTextField() { - if (proxyPortTextField == null) { - proxyPortTextField = new JTextField(); - proxyPortTextField.setName("proxyPortTextField"); - } - return proxyPortTextField; - } - - /** - * This method initializes UseProxyCheckBox - * - * @return javax.swing.JCheckBox - */ - private JCheckBox getUseProxyCheckBox() { - if (useProxyCheckBox == null) { - useProxyCheckBox = new JCheckBox(); - useProxyCheckBox.setText("プロキシを使う"); - useProxyCheckBox.setName("useProxyCheckBox"); - } - return useProxyCheckBox; - } - - /** - * This method initializes FixFontSizeCheckBox - * - * @return javax.swing.JCheckBox - */ - private JCheckBox getFixFontSizeCheckBox() { - if (fixFontSizeCheckBox == null) { - fixFontSizeCheckBox = new JCheckBox(); - fixFontSizeCheckBox.setText("フォントサイズを画面にあわせて自動調整する"); - fixFontSizeCheckBox.setName("fixFontSizeCheckBox"); - } - return fixFontSizeCheckBox; - } - - /** - * This method initializes OpaqueCommentCheckBox - * - * @return javax.swing.JCheckBox - */ - private JCheckBox getOpaqueCommentCheckBox() { - if (opaqueCommentCheckBox == null) { - opaqueCommentCheckBox = new JCheckBox(); - opaqueCommentCheckBox.setText("全てのコメントを不透明にする"); - opaqueCommentCheckBox.setName("opaqueCommentCheckBox"); - } - return opaqueCommentCheckBox; - } - /** - * This method initializes FFmpegOptionComboBox - * - * @return javax.swing.JComboBox - */ - private final OptionComboBoxModel FFmpegOptionModel = new OptionComboBoxModel(); - private JCheckBox disableVhookCheckBox = null; - private JTextField viewCommentField = null; - private JLabel ViewCommentLabel = null; - private JLabel ShadowKindLabel = null; - private JComboBox shadowComboBox = null; - - private JComboBox getFFmpegOptionComboBox() { - if (FFmpegOptionComboBox == null) { - FFmpegOptionComboBox = new JComboBox(FFmpegOptionModel); - FFmpegOptionComboBox.addActionListener(new java.awt.event.ActionListener() { - - public void actionPerformed(java.awt.event.ActionEvent e) { - if (FFmpegOptionModel.isFile()) {// ファイル - setFFMpegOptionEnabled(false); - } else {// ファイルでない - setFFMpegOptionEnabled(true); - setFFMpegOptionCheckbox(); - } - } - - private void setFFMpegOptionEnabled(boolean enable) { - extOptionField.setEnabled(enable); - mainOptionField.setEnabled(enable); - inputOptionField.setEnabled(enable); - outputOptionField.setEnabled(enable); - avfilterOptionField.setEnabled(enable); - resizeCheckBox.setEnabled(enable); - resizeWidthField.setEnabled(enable); - resizeHeigitField.setEditable(enable); - adjustRatioCheckBox.setEnabled(enable); - } - }); - } - return FFmpegOptionComboBox; - } - - /** - * This method initializes FFmpegOptionReloadButton - * - * @return javax.swing.JButton - */ - private JButton getFFmpegOptionReloadButton() { - if (FFmpegOptionReloadButton == null) { - FFmpegOptionReloadButton = new JButton(); - FFmpegOptionReloadButton.setText("更新"); - FFmpegOptionReloadButton.addActionListener(new java.awt.event.ActionListener() { - - public void actionPerformed(java.awt.event.ActionEvent e) { - FFmpegOptionModel.reload(); - } - }); - } - return FFmpegOptionReloadButton; - } - - /** - * This method initializes FFmpegOptionComboBoxPanel - * - * @return javax.swing.JPanel - */ - private JPanel getFFmpegOptionComboBoxPanel() { - if (FFmpegOptionComboBoxPanel == null) { - GridBagConstraints gridBagConstraints47 = new GridBagConstraints(); - gridBagConstraints47.fill = GridBagConstraints.BOTH; - gridBagConstraints47.gridx = -1; - gridBagConstraints47.gridy = -1; - gridBagConstraints47.insets = new Insets(0, 0, 5, 5); - GridBagConstraints gridBagConstraints46 = new GridBagConstraints(); - gridBagConstraints46.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints46.gridwidth = 3; - gridBagConstraints46.gridx = -1; - gridBagConstraints46.gridy = -1; - gridBagConstraints46.weightx = 1.0; - gridBagConstraints46.insets = new Insets(0, 5, 5, 5); - FFmpegOptionComboBoxPanel = new JPanel(); - FFmpegOptionComboBoxPanel.setLayout(new GridBagLayout()); - FFmpegOptionComboBoxPanel.add(getFFmpegOptionComboBox(), - gridBagConstraints46); - FFmpegOptionComboBoxPanel.add(getFFmpegOptionReloadButton(), - gridBagConstraints47); - } - return FFmpegOptionComboBoxPanel; - } - - /** - * This method initializes NotUseVhookCheckBox - * - * @return javax.swing.JCheckBox - */ - private JCheckBox getNotUseVhookCheckBox() { - if (disableVhookCheckBox == null) { - disableVhookCheckBox = new JCheckBox(); - disableVhookCheckBox.setText("拡張vhookライブラリを無効にする(デバッグ用)"); - disableVhookCheckBox.setName("disableVhookCheckBox"); - } - return disableVhookCheckBox; - } - - /** - * This method initializes ViewCommentField - * - * @return javax.swing.JTextField - */ - private JTextField getViewCommentField() { - if (viewCommentField == null) { - viewCommentField = new JTextField(); - viewCommentField.setName("viewCommentField"); - } - return viewCommentField; - } - - /** - * This method initializes ShadowComboBox - * - * @return javax.swing.JComboBox - */ - private JComboBox getShadowComboBox() { - if (shadowComboBox == null) { - shadowComboBox = new JComboBox(SProperties.ShadowKindArray); - shadowComboBox.setName("shadowComboBox"); - } - return shadowComboBox; - } - - private BasicSetting getBasicSetting() { - String mail = mailAddressField.getText(); - String pass = String.valueOf(passwordField.getPassword()); - boolean proxyUse = useProxyCheckBox.isSelected(); - String proxyHost = proxyTextField.getText(); - int proxyPort; - try { - proxyPort = Integer.parseInt(proxyPortTextField.getText()); - } catch (NumberFormatException e) { - proxyPort = -1; - } - // TODO 作業用ディレクトリの設定GUI無し - return new BasicSetting(tempDir, mail, pass, proxyUse, proxyHost, proxyPort); - } - - private InputVideoSetting getInputVideoSetting() { - VideoSaveKind kind; - if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) { - kind = VideoSaveKind.NO_SAVE; - } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) { - kind = VideoSaveKind.NICOBROWSER; - } else { - kind = VideoSaveKind.SAVE; - } - boolean autoNaming = videoSaveInfoPanel.getSaveFolderRadioButton().isSelected(); - String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText(); - String file = videoSaveInfoPanel.getVideoSavedFileField().getText(); - boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected(); - String nibrFile = videoSaveInfoPanel.getNibrFileField().getText(); - - return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile)); - } - - private InputCommentSetting getInputCommentSetting() { - boolean download = savePanel.getSavingCommentCheckBox().isSelected(); - String file = savePanel.getCommentSavedFileField().getText(); - int back_comment; - try { - back_comment = Integer.parseInt(savePanel.getCommentNumField().getText()); - } catch (NumberFormatException ex) { - back_comment = 500; - } - boolean delete = savePanel.getDelCommentCheckBox().isSelected(); - boolean autoNaming = savePanel.getCommentSaveFolderRadioButton().isSelected(); - String folder = savePanel.getCommentSavedFolderField().getText(); - boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected(); - - final String txt = wayBackField.getText(); - long backLogPoint; - try { - backLogPoint = (StringUtils.isNotBlank(txt)) ? WayBackTimeParser.parse(txt) : -1; - } catch (IOException ex) { - backLogPoint = -1; - } - return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom, - back_comment, reduceCommentCheckBox.isSelected(), backLogPoint); - } - - /** - * 画面入力値から投稿者コメント設定を作成する. - * @return 作成した投稿者コメント設定. - */ - private InputTcommentSetting getTcommentSetting() { - boolean down = savePanel.isTcommentDownload(); - boolean del = savePanel.isTcommentDelete(); - boolean naming = savePanel.isTcommentAutoFileName(); - String dir = savePanel.getTcommentDirectoryName(); - String f = savePanel.getTcommentFileName(); - return new InputTcommentSetting(down, naming, dir, f, del); - } - - private OutputVideoSetting getOutputVideoSetting() { - boolean process = savePanel.getSavingConvertedVideoCheckBox().isSelected(); - boolean addComment = savePanel.getAddCommentCheckBox().isSelected(); - boolean addTcomment = savePanel.getAddTcommentCheckBox().isSelected(); - String file = savePanel.getConvertedVideoSavedFileField().getText(); - boolean cutId = savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected(); - boolean autoNaming = savePanel.getConvSaveFolderRadioButton().isSelected(); - String folder = savePanel.getConvertedVideoSavedFolderField().getText(); - - return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment, - addTcomment); - } - - private MovieSetting getMovieSetting() { - String ffmpeg = ffmpegPathField.getText(); - String vhook = vhookPathField.getText(); - String ext = extOptionField.getText(); - String main = mainOptionField.getText(); - String in = inputOptionField.getText(); - String out = outputOptionField.getText(); - String avfilter = avfilterOptionField.getText(); - boolean resize = resizeCheckBox.isSelected(); - String width = resizeWidthField.getText(); - String height = resizeHeigitField.getText(); - boolean adjust = adjustRatioCheckBox.isSelected(); - File optionFile = FFmpegOptionModel.getSelectedFile(); - - FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust); - return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt); - } - - private ConvertSetting getConvertSetting() { - boolean vhookDisabled = disableVhookCheckBox.isSelected(); - int maxComment = 30; - try { - maxComment = Integer.parseInt(viewCommentField.getText()); - } catch (NumberFormatException ex) { - } - File font = new File(fontPathField.getText()); - int fontIndex = Integer.parseInt(fontIndexField.getText()); - int shadowIndex = shadowComboBox.getSelectedIndex(); - boolean showConv = showConvVideoCheckBox.isSelected(); - boolean adjustFont = fixFontSizeCheckBox.isSelected(); - boolean commentOpaque = opaqueCommentCheckBox.isSelected(); - NgSetting ngSetting = new NgSetting(ngWordTextField.getText(), ngIdTextField.getText()); - - return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont, - commentOpaque, ngSetting); - } - - private class InputVideoPanelButtonListener implements ActionListener { - - public void actionPerformed(ActionEvent e) { - final Object source = e.getSource(); - final VideoSaveInfoPanel panel = videoSaveInfoPanel; - String title; - JTextField field; - boolean isSave; - boolean isDir; - - if (source == panel.getShowSavingVideoFolderDialogButton()) { - title = "動画の保存先(フォルダ)"; - field = panel.getVideoSavedFolderField(); - isSave = true; - isDir = true; - } else if (source == panel.getShowSavingVideoFileDialogButton()) { - title = "動画の保存先(ファイル)"; - field = panel.getVideoSavedFileField(); - isSave = true; - isDir = false; - } else if (source == panel.getNibrFileChooserButton()) { - title = "NicoBrowserファイル選択"; - field = panel.getNibrFileField(); - isSave = false; - isDir = false; - } else { - return; - } - showSaveDialog(title, field, isSave, isDir); - } - } - - private class InputCommentPanelButtonListener implements ActionListener { - - public void actionPerformed(ActionEvent e) { - final Object source = e.getSource(); - String title; - JTextField field; - boolean isSave; - boolean isDir; - if (source == savePanel.getShowSavingCommentFolderDialogButton()) { - title = "コメントの保存先(フォルダ)"; - field = savePanel.getCommentSavedFolderField(); - isSave = true; - isDir = true; - } else if (source == savePanel.getShowSavingCommentFileDialogButton()) { - title = "コメントの保存先(ファイル)"; - field = savePanel.getCommentSavedFileField(); - isSave = true; - isDir = false; - } else { - return; - } - showSaveDialog(title, field, isSave, isDir); - } - } - - private class OutputVideoPanelButtonListener implements ActionListener { - - public void actionPerformed(ActionEvent e) { - final Object source = e.getSource(); - String title; - JTextField field; - boolean isSave; - boolean isDir; - if (source == savePanel.getShowSavingConvertedVideoFolderDialogButton()) { - title = "コメント付き動画の保存先(フォルダ)"; - field = savePanel.getConvertedVideoSavedFolderField(); - isSave = true; - isDir = true; - } else if (source == savePanel.getShowSavingConvertedVideoFileDialogButton()) { - title = "コメント付き動画の保存先(ファイル)"; - field = savePanel.getConvertedVideoSavedFileField(); - isSave = true; - isDir = false; - } else { - return; - } - showSaveDialog(title, field, isSave, isDir); - } - } - - private class VideoUseRadioButtonListener implements ActionListener { - - public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); - if (source == videoSaveInfoPanel.getVideoUseNiBrButton()) { - maskExt(); - } else { - maskBase(); - } - } - - private void maskBase() { - mask(true); - } - - private void maskExt() { - mask(false); - } - - private void mask(boolean b) { - final VideoSaveInfoPanel panel = videoSaveInfoPanel; - videoIdField.setEditable(b); - panel.getDelVideoCheckBox().setEnabled(b); - - panel.getSaveFolderRadioButton().setEnabled(b); - panel.getVideoSavedFolderField().setEnabled(b); - panel.getShowSavingVideoFolderDialogButton().setEnabled(b); - - panel.getSaveFileRadioButton().setEnabled(b); - panel.getVideoSavedFileField().setEnabled(b); - panel.getShowSavingVideoFileDialogButton().setEnabled(b); - - panel.getNibrFileField().setEnabled(!b); - panel.getNibrFileChooserButton().setEnabled(!b); - } - } -} - -class MainFrame_this_windowAdapter extends WindowAdapter { - - private MainFrame adaptee; - - MainFrame_this_windowAdapter(MainFrame adaptee) { - this.adaptee = adaptee; - } - - @Override - public void windowClosing(WindowEvent e) { - adaptee.this_windowClosing(e); - } -} - -class MainFrame_SettingFontPathButton_actionAdapter implements ActionListener { - - private MainFrame adaptee; - - MainFrame_SettingFontPathButton_actionAdapter(MainFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent e) { - adaptee.SettingFontPathButton_actionPerformed(e); - } -} - -class MainFrame_SettingVhookPathButton_actionAdapter implements ActionListener { - - private MainFrame adaptee; - - MainFrame_SettingVhookPathButton_actionAdapter(MainFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent e) { - adaptee.SettingVhookPathButton_actionPerformed(e); - } -} - -class MainFrame_SettingFFmpegPathButton_actionAdapter implements ActionListener { - - private MainFrame adaptee; - - MainFrame_SettingFFmpegPathButton_actionAdapter(MainFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent e) { - adaptee.SettingFFmpegPathButton_actionPerformed(e); - } -} - -class MainFrame_DoButton_actionAdapter implements ActionListener { - - private MainFrame adaptee; - - MainFrame_DoButton_actionAdapter(MainFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent e) { - adaptee.DoButton_actionPerformed(e); - } -} - -class MainFrame_jMenuFileExit_ActionAdapter implements ActionListener { - - MainFrame adaptee; - - MainFrame_jMenuFileExit_ActionAdapter(MainFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent actionEvent) { - adaptee.jMenuFileExit_actionPerformed(actionEvent); - } -} - -class MainFrame_jMenuHelpAbout_ActionAdapter implements ActionListener { - - MainFrame adaptee; - - MainFrame_jMenuHelpAbout_ActionAdapter(MainFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent actionEvent) { - adaptee.jMenuHelpAbout_actionPerformed(actionEvent); - } -} diff --git a/frontend/src/saccubus/MainFrame_AboutBox.java b/frontend/src/saccubus/MainFrame_AboutBox.java index fda937c..cae2cbe 100644 --- a/frontend/src/saccubus/MainFrame_AboutBox.java +++ b/frontend/src/saccubus/MainFrame_AboutBox.java @@ -12,30 +12,30 @@ import saccubus.util.PopupRightClick; *

* タイトル: さきゅばす *

- * + * *

* 説明: ニコニコ動画の動画をコメントつきで保存 *

- * + * *

* 著作権: Copyright (c) 2007 PSI *

- * + * *

* 会社名: *

- * + * * @author 未入力 * @version 1.0 */ public class MainFrame_AboutBox extends JDialog implements ActionListener { /** - * + * */ private static final long serialVersionUID = -4256413309312729840L; String version = "ver1.22r(2008/04/27)"; - + String product = "本プログラムは「さきゅばす」を改変したものであり, \n" + "オリジナルの著作権は以下の通りです.\n\n" + "さきゅばす\n"+ @@ -43,7 +43,7 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener { "Copyright (C) 2008 Saccubus Developers Team\n"+ " 2007-2008 PSI\n\n"+ "ニコニコ動画の動画をコメントつきで保存"; - + JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); @@ -86,11 +86,11 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener { /** * コンポーネントの初期化。 - * + * * @throws java.lang.Exception */ private void jbInit() throws Exception { - image1 = new ImageIcon(saccubus.MainFrame.class.getResource("icon.png")); + image1 = new ImageIcon(saccubus.MainFrame_AboutBox.class.getResource("icon.png")); imageLabel.setIcon(image1); setTitle("バージョン情報"); panel1.setLayout(borderLayout1); @@ -121,7 +121,7 @@ public class MainFrame_AboutBox extends JDialog implements ActionListener { /** * ボタンイベントでダイアログを閉じる - * + * * @param actionEvent * ActionEvent */ diff --git a/frontend/src/saccubus/Saccubus.java b/frontend/src/saccubus/Saccubus.java index e2452e0..4310f3e 100644 --- a/frontend/src/saccubus/Saccubus.java +++ b/frontend/src/saccubus/Saccubus.java @@ -5,24 +5,25 @@ import javax.swing.SwingUtilities; import javax.swing.UIManager; import saccubus.prompt.Prompt; +import yukihane.inqubus.gui.MainFrame; /** *

* タイトル: さきゅばす *

- * + * *

* 説明: ニコニコ動画の動画をコメントつきで保存 *

- * + * *

* 著作権: Copyright (c) 2007 PSI *

- * + * *

* 会社名: *

- * + * * @author 未入力 * @version 1.0 */ @@ -53,7 +54,7 @@ public class Saccubus { /** * アプリケーションエントリポイント。 - * + * * @param args * String[] */ diff --git a/frontend/src/saccubus/converter/classic/profile/InputFileSetting.java b/frontend/src/saccubus/converter/classic/profile/InputFileSetting.java index e5c08ad..8ba8e93 100644 --- a/frontend/src/saccubus/converter/classic/profile/InputFileSetting.java +++ b/frontend/src/saccubus/converter/classic/profile/InputFileSetting.java @@ -21,7 +21,7 @@ public class InputFileSetting implements VideoProfile, CommentProfile { * @param download ダウンロードする必要があればtrue, ローカルファイルを用いるのであればfalse. * @param delete 変換後にファイルを削除するのであればtrue, 残したままにするのであればfalse. */ - public InputFileSetting(SFile file, boolean download, boolean delete, CommentGetInfo cominfo, long backLogPoint) { + public InputFileSetting(boolean download, boolean delete, CommentGetInfo cominfo, long backLogPoint) { this.download = download; this.delete = delete; this.commentGetInfo = cominfo; diff --git a/frontend/src/saccubus/converter/classic/profile/OutputFileSetting.java b/frontend/src/saccubus/converter/classic/profile/OutputFileSetting.java index 22db68a..2c15a49 100644 --- a/frontend/src/saccubus/converter/classic/profile/OutputFileSetting.java +++ b/frontend/src/saccubus/converter/classic/profile/OutputFileSetting.java @@ -8,15 +8,13 @@ import java.io.File; */ public class OutputFileSetting implements yukihane.saccubus.converter.profile.OutputProfile { - private final SFile file; private final boolean convert; private final boolean appendPrefixVideoId; private final boolean addComment; private final boolean addTcomment; - public OutputFileSetting(SFile file, boolean convert, boolean appendPrefixVideoId, boolean addComment, + public OutputFileSetting(boolean convert, boolean appendPrefixVideoId, boolean addComment, boolean addTcomment) { - this.file = file; this.convert = convert; this.appendPrefixVideoId = appendPrefixVideoId; this.addComment = addComment; @@ -44,11 +42,6 @@ public class OutputFileSetting implements yukihane.saccubus.converter.profile.Ou } @Override - public SFile getFile() { - return file; - } - - @Override public File getDir() { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/frontend/src/saccubus/converter/classic/profile/SFile.java b/frontend/src/saccubus/converter/classic/profile/SFile.java deleted file mode 100644 index 1efb754..0000000 --- a/frontend/src/saccubus/converter/classic/profile/SFile.java +++ /dev/null @@ -1,43 +0,0 @@ -/* $Id$ */ -package saccubus.converter.classic.profile; - -import java.io.File; - -/** - * さきゅばすで扱うファイルは、「保存するディレクトリ」と、「保存されたファイルそのもの」の2パターンある。 - * このクラスはこれらをまとめて扱うためのもの。 - * @author yuki - */ -public class SFile implements yukihane.saccubus.converter.profile.SFile { - - private final boolean isFile; - private final File file; - - /** - * @param isFile ファイルであればtrue, ディレクトリであればfalse. - * @param file このオブジェクトが示すFileインスタンス. - * @throws IllegalArgumentException 存在しないディレクトリを指定した. isFileがtrueの場合、親ディレクトリが存在しないとこの例外となる. - */ - public SFile(boolean isFile, File file) { - this.isFile = isFile; - this.file = file; - - File dir; - if (isFile) { - dir = file.getAbsoluteFile().getParentFile(); - } else { - dir = file; - } - if (!dir.isDirectory()) { - throw new IllegalArgumentException("ディレクトリが存在しません:" + dir); - } - } - - public boolean isFile() { - return isFile; - } - - public File getFile() { - return file; - } -} diff --git a/frontend/src/saccubus/converter/filegetter/CommentFileWebGetter.java b/frontend/src/saccubus/converter/filegetter/CommentFileWebGetter.java deleted file mode 100644 index efe6d6f..0000000 --- a/frontend/src/saccubus/converter/filegetter/CommentFileWebGetter.java +++ /dev/null @@ -1,48 +0,0 @@ -package saccubus.converter.filegetter; - -import java.io.File; -import java.io.IOException; -import saccubus.net.CommentInfo; -import saccubus.net.NicoClient; -import saccubus.net.TextProgressListener; -import saccubus.net.VideoInfo; - -/** - * - * @author yuki - */ -public class CommentFileWebGetter extends TcommFileWebGetter { - - private final boolean autoCommentNum; - private final int backComment; - private final boolean reduceComment; - private final CommentInfo commentInfo; - - CommentFileWebGetter(NicoClient client, VideoInfo vi, CommentInfo ci, boolean autoCommentNum, int backComment, boolean reduceComment) { - super(client, vi); - this.autoCommentNum = autoCommentNum; - this.backComment = backComment; - this.reduceComment = reduceComment; - this.commentInfo = ci; - } - - @Override - public File get(File file, TextProgressListener listener) throws IOException { - int com; - if (this.autoCommentNum) { - com = getVideoInfo().getBackCommentFromLength(); - } else { - com = backComment; - } - - File res = getClient().getComment(getVideoInfo(), getCommentInfo(), file, listener, com, reduceComment); - if (res == null) { - throw new IOException("コメントファイルのダウンロードに失敗しました。"); - } - return res; - } - - private CommentInfo getCommentInfo() { - return commentInfo; - } -} diff --git a/frontend/src/saccubus/converter/filegetter/FileGetter.java b/frontend/src/saccubus/converter/filegetter/FileGetter.java deleted file mode 100644 index c4ddae2..0000000 --- a/frontend/src/saccubus/converter/filegetter/FileGetter.java +++ /dev/null @@ -1,19 +0,0 @@ -package saccubus.converter.filegetter; - -import java.io.File; -import java.io.IOException; -import saccubus.net.TextProgressListener; - -/** - * - * @author yuki - */ -public class FileGetter { - - FileGetter() { - } - - File get(File file, TextProgressListener listener) throws IOException { - return file; - } -} diff --git a/frontend/src/saccubus/converter/filegetter/FileInstanciator.java b/frontend/src/saccubus/converter/filegetter/FileInstanciator.java deleted file mode 100644 index e9a8e7a..0000000 --- a/frontend/src/saccubus/converter/filegetter/FileInstanciator.java +++ /dev/null @@ -1,201 +0,0 @@ -/* $Id$ */ -package saccubus.converter.filegetter; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import org.apache.commons.io.FilenameUtils; -import saccubus.ConvertStopFlag; -import yukihane.saccubus.converter.profile.InputFileSetting; -import saccubus.net.TextProgressListener; -import yukihane.saccubus.converter.profile.LoinProfile; -import yukihane.saccubus.converter.profile.ProxyProfile; - -/** - * ダウンロード処理を全く必要としない場合のファイルインスタンス化クラス. - * @author yuki - */ -public class FileInstanciator { - - private final InstanciationType videoType; - private final InstanciationType commentType; - private final InstanciationType tcommType; - private final String videoId; - private FileGetter videoFileGetter; - private FileGetter commentFileGetter; - private FileGetter tcommFileGetter; - - protected void setVideoFileGetter(FileGetter getter) { - this.videoFileGetter = getter; - } - - protected void setCommentFileGetter(FileGetter getter) { - this.commentFileGetter = getter; - } - - protected void setTcommFileGetter(FileGetter getter) { - this.tcommFileGetter = getter; - } - - public static FileInstanciator create( - ConvertStopFlag stopFlag, - InstanciationType videoType, - CommentInstanciationType commentType, - InstanciationType tcommType, - LoinProfile li, - ProxyProfile proxy, - String tag, - long time) throws - IOException { - FileInstanciator getter; - if (videoType.isDownload() || commentType.isDownload() || tcommType.isDownload()) { - getter = new WebFileInstanciator(stopFlag, videoType, commentType, tcommType, li, proxy, tag, time); - } else { - getter = new FileInstanciator(videoType, commentType, tcommType, tag); - } - return getter; - } - - protected FileInstanciator( - InstanciationType videoType, - InstanciationType commentType, - InstanciationType tcommType, - String videoId) { - this.videoType = videoType; - this.commentType = commentType; - this.tcommType = tcommType; - this.videoId = videoId; - FileGetter getter = new FileGetter(); - setVideoFileGetter(getter); - setCommentFileGetter(getter); - setTcommFileGetter(getter); - } - - /** - * @return 動画のタイトル. - * @throws FileNotFoundException ビデオタイトルの自動命名時、参考となるファイルが見つからなかった。 - */ - public String getVideoTitle() throws FileNotFoundException { - String fileName = null; - if (!videoType.isAutoFileName()) { - // 動画ファイル名を直接指定している場合は、そのファイル名を基にタイトルを取得する. - fileName = videoType.getInitFile().toString(); - } else { - // 自動命名の場合は、ディレクトリ内にあるファイルからタイトル名を類推。 - String[] files = videoType.getInitFile().list(); - if (files != null) { - for (String file : files) { - if (file.startsWith(getVideoIdWithBracket())) { - fileName = FilenameUtils.getBaseName(file); - break; - } - } - } - if (fileName == null) { - throw new FileNotFoundException(getVideoIdWithBracket() + "のファイルを特定できませんでした。"); - } - } - - String baseName = FilenameUtils.getBaseName(fileName); - int s = baseName.indexOf(getVideoIdWithBracket()); - return baseName.replace(getVideoIdWithBracket(), ""); - } - - /** - * 動画ファイルを取得します. - * @param listener 進捗通知を受け取るためのリスナ. - * @return 動画ファイル. - * @throws IOException 動画ファイルが存在しない, 取得に失敗した. - */ - public final File getVideoFile(TextProgressListener listener) throws IOException { - File file = new FileLocator(videoType.isAutoFileName(), videoType.getInitFile(), getVideoIdWithBracket(), - getVideoTitle(), ".flv", ".mp4", ".swf").getFile(); - file = videoFileGetter.get(file, listener); - return file; - } - - /** - * コメントファイルを取得します. - * @param listener 進捗通知を受け取るためのリスナ. - * @return コメントファイル. - * @throws IOException コメントファイルが存在しない, 取得に失敗した. - */ - public final File getCommentFile(TextProgressListener listener) throws IOException { - File file = new FileLocator(commentType.isAutoFileName(), commentType.getInitFile(), getVideoIdWithBracket(), - getVideoTitle(), ".xml").getFile(); - file = commentFileGetter.get(file, listener); - return file; - } - - /** - * 投稿者コメントファイルを取得します. - * @param listener 進捗通知を受け取るためのリスナ. - * @return 投稿者コメントファイル. - * @throws IOException コメントファイルが存在しない, 取得に失敗した. - */ - public final File getTcommFile(TextProgressListener listener) throws IOException { - File file = new FileLocator(tcommType.isAutoFileName(), tcommType.getInitFile(), getVideoIdWithBracket(), - getVideoTitle(), ".xml").getFile(); - file = tcommFileGetter.get(file, listener); - return file; - } - - private String getVideoIdWithBracket() { - return "[" + videoId + "]"; - } - - public static class InstanciationType { - - private final boolean download; - private final boolean autoFileName; - private final File initFile; - - /** - * ファイルをインスタンス化する方法を指定するクラス. - */ - public InstanciationType(InputFileSetting fileSetting) { - this.download = fileSetting.isDownload(); - this.autoFileName = !fileSetting.getFile().isFile(); - this.initFile = fileSetting.getFile().getFile(); - } - - public boolean isDownload() { - return download; - } - - public File getInitFile() { - return initFile; - } - - public boolean isAutoFileName() { - return autoFileName; - } - } - - public static class CommentInstanciationType extends InstanciationType { - - private final boolean autoCommentNum; - private final int backComment; - private final boolean reduceComment; - - public CommentInstanciationType(InputFileSetting fileSetting, boolean autoCommentNum, int backComment, - boolean reduceComment) { - super(fileSetting); - this.autoCommentNum = autoCommentNum; - this.backComment = backComment; - this.reduceComment = reduceComment; - } - - public boolean isAutoCommentNum() { - return autoCommentNum; - } - - public int getBackComment() { - return backComment; - } - - boolean isReduceComment() { - return reduceComment; - } - } -} diff --git a/frontend/src/saccubus/converter/filegetter/FileLocator.java b/frontend/src/saccubus/converter/filegetter/FileLocator.java deleted file mode 100644 index 54f4f32..0000000 --- a/frontend/src/saccubus/converter/filegetter/FileLocator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* $Id$ */ -package saccubus.converter.filegetter; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * - * @author yuki - */ -class FileLocator { - - private final boolean autoFileName; - private final File initFile; - private final String prefix; - private final String title; - private final String[] suffixes; - - FileLocator(boolean autoFileName, File initFile, String prefix, String title, String... suffixes) { - this.autoFileName = autoFileName; - this.initFile = initFile; - this.prefix = prefix; - this.title = title; - this.suffixes = suffixes; - } - - /** - * コンストラクタで指定した条件でファイルを検索する。 - * autoFileNameがfalseの場合、直接名前指定であるため指定されたファイルをそのまま返す。 - * autoFileNameがtrueの場合、initFileディレクトリにprefixで始まりsuffixで終わるファイルが存在するか検索し - * あればそれを返す。 - * このファイルも無い場合、指定されたパラメータに従ったファイル名を返す。 - * このとき拡張子(suffixes)が複数指定されていた場合は最初のものを返す。 - * @return 所望のファイル。ファイルは存在する場合もあり、存在しない場合もあることに注意。 - */ - File getFile() { - if (!isAutoNaming()) { - return initFile; - } else { - File res = searchFile(); - if (res != null) { - return res; - } - return new File(initFile, prefix + title + suffixes[0]); - } - } - - private File searchFile() { - FilenameFilter filter = new FilenameFilter() { - - @Override - public boolean accept(File dir, String name) { - if (name.startsWith(prefix)) { - for (String suffix : suffixes) { - if (name.endsWith(suffix)) { - return true; - } - } - } - return false; - } - }; - File[] res = initFile.listFiles(filter); - if (res == null || res.length == 0) { - return null; - } - if (res.length > 1) { - final String message = "複数の候補ファイルがヒットしました. 意図しないファイルが選択されている可能性があります:" - + res[0]; - Logger.getLogger(FileLocator.class.getName()).log(Level.WARNING, message); - } - return res[0]; - } - - protected boolean isAutoNaming() { - return autoFileName; - } - - protected final boolean getAutoFileName() { - return autoFileName; - } -} diff --git a/frontend/src/saccubus/converter/filegetter/TcommFileWebGetter.java b/frontend/src/saccubus/converter/filegetter/TcommFileWebGetter.java deleted file mode 100644 index 57a4b5f..0000000 --- a/frontend/src/saccubus/converter/filegetter/TcommFileWebGetter.java +++ /dev/null @@ -1,39 +0,0 @@ -package saccubus.converter.filegetter; - -import java.io.File; -import java.io.IOException; -import saccubus.net.NicoClient; -import saccubus.net.TextProgressListener; -import saccubus.net.VideoInfo; - -/** - * - * @author yuki - */ -class TcommFileWebGetter extends FileGetter { - - private final NicoClient client; - private final VideoInfo videoInfo; - - protected final NicoClient getClient() { - return client; - } - - protected final VideoInfo getVideoInfo() { - return videoInfo; - } - - TcommFileWebGetter(NicoClient client, VideoInfo vi) { - this.client = client; - this.videoInfo = vi; - } - - @Override - public File get(File file, TextProgressListener listener) throws IOException { - File res = getClient().getTcomment(videoInfo, file, listener); - if (res == null) { - throw new IOException("投稿者コメントファイルのダウンロードに失敗しました"); - } - return res; - } -} diff --git a/frontend/src/saccubus/converter/filegetter/VideoFileWebGetter.java b/frontend/src/saccubus/converter/filegetter/VideoFileWebGetter.java deleted file mode 100644 index ac051ed..0000000 --- a/frontend/src/saccubus/converter/filegetter/VideoFileWebGetter.java +++ /dev/null @@ -1,32 +0,0 @@ -package saccubus.converter.filegetter; - -import java.io.File; -import java.io.IOException; -import saccubus.net.NicoClient; -import saccubus.net.TextProgressListener; -import saccubus.net.VideoInfo; - -/** - * - * @author yuki - */ -public class VideoFileWebGetter extends FileGetter { - - private final NicoClient client; - private final VideoInfo videoInfo; - - VideoFileWebGetter(NicoClient client, VideoInfo videoInfo) { - this.client = client; - this.videoInfo = videoInfo; - } - - @Override - File get(File file, TextProgressListener listener) throws IOException { - listener.setText("動画のダウンロード開始中"); - File res = client.getVideo(videoInfo, file, listener); - if (res == null) { - throw new IOException("動画ファイルのダウンロードに失敗しました。"); - } - return res; - } -} diff --git a/frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java b/frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java deleted file mode 100644 index 730c151..0000000 --- a/frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java +++ /dev/null @@ -1,107 +0,0 @@ -/* $Id$ */ -package saccubus.converter.filegetter; - -import java.io.IOException; -import java.text.Normalizer; -import org.apache.commons.lang.StringUtils; -import saccubus.ConvertStopFlag; -import saccubus.net.CommentInfo; -import saccubus.net.NicoClient; -import saccubus.net.VideoInfo; -import saccubus.util.WayBackTimeParser; -import yukihane.inqubus.saccubus_adapter.NicoBrowserAdapter; -import yukihane.saccubus.converter.profile.ProxyProfile; -import yukihane.saccubus.converter.profile.LoinProfile; - -/** - * 動画ファイル, コメントファイルなど必要なファイルのうち, 1つでもダウンロード処理を必要とする場合のインスタンス化クラス. - * @author yuki - */ -public class WebFileInstanciator extends FileInstanciator { - - private final NicoClient client; - private final VideoInfo videoInfo; - private final CommentInfo commentInfo; - - WebFileInstanciator( - ConvertStopFlag stopFlag, - InstanciationType videoType, - CommentInstanciationType commentType, - InstanciationType tcommType, - LoinProfile li, - ProxyProfile proxy, - String tag, - long time) throws IOException { - super(videoType, commentType, tcommType, tag); - - if (li.getMail() == null || li.getPass() == null || li.getMail().equals("") || li.getPass().equals("")) { - throw new IllegalArgumentException("メールアドレスかパスワードが空白です。"); - } - - String host; - int port; - if (proxy.use()) { - host = proxy.getHost(); - port = proxy.getPort(); - } else { - host = null; - port = -1; - } - client = new NicoBrowserAdapter(li.getMail(), li.getPass(), stopFlag, host, port) { - }; - - if (!client.isLoggedIn()) { - throw new IOException("ログインに失敗"); - } - - try { - videoInfo = client.getVideoInfo(tag); - if (time >= 0) { - System.out.print("Setting wayback time..."); - final long waybacktime = time; - String waybackkey = client.getWayBackKey(videoInfo); - commentInfo = new CommentInfo(waybackkey, waybacktime); - } else { - commentInfo = null; - } - - } catch (IOException ex) { - final String text = tag + "の情報の取得に失敗"; - final String cause = (ex.getMessage() != null) ? "(" + ex.getMessage() + ")" : ""; - - throw new IOException(text + cause, ex); - } - - if (videoType.isDownload()) { - setVideoFileGetter(new VideoFileWebGetter(client, videoInfo)); - } - - if (commentType.isDownload()) { - setCommentFileGetter(new CommentFileWebGetter(client, videoInfo, commentInfo, commentType.isAutoCommentNum(), - commentType.getBackComment(), commentType.isReduceComment())); - } - - if (tcommType.isDownload()) { - setTcommFileGetter(new TcommFileWebGetter(client, videoInfo)); - } - } - - /** - * 動画のタイトルを取得する。 - * 実際の動画タイトルはファイル名に用いることが出来ない文字を含んである場合があるため、ファイル名に適合するように編集した値が返る。 - * @return - */ - @Override - public String getVideoTitle() { - String name = videoInfo.getVideoTitle(); - name = Normalizer.normalize(name, Normalizer.Form.NFKC); - name = name.replaceAll("[\\\\/:*?\"<>|.]", "_"); - name = name.replace('\u2212', '\uff0d'); // - U+2212(MINUS SIGN) -> U+FF0D(FULLWIDTH HYPHEN-MINUS) - name = name.replace('\u301c', '\uff5e'); // ~ U+301C(WAVE DASH) -> U+FF5E(FULLWIDTH TILDE) - name = name.replace('\u223c', '\uff5e'); // ~ U+223C(TILDE OPERATOR) -> U+FF5E(FULLWIDTH TILDE) - name = name.replace('\u00a2', '\uffe0'); // ¢ U+00A2(CENT SIGN) -> U+FFE0(FULLWIDTH CENT SIGN) - name = name.replace('\u00a3', '\uffe1'); // £ U+00A3(POUND SIGN) -> U+FFE1(FULLWIDTH POUND SIGN) - name = name.replace('\u00ac', '\uffe2'); // ¬ U+00AC(NOT SIGN) -> U+FFE2(FULLWIDHT NOT SIGN) - return name; - } -} diff --git a/frontend/src/saccubus/prompt/Prompt.java b/frontend/src/saccubus/prompt/Prompt.java index ab08d42..043863b 100644 --- a/frontend/src/saccubus/prompt/Prompt.java +++ b/frontend/src/saccubus/prompt/Prompt.java @@ -24,8 +24,6 @@ import saccubus.converter.classic.profile.GeneralSetting; import saccubus.converter.classic.profile.InputFileSetting; import saccubus.converter.classic.profile.OutputFileSetting; import saccubus.converter.classic.profile.Profile; -import saccubus.converter.classic.profile.SFile; -import saccubus.properties.SProperties; import saccubus.net.TextProgressListener; /** @@ -118,40 +116,43 @@ public class Prompt { } private Profile createExecuteOption(CommandLine cmd) throws IOException { - final String mail = "dmy"; - final String pass = "dmy"; - final String video = cmd.getOptionValue("file_video"); - final String comm = cmd.getOptionValue("file_comment"); - final String tcomm = cmd.getOptionValue("file_tcomment"); - final String output = cmd.getOptionValue("file_output"); - final String ff = cmd.getOptionValue("ffmpeg"); - - SProperties setting = SProperties.loadSetting(mail, pass); - Profile p = setting.toProfile(); - GeneralSetting general = p.getGeneralSetting(); - LoginInfo loginInfo = p.getLoginInfo(); -// InputFileSetting videoSetting = p.getVideoSetting(); -// InputFileSetting commentSetting = p.getCommentSetting(); - CommentGetInfo commentGetInfo = p.getCommentGetInfo(); -// InputFileSetting tcommentSetting = p.getTcommentSetting(); -// OutputFileSetting outputFileSetting = p.getOutputFileSetting(); - Ffmpeg ffmpeg = p.getFfmpeg(); - - FfmpegOption newFfmpegOption = new FfmpegOption(ffmpeg.getFfmpegOption().getExtOption(), "", "", ff, "", false, - "", "", false); - InputFileSetting newVideoSetting = new InputFileSetting(new SFile(true, new File(video)), false, false, commentGetInfo, -1); - InputFileSetting newCommentSetting = new InputFileSetting(new SFile(true, new File(comm)), false, false, commentGetInfo, -1); - InputFileSetting newTcommentSetting = new InputFileSetting(new SFile(true, new File(tcomm)), false, false, commentGetInfo, -1); - OutputFileSetting newOutputFileSetting = new OutputFileSetting(new SFile(true, new File(output)), true, false, - true, true); - Ffmpeg newFfmpeg = new Ffmpeg(ffmpeg.getFfmpeg(), ffmpeg.getVhook(), newFfmpegOption, ffmpeg.isVhookDisabled(), ffmpeg. - getMaxNumOfComment(), ffmpeg.getFont(), ffmpeg.getFontIndex(), ffmpeg.getShadowIndex(), ffmpeg. - isShowConverting(), ffmpeg.isSelfAdjustFontSize(), ffmpeg.isCommentOpaque(), ffmpeg.getNgSetting()); - - p = new Profile(general, loginInfo, newVideoSetting, newCommentSetting, commentGetInfo, newTcommentSetting, - newOutputFileSetting, newFfmpeg); - - return p; +// final String mail = "dmy"; +// final String pass = "dmy"; +// final String video = cmd.getOptionValue("file_video"); +// final String comm = cmd.getOptionValue("file_comment"); +// final String tcomm = cmd.getOptionValue("file_tcomment"); +// final String output = cmd.getOptionValue("file_output"); +// final String ff = cmd.getOptionValue("ffmpeg"); +// +// // TODO 後で実装 +//// SProperties setting = SProperties.loadSetting(mail, pass); +//// Profile p = setting.toProfile(); +// Profile p = null; +// GeneralSetting general = p.getGeneralSetting(); +// LoginInfo loginInfo = p.getLoginInfo(); +//// InputFileSetting videoSetting = p.getVideoSetting(); +//// InputFileSetting commentSetting = p.getCommentSetting(); +// CommentGetInfo commentGetInfo = p.getCommentGetInfo(); +//// InputFileSetting tcommentSetting = p.getTcommentSetting(); +//// OutputFileSetting outputFileSetting = p.getOutputFileSetting(); +// Ffmpeg ffmpeg = p.getFfmpeg(); +// +// FfmpegOption newFfmpegOption = new FfmpegOption(ffmpeg.getFfmpegOption().getExtOption(), "", "", ff, "", false, +// "", "", false); +// InputFileSetting newVideoSetting = new InputFileSetting(new SFile(true, new File(video)), false, false, commentGetInfo, -1); +// InputFileSetting newCommentSetting = new InputFileSetting(new SFile(true, new File(comm)), false, false, commentGetInfo, -1); +// InputFileSetting newTcommentSetting = new InputFileSetting(new SFile(true, new File(tcomm)), false, false, commentGetInfo, -1); +// OutputFileSetting newOutputFileSetting = new OutputFileSetting(new SFile(true, new File(output)), true, false, +// true, true); +// Ffmpeg newFfmpeg = new Ffmpeg(ffmpeg.getFfmpeg(), ffmpeg.getVhook(), newFfmpegOption, ffmpeg.isVhookDisabled(), ffmpeg. +// getMaxNumOfComment(), ffmpeg.getFont(), ffmpeg.getFontIndex(), ffmpeg.getShadowIndex(), ffmpeg. +// isShowConverting(), ffmpeg.isSelfAdjustFontSize(), ffmpeg.isCommentOpaque(), ffmpeg.getNgSetting()); +// +// p = new Profile(general, loginInfo, newVideoSetting, newCommentSetting, commentGetInfo, newTcommentSetting, +// newOutputFileSetting, newFfmpeg); +// +// return p; + return null; } /** @@ -162,8 +163,11 @@ public class Prompt { String pass = args[1]; String tag = args[2]; String time = args.length < 4 ? "" : args[3]; - SProperties setting = SProperties.loadSetting(mail, pass); - Converter conv = new Converter(tag, setting.toProfile(), TextProgressListener.EMPTY_LISTENER, new ConvertStopFlag( + // TODO +// SProperties setting = SProperties.loadSetting(mail, pass); +// Converter conv = new Converter(tag, setting.toProfile(), TextProgressListener.EMPTY_LISTENER, new ConvertStopFlag( +// ConvertStopFlag.StateChangeListener.EMPTY_LISTENER)); + Converter conv = new Converter(tag, null/*この部分*/, TextProgressListener.EMPTY_LISTENER, new ConvertStopFlag( ConvertStopFlag.StateChangeListener.EMPTY_LISTENER)); System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"); System.out.println("Saccubus on CUI"); diff --git a/frontend/src/saccubus/properties/SProperties.java b/frontend/src/saccubus/properties/SProperties.java deleted file mode 100644 index 66ab194..0000000 --- a/frontend/src/saccubus/properties/SProperties.java +++ /dev/null @@ -1,280 +0,0 @@ -package saccubus.properties; - -import java.io.File; -import java.util.Properties; -import java.io.IOException; -import java.io.FileOutputStream; -import java.io.FileInputStream; -import java.util.logging.Level; -import java.util.logging.Logger; -import saccubus.VideoSaveKind; -import saccubus.converter.classic.profile.LoginInfo; -import saccubus.converter.classic.profile.CommentGetInfo; -import saccubus.converter.classic.profile.Ffmpeg; -import saccubus.converter.classic.profile.FfmpegOption; -import saccubus.converter.classic.profile.GeneralSetting; -import saccubus.converter.classic.profile.InputFileSetting; -import saccubus.converter.classic.profile.OutputFileSetting; -import saccubus.converter.classic.profile.Profile; -import saccubus.converter.classic.profile.Proxy; -import saccubus.converter.classic.profile.SFile; - -/** - *

- * タイトル: さきゅばす - *

- * - *

- * 説明: ニコニコ動画の動画をコメントつきで保存 - *

- * - *

- * 著作権: Copyright (c) 2007 PSI - *

- * - *

- * 会社名: - *

- * - * @author 未入力 - * @version 1.0 - */ -public class SProperties { - - private static final String PROP_FILE = "./saccubus.xml"; - public static final String[] ShadowKindArray = { - "00:なし", - "01:ニコニコ動画風", - "02:右下", - "03:囲い込み" - }; - private final BasicSetting basicSetting; - private final InputVideoSetting inputVideoSetting; - private final InputCommentSetting inputCommentSetting; - private final InputTcommentSetting inputTcommentSetting; - private final OutputVideoSetting outputVideoSetting; - private final MovieSetting movieSetting; - private final ConvertSetting convertSetting; - - public SProperties( - BasicSetting basicSetting, - InputVideoSetting inputVideoSetting, - InputCommentSetting inputCommentSetting, - InputTcommentSetting tcommentSetting, - OutputVideoSetting outputVideoSetting, - MovieSetting movieSetting, - ConvertSetting convertSetting // String videoshownum, - ) { -// this.saveVideo = savevideo; -// if (videofile.lastIndexOf(".") < videofile.lastIndexOf("\\")) { -// videofile += ".flv"; -// } -// VideoFile = new File(videofile); - -// if (commentfile.lastIndexOf(".") < commentfile.lastIndexOf("\\")) { -// commentfile += ".xml"; -// } -// CommentFile = new File(commentfile); - -// if (convvideofile.lastIndexOf(".") < convvideofile.lastIndexOf("\\")) { -// convvideofile += ".avi"; -// } - - this.basicSetting = basicSetting; - this.inputVideoSetting = inputVideoSetting; - this.inputCommentSetting = inputCommentSetting; - this.inputTcommentSetting = tcommentSetting; - this.outputVideoSetting = outputVideoSetting; - this.movieSetting = movieSetting; - this.convertSetting = convertSetting; - } - - public Profile toProfile() throws IOException { - return new ProfileBuilder().build(); - } - - private class ProfileBuilder { - - private Profile build() throws IOException { - GeneralSetting generalSetting = buildGeneralSetting(); - LoginInfo loginInfo = buildLoginInfo(); - InputFileSetting videoSetting = buildVideoSetting(); - InputFileSetting commentSetting = buildCommentSetting(); - CommentGetInfo commentGetInfo = buildCommentGetInfo(); - InputFileSetting tcommentSetting = buildTcommentSetting(); - OutputFileSetting outputFileSetting = buildOutputFileSetting(); - Ffmpeg ffmpeg = buildFfmpeg(); - - return new Profile(generalSetting, loginInfo, videoSetting, commentSetting, commentGetInfo, tcommentSetting, - outputFileSetting, ffmpeg); - } - - private GeneralSetting buildGeneralSetting() { - final BasicSetting basic = getBasicSetting(); - return new GeneralSetting(basic.getTempDir()); - } - - private LoginInfo buildLoginInfo() { - final BasicSetting basic = getBasicSetting(); - Proxy proxy = Proxy.NO_PROXY; - if (basic.isProxyUse()) { - proxy = new Proxy(basic.getProxyHost(), basic.getProxyPort()); - } - final LoginInfo loginInfo = new LoginInfo(basic.getUser().getMail(), basic.getUser().getPassword(), proxy); - return loginInfo; - } - - private InputFileSetting buildVideoSetting() { - final InputVideoSetting setting = getInputVideoSetting(); - // Nicobrowserダウンロードファイルの場合は常にファイル指定. - final boolean isFile = (!setting.isAutoNaming() || setting.getProcessKind() == VideoSaveKind.NICOBROWSER); - File video; - if (setting.getProcessKind() == VideoSaveKind.NICOBROWSER) { - video = setting.getNicoBrowserFile(); - } else { - if (setting.isAutoNaming()) { - video = setting.getFolder(); - } else { - video = setting.getFile(); - } - } - final SFile videoFile = new SFile(isFile, video); - // Nicobrowserダウンロードファイルは削除対象にならない. - boolean delete = setting.isDeleteAfterConvert() && (setting.getProcessKind() != VideoSaveKind.NICOBROWSER); - - return new InputFileSetting(videoFile, (setting.getProcessKind() == VideoSaveKind.SAVE), delete, - buildCommentGetInfo(), inputCommentSetting.getBackLogPoint()); - } - - private InputFileSetting buildCommentSetting() { - return createCommentSetting(getInputCommentSetting()); - } - - private CommentGetInfo buildCommentGetInfo() { - final InputCommentSetting setting = getInputCommentSetting(); - return new CommentGetInfo(setting.isSelfAdjustNumOfComment(), setting.getNumOfComment(), setting. - isReduceComment()); - } - - private InputFileSetting buildTcommentSetting() { - return createCommentSetting(getInputTcommentSetting()); - } - - private InputFileSetting createCommentSetting(saccubus.properties.InputFileSetting setting) { - SFile file = createSFile(setting); - - return new InputFileSetting(file, setting.getProcessKind().booleanValue(), setting.isDeleteAfterConvert(), - buildCommentGetInfo(), inputCommentSetting.getBackLogPoint()); - - } - - private SFile createSFile(ProcessFileSetting setting) { - File f; - if (setting.isAutoNaming()) { - f = setting.getFolder(); - } else { - f = setting.getFile(); - } - final SFile file = new SFile(!setting.isAutoNaming(), f); - return file; - } - - private OutputFileSetting buildOutputFileSetting() { - final OutputVideoSetting setting = getOutputVideoSetting(); - - SFile file = createSFile(setting); - return new OutputFileSetting(file, setting.getProcessKind().booleanValue(), !setting.isCutIdName(), setting. - isAddComment(), setting.isAddTcomment()); - } - - private Ffmpeg buildFfmpeg() throws IOException { - final MovieSetting movie = getMovieSetting(); - final ConvertSetting conv = getConvertSetting(); - - FfmpegOption fo = movie.getFfmpegOption(); - if (movie.getOptionFile() != null) { - try { - fo = FfmpegOption.load(movie.getOptionFile()); - } catch (IOException ex) { - throw new IOException("オプションファイルの書式が誤っています:" + movie.getOptionFile().getName(), ex); - } - } - - return new Ffmpeg( - movie.getFfmpeg(), - movie.getVhook(), - fo, - conv.isVhookDisabled(), - conv.getMaxNumOfComment(), - conv.getFont(), - conv.getFontIndex(), - conv.getShadowIndex(), - conv.isShowConverting(), - conv.isSelfAdjustFontSize(), - conv.isCommentOpaque(), - conv.getNgSetting()); - } - } - - public static void saveSetting(SProperties setting) { - final Properties prop = new Properties(); - setting.getBasicSetting().save(prop); - setting.getInputVideoSetting().save(prop); - setting.getInputCommentSetting().save(prop); - setting.getInputTcommentSetting().save(prop); - setting.getOutputVideoSetting().save(prop); - setting.getMovieSetting().save(prop); - setting.getConvertSetting().save(prop); - try { - prop.storeToXML(new FileOutputStream(PROP_FILE), "settings"); - } catch (IOException ex) { - Logger.getLogger(SProperties.class.getName()).log(Level.SEVERE, "コンフィグファイルの保存に失敗", ex); - } - } - - public static SProperties loadSetting(String user, String password) { - Properties prop = new Properties(); - try { - prop.loadFromXML(new FileInputStream(PROP_FILE)); - } catch (IOException ex) { - Logger.getLogger(SProperties.class.getName()).log(Level.INFO, "コンフィグファイルが存在しないため自動生成します", ex); - } - - return new SProperties( - BasicSetting.load(prop, user, password), - InputVideoSetting.load(prop), - InputCommentSetting.load(prop), - InputTcommentSetting.load(prop), - OutputVideoSetting.load(prop), - MovieSetting.load(prop), - ConvertSetting.load(prop)); - } - - public BasicSetting getBasicSetting() { - return basicSetting; - } - - public InputVideoSetting getInputVideoSetting() { - return inputVideoSetting; - } - - public InputCommentSetting getInputCommentSetting() { - return inputCommentSetting; - } - - public InputTcommentSetting getInputTcommentSetting() { - return inputTcommentSetting; - } - - public OutputVideoSetting getOutputVideoSetting() { - return outputVideoSetting; - } - - public MovieSetting getMovieSetting() { - return movieSetting; - } - - public ConvertSetting getConvertSetting() { - return convertSetting; - } -} diff --git a/frontend/src/yukihane/saccubus/converter/profile/InputFileSetting.java b/frontend/src/yukihane/saccubus/converter/profile/InputFileSetting.java deleted file mode 100644 index 844af7a..0000000 --- a/frontend/src/yukihane/saccubus/converter/profile/InputFileSetting.java +++ /dev/null @@ -1,12 +0,0 @@ -package yukihane.saccubus.converter.profile; - -/** - * - * @author yuki - */ -public interface InputFileSetting { - - SFile getFile(); - - boolean isDownload(); -} diff --git a/frontend/src/yukihane/saccubus/converter/profile/OutputProfile.java b/frontend/src/yukihane/saccubus/converter/profile/OutputProfile.java index 701a757..7704a88 100644 --- a/frontend/src/yukihane/saccubus/converter/profile/OutputProfile.java +++ b/frontend/src/yukihane/saccubus/converter/profile/OutputProfile.java @@ -13,8 +13,6 @@ public interface OutputProfile { boolean isAddTcomment(); - SFile getFile(); - public File getDir(); public String getFileName(); diff --git a/frontend/src/yukihane/saccubus/converter/profile/SFile.java b/frontend/src/yukihane/saccubus/converter/profile/SFile.java deleted file mode 100644 index 952ad8c..0000000 --- a/frontend/src/yukihane/saccubus/converter/profile/SFile.java +++ /dev/null @@ -1,14 +0,0 @@ -package yukihane.saccubus.converter.profile; - -import java.io.File; - -/** - * - * @author yuki - */ -public interface SFile { - - boolean isFile(); - - File getFile(); -} diff --git a/frontend/test/saccubus/SaccubusTest.java b/frontend/test/saccubus/SaccubusTest.java deleted file mode 100644 index c0786a3..0000000 --- a/frontend/test/saccubus/SaccubusTest.java +++ /dev/null @@ -1,643 +0,0 @@ -/*$Id$*/ -package saccubus; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import javax.swing.JFrame; -import mockit.Mock; -import mockit.MockClass; -import mockit.Mockit; -import mockit.integration.junit4.JMockit; -import static org.fest.assertions.Assertions.*; -import org.fest.reflect.core.Reflection; -import org.fest.swing.fixture.JFileChooserFixture; -import org.fest.swing.keystroke.KeyStrokeMappingProvider; -import static org.fest.swing.launcher.ApplicationLauncher.application; -import org.fest.swing.core.BasicRobot; -import org.fest.swing.core.Robot; -import org.fest.swing.finder.JFileChooserFinder; -import org.fest.swing.finder.WindowFinder; -import org.fest.swing.fixture.FrameFixture; -import org.fest.swing.keystroke.KeyStrokeMap; -import org.fest.swing.keystroke.KeyStrokeMappingsParser; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import saccubus.properties.SProperties; -import static org.junit.Assert.*; - -/** - * - * @author yuki - */ -@RunWith(JMockit.class) -public class SaccubusTest { - - private static Robot robot; - private static FrameFixture window; - - @Before - public void setUp() throws IOException { - KeyStrokeMappingsParser parser = new KeyStrokeMappingsParser(); - KeyStrokeMappingProvider provider = parser.parse("fest-swing_mapping.txt"); - KeyStrokeMap.addKeyStrokesFrom(provider); - - robot = BasicRobot.robotWithNewAwtHierarchy(); - application(saccubus.Saccubus.class).start(); - window = WindowFinder.findFrame(JFrame.class).using(robot); - } - - @After - public void tearDown() { - robot.cleanUp(); - } - - private SProperties getProperties() { - return Reflection.method("getSetting").withReturnType(SProperties.class).in(window.component()).invoke(); - } - - @Test - public void testConfigSave() throws Exception { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - SProperties.saveSetting(getProperties()); - } - - @Test - public void testMailAddress() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("基本設定"); - window.textBox("mailAddressField").enterText("mail@example.com"); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testPassword() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("基本設定"); - window.textBox("passwordField").enterText("pass word input"); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testUseProxy() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("基本設定"); - window.checkBox("useProxyCheckBox").check(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("基本設定"); - window.checkBox("useProxyCheckBox").uncheck(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testProxyHost() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("基本設定"); - window.textBox("proxyTextField").enterText("proxy.example.com"); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testProxyPort() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("基本設定"); - window.textBox("proxyPortTextField").enterText("8090"); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testMovieSouce() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力動画"); - window.radioButton("videoUseNiBrButton").check(); - window.textBox("nibrFileField").enterText("nibr_file.mp4"); - window.radioButton("videoNoSaveButton").check(); - window.checkBox("delVideoCheckBox").click(); - window.textBox("videoSavedFolderField").selectAll().enterText("C:\\works\\"); - window.textBox("videoSavedFileField").selectAll().enterText("C:\\movie_file.flv"); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力動画"); - window.radioButton("videoSaveButton").check(); - window.checkBox("delVideoCheckBox").click(); - window.textBox("videoSavedFolderField").selectAll().enterText("C:\\works\\movie"); - window.textBox("videoSavedFileField").selectAll().enterText("C:\\movie_file\\file.flv"); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力動画"); - window.checkBox("delVideoCheckBox").click(); - window.textBox("videoSavedFolderField").deleteText(); - window.textBox("videoSavedFileField").deleteText(); - window.radioButton("videoUseNiBrButton").check(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testMovieSouce2() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力動画"); - window.radioButton("saveFolderRadioButton").check(); - window.textBox("videoSavedFolderField").selectAll().enterText("folder\\"); - window.textBox("videoSavedFileField").selectAll().enterText("file.flv"); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力動画"); - window.radioButton("saveFileRadioButton").check(); - window.textBox("videoSavedFolderField").selectAll().enterText("folder1\\folder2\\"); - window.textBox("videoSavedFileField").selectAll().enterText("folder\\file.flv"); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testMovieSourceFolderButton() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力動画"); - window.button("showSavingVideoFolderDialogButton").click(); - JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot); - File folder = new File("F:\\docs\\NetBeansProjects"); - chooser.selectFile(folder).approve(); - assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("videoSavedFolderField").text()); - } - - @Test - public void testMovieSourceFileButton() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力動画"); - window.button("showSavingVideoFileDialogButton").click(); - JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot); - File folder = new File("F:\\docs\\NetBeansProjects\\saccubus_frontend\\out\\movie\\aa.flv"); - chooser.selectFile(folder).approve(); - assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("videoSavedFileField").text()); - } - - @Test - public void testDownloadComment() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.checkBox("savingCommentCheckBox").check(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.checkBox("savingCommentCheckBox").uncheck(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testDeleteComment() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.checkBox("delCommentCheckBox").check(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.checkBox("delCommentCheckBox").uncheck(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testCommentDownloadNum() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.checkBox("fixCommentNumCheckBox").check(); - window.textBox("commentNumField").selectAll().enterText("100"); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.checkBox("fixCommentNumCheckBox").uncheck(); - window.radioButton("commentSaveFolderRadioButton").check(); - window.textBox("commentNumField").deleteText(); - SProperties.saveSetting(getProperties()); - - } - - @Test - public void testCommentDownloadFolder() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.radioButton("commentSaveFolderRadioButton").check(); - window.textBox("commentSavedFolderField").selectAll().enterText("c:\\comment\\"); - window.textBox("commentSavedFileField").selectAll().enterText("c:\\comment\\file.xml"); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.radioButton("commentSaveFileRadioButton").check(); - window.textBox("commentSavedFolderField").selectAll().enterText("comment"); - window.textBox("commentSavedFileField").selectAll().enterText("file.xml"); - SProperties.saveSetting(getProperties()); - - } - - @Test - public void testCommentFolderButton() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.button("showSavingCommentFolderDialogButton").click(); - JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot); - File folder = new File("F:\\docs\\NetBeansProjects"); - chooser.selectFile(folder).approve(); - assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("commentSavedFolderField").text()); - } - - @Test - public void testCommentFileButton() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - window.button("showSavingCommentFileDialogButton").click(); - JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot); - File folder = new File("F:\\docs\\NetBeansProjects\\comment.xml"); - chooser.selectFile(folder).approve(); - assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("commentSavedFileField").text()); - } - - @Test - public void testDownloadTcomment() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - window.checkBox("needDownloadTcomment").check(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - window.checkBox("needDownloadTcomment").uncheck(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testDeleteTcomment() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - window.checkBox("delTcomment").check(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - window.checkBox("delTcomment").uncheck(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testTcommentDownloadFolder() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - window.radioButton("tcommentSaveInFolder").check(); - window.textBox("tcommentFolder").selectAll().enterText("c:\\comment\\"); - window.textBox("tcommentFile").selectAll().enterText("c:\\comment\\file.xml"); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - window.radioButton("tcommentSaveToFile").check(); - window.textBox("tcommentFolder").selectAll().enterText("comment"); - window.textBox("tcommentFile").selectAll().enterText("file.xml"); - SProperties.saveSetting(getProperties()); - - } - - @Test - public void testTcommentFolderButton() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - window.button("tcoomentFolderChooserButton").click(); - JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot); - File folder = new File("F:\\docs\\NetBeansProjects\\saccubus_frontend\\src"); - chooser.selectFile(folder).approve(); - assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("tcommentFolder").text()); - } - - @Test - public void testTcommentFileButton() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - window.button("tcommentFileChooserButton").click(); - JFileChooserFixture chooser = JFileChooserFinder.findFileChooser().using(robot); - File folder = new File("F:\\docs\\NetBeansProjects\\tcomment.xml"); - chooser.selectFile(folder).approve(); - assertThat(folder.getAbsolutePath()).isEqualTo(window.textBox("tcommentFile").text()); - } - - @Test - public void testConvertVideo() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.checkBox("savingConvertedVideoCheckBox").uncheck(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.checkBox("savingConvertedVideoCheckBox").check(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testAddComment() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.checkBox("addComment").uncheck(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.checkBox("addComment").check(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testAddTcomment() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.checkBox("addTcomment").uncheck(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.checkBox("addTcomment").check(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testNoAddId() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.checkBox("notAddVideoIdConvVideoCheckBox").uncheck(); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.checkBox("notAddVideoIdConvVideoCheckBox").check(); - SProperties.saveSetting(getProperties()); - } - - @Test - public void testConvertedVideoSavePlace() { - Mockit.setUpMocks(new MockProperties(), new MockFileOutputStream()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.radioButton("convSaveFolderRadioButton").check(); - window.textBox("convertedVideoSavedFolderField").setText("folder"); - window.textBox("convertedVideoSavedFileField").setText("converted.avi"); - SProperties.saveSetting(getProperties()); - - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - window.radioButton("convSaveFileRadioButton").check(); - window.textBox("convertedVideoSavedFolderField").setText("folder\\folder2"); - window.textBox("convertedVideoSavedFileField").setText("folder\\converted.avi"); - SProperties.saveSetting(getProperties()); - } - - @MockClass(realClass = FileOutputStream.class) - public static class MockFileOutputStream { - - public MockFileOutputStream() { - } - - @Mock - public MockFileOutputStream(String name) { - System.out.println("FileOutputStream constructor mocked."); - } - } - - @MockClass(realClass = Properties.class) - public static class MockProperties { - - private Map map = new HashMap(); - - @Mock - public void storeToXML(OutputStream os, String comment) { - System.out.println("storeToXML mocked."); - - // 基本設定 - window.tabbedPane("mainTabbedPane").selectTab("基本設定"); - // ユーザ設定 - assertThat(map.get("MailAddress")).isEqualTo(window.textBox("mailAddressField").text()); - assertThat(map.get("Password")).isEqualTo(window.textBox("passwordField").text()); - // プロキシ設定 - assertThat(Boolean.parseBoolean(map.get("UseProxy"))).isEqualTo(window.checkBox("useProxyCheckBox"). - component().isSelected()); - assertThat(map.get("Proxy")).isEqualTo(window.textBox("proxyTextField").text()); - final String port = window.textBox("proxyPortTextField").text(); - if (!"".equals(port)) { - assertThat(map.get("ProxyPort")).isEqualTo(port); - } else { - assertThat(map.get("ProxyPort")).as("ポートが空の場合には-1(無効な番号)を設定する").isEqualTo("-1"); - } - - // 保存設定 - 入力動画 - window.tabbedPane("mainTabbedPane").selectTab("保存設定"); - window.tabbedPane("saveTabbedPane").selectTab("入力動画"); - - final VideoSaveKind saveVideo = VideoSaveKind.valueOf(map.get("SaveVideoFile")); - switch (saveVideo) { - case NO_SAVE: - window.radioButton("videoNoSaveButton").requireSelected(); - window.radioButton("videoSaveButton").requireNotSelected(); - window.radioButton("videoUseNiBrButton").requireNotSelected(); - break; - case SAVE: - window.radioButton("videoNoSaveButton").requireNotSelected(); - window.radioButton("videoSaveButton").requireSelected(); - window.radioButton("videoUseNiBrButton").requireNotSelected(); - break; - case NICOBROWSER: - window.radioButton("videoNoSaveButton").requireNotSelected(); - window.radioButton("videoSaveButton").requireNotSelected(); - window.radioButton("videoUseNiBrButton").requireSelected(); - break; - default: - fail(); - } - - final boolean videoAutoNaming = Boolean.parseBoolean(map.get("VideoFixFileName")); - if (videoAutoNaming) { - window.radioButton("saveFolderRadioButton").requireSelected(); - window.radioButton("saveFileRadioButton").requireNotSelected(); - } else { - window.radioButton("saveFolderRadioButton").requireNotSelected(); - window.radioButton("saveFileRadioButton").requireSelected(); - } - - assertThat(Boolean.parseBoolean(map.get("DeleteVideoAfterConv"))).isEqualTo(window.checkBox( - "delVideoCheckBox").component().isSelected()); - assertThat(map.get("VideoFixFileNameFolder")).isEqualTo(new File(window.textBox("videoSavedFolderField"). - text()).getPath()); - assertThat(map.get("VideoFile")).isEqualTo(window.textBox("videoSavedFileField").text()); - - assertThat(map.get("NicoBrowserFileName")).isEqualTo(window.textBox("nibrFileField").text()); - - - // 保存設定 - 入力コメント - window.tabbedPane("saveTabbedPane").selectTab("入力コメント"); - - assertThat(Boolean.parseBoolean(map.get("SaveCommentFile"))).isEqualTo(window.checkBox( - "savingCommentCheckBox").component().isSelected()); - assertThat(Boolean.parseBoolean(map.get("DeleteCommentAfterConv"))).isEqualTo(window.checkBox( - "delCommentCheckBox").component().isSelected()); - assertThat(Boolean.parseBoolean(map.get("FixCommentSize"))).isEqualTo(window.checkBox( - "fixCommentNumCheckBox").component().isSelected()); - // 空だったらデフォルト値500を設定する - String backComment = (window.textBox("commentNumField").text().isEmpty()) ? "500" : window.textBox( - "commentNumField").text(); - assertThat(map.get("BackComment")).isEqualTo(backComment); - - final boolean commentAutoNaming = Boolean.parseBoolean(map.get("CommentFixFileName")); - if (commentAutoNaming) { - window.radioButton("commentSaveFolderRadioButton").requireSelected(); - window.radioButton("commentSaveFileRadioButton").requireNotSelected(); - } else { - window.radioButton("commentSaveFolderRadioButton").requireNotSelected(); - window.radioButton("commentSaveFileRadioButton").requireSelected(); - } - - assertThat(map.get("CommentFixFileNameFolder")).isEqualTo(new File(window.textBox("commentSavedFolderField"). - text()).getPath()); - assertThat(map.get("CommentFile")).isEqualTo(window.textBox("commentSavedFileField").text()); - - - // 保存設定 - 入力投稿者コメント - window.tabbedPane("saveTabbedPane").selectTab("入力投稿者コメント"); - - assertThat(Boolean.parseBoolean(map.get("TCDownload"))).isEqualTo(window.checkBox("needDownloadTcomment"). - component().isSelected()); - assertThat(Boolean.parseBoolean(map.get("TCDelete"))).isEqualTo(window.checkBox("delTcomment").component(). - isSelected()); - - final boolean tcommAutoNaming = Boolean.parseBoolean(map.get("TCAutoNaming")); - if (tcommAutoNaming) { - window.radioButton("tcommentSaveInFolder").requireSelected(); - window.radioButton("tcommentSaveToFile").requireNotSelected(); - } else { - window.radioButton("tcommentSaveInFolder").requireNotSelected(); - window.radioButton("tcommentSaveToFile").requireSelected(); - } - - assertThat(map.get("TCDirectory")).isEqualTo(window.textBox("tcommentFolder").text()); - assertThat(map.get("TCFileName")).isEqualTo(window.textBox("tcommentFile").text()); - - - // 保存設定 - 出力コメント付き動画 - window.tabbedPane("saveTabbedPane").selectTab("出力コメント付き動画"); - - assertThat(Boolean.parseBoolean(map.get("SaveConvertedFile"))).isEqualTo(window.checkBox( - "savingConvertedVideoCheckBox").component().isSelected()); - assertThat(Boolean.parseBoolean(map.get("AddComment"))).isEqualTo(window.checkBox("addComment").component(). - isSelected()); - assertThat(Boolean.parseBoolean(map.get("AddTcomment"))).isEqualTo(window.checkBox("addTcomment").component(). - isSelected()); - - final boolean convertedAutoNaming = Boolean.parseBoolean(map.get("ConvFixFileName")); - if (convertedAutoNaming) { - window.radioButton("convSaveFolderRadioButton").requireSelected(); - window.radioButton("convSaveFileRadioButton").requireNotSelected(); - } else { - window.radioButton("convSaveFolderRadioButton").requireNotSelected(); - window.radioButton("convSaveFileRadioButton").requireSelected(); - } - - assertThat(Boolean.parseBoolean(map.get("NotAddVideoIDtoConverted"))).isEqualTo(window.checkBox( - "notAddVideoIdConvVideoCheckBox").component().isSelected()); - assertThat(map.get("ConvFixFileNameFolder")).isEqualTo( - window.textBox("convertedVideoSavedFolderField").text()); - assertThat(map.get("ConvertedFile")).isEqualTo(window.textBox("convertedVideoSavedFileField").text()); - - - // 基本設定 - window.tabbedPane("mainTabbedPane").selectTab("動画設定"); - - assertThat(map.get("FFnpegPath")).isEqualTo(window.textBox("ffmpegPathField").text()); - assertThat(map.get("VhookPath")).isEqualTo(window.textBox("vhookPathField").text()); - - assertThat(map.get("CMD_EXT")).isEqualTo(window.textBox("extOptionField").text()); - assertThat(map.get("CMD_MAIN")).isEqualTo(window.textBox("mainOptionField").text()); - assertThat(map.get("CMD_IN")).isEqualTo(window.textBox("inputOptionField").text()); - assertThat(map.get("CMD_OUT")).isEqualTo(window.textBox("outputOptionField").text()); - - - // 変換設定 - window.tabbedPane("mainTabbedPane").selectTab("変換設定"); - assertThat(Boolean.parseBoolean(map.get("VhookDisabled"))).isEqualTo(window.checkBox("disableVhookCheckBox"). - component().isSelected()); - assertThat(map.get("ShowCommentNum")).isEqualTo(window.textBox("viewCommentField").text()); - assertThat(map.get("FontPath")).isEqualTo(window.textBox("fontPathField").text()); - assertThat(map.get("FontIndex")).isEqualTo(window.textBox("fontIndexField").text()); - window.comboBox("shadowComboBox").requireSelection(Integer.parseInt(map.get("ShadowIndex"))); - assertThat(Boolean.parseBoolean(map.get("ShowVideo"))).isEqualTo(window.checkBox("showConvVideoCheckBox"). - component().isSelected()); - assertThat(Boolean.parseBoolean(map.get("FixFontSize"))).isEqualTo(window.checkBox("fixFontSizeCheckBox"). - component().isSelected()); - assertThat(Boolean.parseBoolean(map.get("OpaqueComment"))).isEqualTo(window.checkBox("opaqueCommentCheckBox"). - component().isSelected()); - - assertThat(map.get("NG_Word")).isEqualTo(window.textBox("ngWordTextField").text()); - assertThat(map.get("NG_ID")).isEqualTo(window.textBox("ngIdTextField").text()); - - -//assertThat(map.get("TempDir")).isEqualTo(window. - } - - @Mock - public Object setProperty(String key, String value) { - String prev = map.put(key, value); -// assertNull(prev); - return prev; - } - } -} -- 2.11.0