*/
package yukihane.inqubus.gui;
-import static javax.swing.GroupLayout.DEFAULT_SIZE;
-import static javax.swing.GroupLayout.PREFERRED_SIZE;
-
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import javax.swing.BorderFactory;
+import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
+import static javax.swing.GroupLayout.DEFAULT_SIZE;
+import static javax.swing.GroupLayout.PREFERRED_SIZE;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
+import javax.swing.JRadioButton;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.WindowConstants;
import org.apache.commons.configuration.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import yukihane.inqubus.config.Config;
+import yukihane.inqubus.config.Config.CookieBrowser;
/**
*
public ConfigDialog(JFrame owner){
super(owner);
+ setTitle("いんきゅばす 設定");
final JTabbedPane tabbedPane = new JTabbedPane();
final JPanel pnlNetwork = new JPanel();
final JPanel pnlAccount = new JPanel();
- final JLabel lblMail = new JLabel();
fldMail = new JTextField();
fldPassword.setEchoChar('*');
- final JLabel lblPassword = new JLabel();
final JPanel pnlProxy = new JPanel();
cbProxyUse = new JCheckBox();
final JLabel lblProxyHost = new JLabel();
final JLabel lblCommentMinSizeManual = new JLabel();
final JLabel lblCommentDisplayMax = new JLabel();
final JLabel lblCommentDisplayMaxManual = new JLabel();
+ final JLabel lblCommentOwnerOnly = new JLabel();
final JPanel pnlCommentAdvanced = new JPanel();
final JLabel lblFontPath = new JLabel();
cbFontSizeArrangeDisable = new JCheckBox();
pnlAccount.setBorder(BorderFactory.createTitledBorder("アカウント"));
- lblMail.setText("ID(メールアドレス)");
-
- lblPassword.setText("パスワード");
+ final JLabel lblMail = new JLabel("ID(メールアドレス)");
+ final JLabel lblPassword = new JLabel("パスワード");
GroupLayout gl_pnlAccount = new GroupLayout(pnlAccount);
pnlAccount.setLayout(gl_pnlAccount);
- gl_pnlAccount.setHorizontalGroup(
- gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
+ gl_pnlAccount.setHorizontalGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(btnAccount)
.addGroup(gl_pnlAccount.createSequentialGroup()
.addContainerGap()
+ .addGap(10)
.addGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(lblMail)
- .addComponent(lblPassword))
+ .addComponent(lblPassword)
+ )
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(fldPassword, GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
- .addComponent(fldMail, GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE))
- .addContainerGap())
+ .addComponent(fldMail, GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
+ )
+ .addContainerGap()
+ )
);
gl_pnlAccount.setVerticalGroup(
gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(gl_pnlAccount.createSequentialGroup()
.addContainerGap()
+ .addComponent(btnAccount)
+ .addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(lblMail)
.addComponent(fldMail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
+
+ final JButton btnCookie = new JButton("...");
+ btnCookie.addActionListener(new FileChooseActionListener(this, JFileChooser.FILES_AND_DIRECTORIES, fldCookie));
+
+ final ButtonGroup grpLoginType = new ButtonGroup();
+ grpLoginType.add(btnAccount);
+ grpLoginType.add(btnLoginCookie);
+
+ final ButtonGroup grpCookie = new ButtonGroup();
+ grpCookie.add(btnCookieIe);
+ grpCookie.add(btnCookieFirefox);
+ grpCookie.add(btnCookieChrome);
+ grpCookie.add(btnCookieChromium);
+ grpCookie.add(btnCookieOpera);
+ grpCookie.add(btnCookieOther);
+
+ final JPanel pnlCookie = new JPanel();
+ pnlCookie.setBorder(BorderFactory.createTitledBorder("cookie"));
+ final GroupLayout glCookie = new GroupLayout(pnlCookie);
+ pnlCookie.setLayout(glCookie);
+ glCookie.setAutoCreateContainerGaps(true);
+ glCookie.setAutoCreateGaps(true);
+
+ glCookie.setHorizontalGroup(glCookie.createParallelGroup()
+ .addComponent(btnLoginCookie)
+ .addGroup(glCookie.createSequentialGroup()
+ .addGap(10)
+ .addGroup(glCookie.createParallelGroup()
+ .addComponent(btnCookieIe)
+ .addComponent(btnCookieFirefox)
+ .addComponent(btnCookieChrome)
+ .addComponent(btnCookieChromium)
+ .addComponent(btnCookieOpera)
+ .addComponent(btnCookieOther)
+ .addGroup(glCookie.createSequentialGroup()
+ .addComponent(fldCookie)
+ .addComponent(btnCookie)
+ )
+ )
+ )
+ );
+
+ glCookie.setVerticalGroup(glCookie.createSequentialGroup()
+ .addComponent(btnLoginCookie)
+ .addComponent(btnCookieIe)
+ .addComponent(btnCookieFirefox)
+ .addComponent(btnCookieChrome)
+ .addComponent(btnCookieChromium)
+ .addComponent(btnCookieOpera)
+ .addComponent(btnCookieOther)
+ .addGroup(glCookie.createParallelGroup(Alignment.BASELINE)
+ .addComponent(fldCookie)
+ .addComponent(btnCookie)
+ )
+ );
+
+
pnlProxy.setBorder(BorderFactory.createTitledBorder("プロキシ"));
cbProxyUse.setText("プロキシを使用する");
.addGroup(gl_pnlProxy.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(lblProxyPort)
.addComponent(fldProxyPort, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addContainerGap(39, Short.MAX_VALUE))
+ .addContainerGap())
);
+
GroupLayout gl_pnlNetwork = new GroupLayout(pnlNetwork);
pnlNetwork.setLayout(gl_pnlNetwork);
gl_pnlNetwork.setHorizontalGroup(
.addGroup(GroupLayout.Alignment.TRAILING, gl_pnlNetwork.createSequentialGroup()
.addContainerGap()
.addGroup(gl_pnlNetwork.createParallelGroup(GroupLayout.Alignment.TRAILING)
+ .addComponent(pnlAccount, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(pnlCookie, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlProxy, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(pnlAccount, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ )
.addContainerGap())
);
gl_pnlNetwork.setVerticalGroup(
.addContainerGap()
.addComponent(pnlAccount, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(pnlCookie, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(pnlProxy, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(178, Short.MAX_VALUE))
+ .addContainerGap()
+ )
);
tabbedPane.addTab("ネットワーク", pnlNetwork);
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
- final JPanel pnlFileProhibit = new JPanel();
- pnlFileProhibit.setBorder(BorderFactory.createTitledBorder("禁則文字"));
- final JLabel lblReplaceFrom = new JLabel("置換対象文字");
- final JLabel lblReplaceTo = new JLabel("置換後文字");
-
- final GroupLayout glProhibit = new GroupLayout(pnlFileProhibit);
- glProhibit.setAutoCreateContainerGaps(true);
- glProhibit.setAutoCreateGaps(true);
- pnlFileProhibit.setLayout(glProhibit);
-
- glProhibit.setHorizontalGroup(glProhibit.createSequentialGroup()
- .addGroup(glProhibit.createParallelGroup()
- .addComponent(lblReplaceFrom)
- .addComponent(lblReplaceTo)
- )
- .addGroup(glProhibit.createParallelGroup()
- .addComponent(fldReplaceFrom)
- .addComponent(fldReplaceTo)
- )
- );
-
- glProhibit.setVerticalGroup(glProhibit.createSequentialGroup()
- .addGroup(glProhibit.createParallelGroup(Alignment.BASELINE)
- .addComponent(lblReplaceFrom)
- .addComponent(fldReplaceFrom)
- )
- .addGroup(glProhibit.createParallelGroup(Alignment.BASELINE)
- .addComponent(lblReplaceTo)
- .addComponent(fldReplaceTo)
- )
- );
-
GroupLayout gl_pnlFile = new GroupLayout(pnlFile);
pnlFile.setLayout(gl_pnlFile);
gl_pnlFile.setHorizontalGroup(
.addComponent(pnlFileOutput, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlFileVideo, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlFileComment, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(pnlFileProhibit, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
)
.addContainerGap())
);
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(pnlFileOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(pnlFileProhibit, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
lblCommentDisplayMaxManual.setText("手動設定");
+ lblCommentOwnerOnly.setText("取得するコメントの種類");
+
GroupLayout gl_pnlCommentStandard = new GroupLayout(pnlCommentStandard);
pnlCommentStandard.setLayout(gl_pnlCommentStandard);
gl_pnlCommentStandard.setAutoCreateContainerGaps(true);
.addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(lblCommentSize)
.addComponent(lblCommentMinSize)
- .addComponent(lblCommentDisplayMax))
- .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(cbCommentSizeAuto)
- .addComponent(cbCommentMinDisable)
- .addComponent(cbCommentMinSizeAuto)
- .addComponent(cbCommentDisplaySizeDefault))
- .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(lblCommentSizeManual)
- .addComponent(lblCommentMinSizeManual)
- .addComponent(lblCommentDisplayMaxManual))
+ .addComponent(lblCommentDisplayMax)
+ .addComponent(lblCommentOwnerOnly)
+ )
.addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
- .addComponent(fldCommentSizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addComponent(fldCommentMinSizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addComponent(fldCommentDisplaySizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addGroup(gl_pnlCommentStandard.createSequentialGroup()
+ .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(cbCommentSizeAuto)
+ .addComponent(cbCommentMinDisable)
+ .addComponent(cbCommentMinSizeAuto)
+ .addComponent(cbCommentDisplaySizeDefault)
+ )
+ .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(lblCommentSizeManual)
+ .addComponent(lblCommentMinSizeManual)
+ .addComponent(lblCommentDisplayMaxManual))
+ .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
+ .addComponent(fldCommentSizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(fldCommentMinSizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(fldCommentDisplaySizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ )
+ .addGroup(gl_pnlCommentStandard.createSequentialGroup()
+ .addComponent(cbCommentOwnerOnly)
+ )
+ )
);
gl_pnlCommentStandard.setVerticalGroup(
gl_pnlCommentStandard.createSequentialGroup()
.addComponent(cbCommentDisplaySizeDefault)
.addComponent(lblCommentDisplayMaxManual)
.addComponent(fldCommentDisplaySizeManual))
+ .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
+ .addComponent(lblCommentOwnerOnly)
+ .addComponent(cbCommentOwnerOnly)
+ )
);
pnlCommentAdvanced.setBorder(BorderFactory.createTitledBorder("高度な設定"));
// ネットワーク
// ネットワーク - アカウント
+ final JRadioButton btnAccount = new JRadioButton("次の情報を使用してログインする");
private final JTextField fldMail;
private final JPasswordField fldPassword = new JPasswordField();
+ // ネットワーク - cookie
+ final JRadioButton btnLoginCookie = new JRadioButton("ブラウザのログイン情報を使用してアクセスする");
+ final JRadioButton btnCookieIe = new JRadioButton("IE(7以降) (Windows)");
+ final JRadioButton btnCookieFirefox = new JRadioButton("Firefox(4以降) (Windows)");
+ final JRadioButton btnCookieChrome = new JRadioButton("Google Chrome (Windows)");
+ final JRadioButton btnCookieChromium = new JRadioButton("Chrome派生ブラウザ (Windows)");
+ final JRadioButton btnCookieOpera = new JRadioButton("Opera (Windows)");
+ final JRadioButton btnCookieOther = new JRadioButton("上記以外 - cookie保存ディレクトリを次に入力");
+ final JTextField fldCookie = new JTextField();
// ネットワーク - プロキシ
private final JCheckBox cbProxyUse;
private final JTextField fldProxyHost = new JTextField();
private final JCheckBox cbOutputEnable;
private final JCheckBox cbOutputCommentOverlay;
private final JCheckBox cbOutputDisplayProgress;
- // ファイル - 禁則文字
- private final JTextField fldReplaceFrom = new JTextField();
- private final JTextField fldReplaceTo = new JTextField();
// コメント
// コメント
private final JCheckBox cbCommentSizeAuto = new JCheckBox("自動調整");
private final NumberFormattedTextField fldCommentMinSizeManual = new NumberFormattedTextField();
private final JCheckBox cbCommentDisplaySizeDefault = new JCheckBox("標準(30)");
private final NumberFormattedTextField fldCommentDisplaySizeManual = new NumberFormattedTextField();
+ private final JCheckBox cbCommentOwnerOnly = new JCheckBox("投稿者コメントのみ");
// コメント - 高度な設定
private final JTextField fldFontPath;
private final JTextField fldFontIndex;
/*
* ネットワーク - アカウント
*/
+ btnAccount.setSelected(p.getNeedsLogin());
fldMail.setText(p.getId());
fldPassword.setText(p.getPassword());
/*
+ * ネットワーク - cookie
+ */
+ btnLoginCookie.setSelected(!p.getNeedsLogin());
+ final CookieBrowser cookieBrowser = p.getCookieBrowser();
+ final JRadioButton enabledBrowser;
+ switch(cookieBrowser){
+ case MSIE:
+ enabledBrowser = btnCookieIe;
+ break;
+ case FIREFOX:
+ enabledBrowser = btnCookieFirefox;
+ break;
+ case CHROME:
+ enabledBrowser = btnCookieChrome;
+ break;
+ case CHROMIUM:
+ enabledBrowser = btnCookieChromium;
+ break;
+ case OPERA:
+ enabledBrowser = btnCookieOpera;
+ break;
+ case OTHER:
+ enabledBrowser = btnCookieOther;
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ enabledBrowser.setSelected(true);
+ fldCookie.setText(p.getCookieDir());
+
+ /*
* ネットワーク - プロキシ
*/
cbProxyUse.setSelected(p.getProxyUse());
cbOutputCommentOverlay.setSelected(p.getOutputCommentOverlay());
cbOutputDisplayProgress.setSelected(p.getOutputDisplayProgress());
- /*
- * ファイル - 禁則文字
- */
- fldReplaceFrom.setText(p.getReplaceFrom());
- fldReplaceTo.setText(p.getReplaceTo());
-
/**
* コメント
*/
fldCommentSizeManual.setText(p.getCommentMinSizeManual());
cbCommentDisplaySizeDefault.setSelected(p.getCommentDisplaySizeDefault());
fldCommentDisplaySizeManual.setText(p.getCommentDisplaySizeManual());
+ cbCommentOwnerOnly.setSelected(p.getCommentOwnerOnly());
/**
* コメント - 高度な設定
/*
* ネットワーク - アカウント
*/
-
+ p.setNeedsLogin(btnAccount.isSelected());
p.setId(fldMail.getText());
p.setPassword(String.valueOf(fldPassword.getPassword()));
/*
+ * ネットワーク - cookie
+ */
+ final CookieBrowser cookieBrowser;
+ if(btnCookieIe.isSelected()) {
+ cookieBrowser = CookieBrowser.MSIE;
+ } else if(btnCookieFirefox.isSelected()) {
+ cookieBrowser = CookieBrowser.FIREFOX;
+ } else if (btnCookieChrome.isSelected()) {
+ cookieBrowser = CookieBrowser.CHROME;
+ } else if (btnCookieChromium.isSelected()) {
+ cookieBrowser = CookieBrowser.CHROMIUM;
+ } else if(btnCookieOpera.isSelected()) {
+ cookieBrowser = CookieBrowser.OPERA;
+ } else if(btnCookieOther.isSelected()) {
+ cookieBrowser = CookieBrowser.OTHER;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ p.setCookieBrowser(cookieBrowser);
+ p.setCookieDir(fldCookie.getText());
+
+ /*
* ネットワーク - プロキシ
*/
p.setProxyUse(cbProxyUse.isSelected());
p.setOutputDisplayProgress(cbOutputDisplayProgress.isSelected());
/*
- * ファイル - 禁則文字
- */
- p.setReplaceFrom(fldReplaceFrom.getText());
- p.setReplaceTo(fldReplaceTo.getText());
-
- /*
* コメント
*/
p.setCommentSizeAutosize(cbCommentSizeAuto.isSelected());
p.setCommentMinSizeManual(fldCommentSizeManual.getText());
p.setCommentDisplaySizeDefault(cbCommentDisplaySizeDefault.isSelected());
p.setCommentDisplaySizeManual(fldCommentDisplaySizeManual.getText());
+ p.setCommentOwnerOnly(cbCommentOwnerOnly.isSelected());
/**
* コメント - 高度な設定