package saccubus;
-import java.awt.*;
+import java.net.URISyntaxException;
+import static javax.swing.WindowConstants.*;
+
+import java.awt.Color;
+import java.awt.Desktop;
+import java.awt.Dimension;
+import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-
-import javax.swing.*;
-
-import saccubus.util.PopupRightClick;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.swing.BorderFactory;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.SwingUtilities;
/**
* <p>
- * \83^\83C\83g\83\8b: \82³\82«\82ã\82Î\82·
+ * タイトル: さきゅばす
* </p>
- *
+ *
* <p>
- * \90à\96¾: \83j\83R\83j\83R\93®\89æ\82Ì\93®\89æ\82ð\83R\83\81\83\93\83g\82Â\82«\82Å\95Û\91¶
+ * 説明: ニコニコ動画の動画をコメントつきで保存
* </p>
- *
+ *
* <p>
- * \92\98\8dì\8c : Copyright (c) 2007 PSI
+ * 著作権: Copyright (c) 2007 PSI
* </p>
- *
+ *
* <p>
- * \89ï\8eÐ\96¼:
+ * 会社名:
* </p>
- *
- * @author \96¢\93ü\97Í
+ *
+ * @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 =
- "\82³\82«\82ã\82Î\82·\n"+
- version + "\n\n"+
- "Copyright (C) 2008 Saccubus Developers Team\n"+
- " 2007-2008 PSI\n\n"+
- "\83j\83R\83j\83R\93®\89æ\82Ì\93®\89æ\82ð\83R\83\81\83\93\83g\82Â\82«\82Å\95Û\91¶";
-
- JPanel panel1 = new JPanel();
-
- JPanel panel2 = new JPanel();
-
- JPanel insetsPanel1 = new JPanel();
-
- JPanel insetsPanel2 = new JPanel();
-
- JPanel insetsPanel3 = new JPanel();
-
- JButton button1 = new JButton();
-
- JLabel imageLabel = new JLabel();
-
- JTextArea product_field = new JTextArea(product);
-
- ImageIcon image1 = new ImageIcon();
-
- BorderLayout borderLayout1 = new BorderLayout();
-
- BorderLayout borderLayout2 = new BorderLayout();
-
- FlowLayout flowLayout1 = new FlowLayout();
-
- GridLayout gridLayout1 = new GridLayout();
-
- public MainFrame_AboutBox(Frame parent) {
- super(parent);
- try {
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- jbInit();
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
-
- public MainFrame_AboutBox() {
- this(null);
- }
-
- /**
- * \83R\83\93\83|\81[\83l\83\93\83g\82Ì\8f\89\8aú\89»\81B
- *
- * @throws java.lang.Exception
- */
- private void jbInit() throws Exception {
- image1 = new ImageIcon(saccubus.MainFrame.class.getResource("icon.png"));
- imageLabel.setIcon(image1);
- setTitle("\83o\81[\83W\83\87\83\93\8fî\95ñ");
- panel1.setLayout(borderLayout1);
- panel2.setLayout(borderLayout2);
- insetsPanel1.setLayout(flowLayout1);
- insetsPanel2.setLayout(flowLayout1);
- insetsPanel2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- gridLayout1.setRows(1);
- gridLayout1.setColumns(1);
- insetsPanel3.setLayout(gridLayout1);
- insetsPanel3.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- button1.setText("OK");
- button1.addActionListener(this);
- insetsPanel2.add(imageLabel, null);
- panel2.add(insetsPanel2, BorderLayout.WEST);
- getContentPane().add(panel1, null);
- product_field.setForeground(insetsPanel3.getForeground());
- product_field.setBackground(insetsPanel3.getBackground());
- product_field.addMouseListener(new PopupRightClick(product_field));
- product_field.setEditable(false);
- insetsPanel3.add(product_field, null);
- panel2.add(insetsPanel3, BorderLayout.CENTER);
- insetsPanel1.add(button1, null);
- panel1.add(insetsPanel1, BorderLayout.SOUTH);
- panel1.add(panel2, BorderLayout.NORTH);
- setResizable(true);
- }
-
- /**
- * \83{\83^\83\93\83C\83x\83\93\83g\82Å\83_\83C\83A\83\8d\83O\82ð\95Â\82¶\82é
- *
- * @param actionEvent
- * ActionEvent
- */
- public void actionPerformed(ActionEvent actionEvent) {
- if (actionEvent.getSource() == button1) {
- dispose();
- }
- }
+
+ private static final String VERSION = "いんきゅばす 2.b.0";
+ private static final long serialVersionUID = -4256413309312729840L;
+ private static final Logger logger = LoggerFactory.getLogger(MainFrame_AboutBox.class);
+ private static final String LINE_FEED = System.getProperty("line.separator");
+ private final JButton btnOk = new JButton();
+
+ public MainFrame_AboutBox(Frame parent) {
+ super(parent);
+ try {
+ setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+ jbInit();
+ } catch (Exception exception) {
+ logger.error(null, exception);
+ }
+ }
+
+ public MainFrame_AboutBox() {
+ this(null);
+ }
+
+ /**
+ * コンポーネントの初期化。
+ *
+ * @throws java.lang.Exception
+ */
+ private void jbInit() {
+ final JTabbedPane tab = new JTabbedPane(JTabbedPane.BOTTOM);
+
+ final JLabel lblImage = new JLabel();
+ final ImageIcon icon = new ImageIcon(saccubus.MainFrame_AboutBox.class.getResource("icon.png"));
+ lblImage.setIcon(icon);
+
+ final JTextArea fldProduct = createProductField();
+ // Numbus bug 対応
+ // http://stackoverflow.com/questions/613603/java-nimbus-laf-with-transparent-text-fields
+ fldProduct.setOpaque(false);
+ fldProduct.setBorder(BorderFactory.createEmptyBorder());
+ fldProduct.setBackground(new Color(0, 0, 0, 0));
+
+ final JButton btnInqubus = new JButton("いんきゅばすホームページへ...");
+ btnInqubus.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (Desktop.isDesktopSupported()) {
+ try {
+ Desktop.getDesktop().browse(new URI("http://sourceforge.jp/projects/coroid/wiki/InqubusV2"));
+ } catch (IOException | URISyntaxException ex) {
+ logger.error(null, ex);
+ }
+ }
+ }
+ });
+
+ final JButton btnSaccubus = new JButton("さきゅばすホームページへ...");
+ btnSaccubus.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (Desktop.isDesktopSupported()) {
+ try {
+ Desktop.getDesktop().browse(new URI("http://saccubus.sourceforge.jp/"));
+ } catch (IOException | URISyntaxException ex) {
+ logger.error(null, ex);
+ }
+ }
+ }
+ });
+
+ final JPanel pnlAbout = new JPanel();
+ GroupLayout glAbout = new GroupLayout(pnlAbout);
+ pnlAbout.setLayout(glAbout);
+ glAbout.setAutoCreateContainerGaps(true);
+ glAbout.setAutoCreateGaps(true);
+
+ glAbout.setHorizontalGroup(glAbout.createParallelGroup(GroupLayout.Alignment.CENTER)
+ .addGroup(glAbout.createSequentialGroup()
+ .addComponent(lblImage)
+ .addPreferredGap(ComponentPlacement.UNRELATED)
+ .addComponent(fldProduct)
+ )
+ .addGroup(glAbout.createSequentialGroup()
+ .addComponent(btnInqubus)
+ .addComponent(btnSaccubus)
+ )
+ );
+
+ glAbout.setVerticalGroup(glAbout.createSequentialGroup()
+ .addGroup(glAbout.createParallelGroup()
+ .addComponent(lblImage)
+ .addComponent(fldProduct, 0, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
+ )
+ .addGroup(glAbout.createParallelGroup()
+ .addComponent(btnInqubus)
+ .addComponent(btnSaccubus)
+ )
+ );
+
+ tab.add("About", pnlAbout);
+
+ final JScrollPane pnlLicense = createLicensePane();
+ tab.add("License", pnlLicense);
+
+ btnOk.setText("OK");
+ btnOk.addActionListener(this);
+
+ final JPanel pnlBase = new JPanel();
+ final GroupLayout glBase = new GroupLayout(pnlBase);
+ pnlBase.setLayout(glBase);
+ glBase.setAutoCreateContainerGaps(true);
+ glBase.setAutoCreateGaps(true);
+
+ glBase.setHorizontalGroup(glBase.createParallelGroup(Alignment.CENTER)
+ .addComponent(tab)
+ .addComponent(btnOk)
+ );
+
+ glBase.setVerticalGroup(glBase.createSequentialGroup()
+ .addComponent(tab)
+ .addComponent(btnOk)
+ );
+
+
+ setContentPane(pnlBase);
+
+ setTitle("バージョン情報");
+ setResizable(true);
+ pack();
+ }
+
+ private JTextArea createProductField() {
+ final JTextArea area = new JTextArea();
+ area.append(VERSION);
+ area.append(LINE_FEED);
+ area.append(LINE_FEED);
+
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
+ "saccubus_description.txt"), "UTF-8"))) {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ area.append(line);
+ area.append(LINE_FEED);
+ }
+ } catch (IOException ex) {
+ logger.error(null, ex);
+ }
+
+ area.setEditable(false);
+ return area;
+ }
+
+ private JScrollPane createLicensePane() {
+ final JTextArea licenseField = new JTextArea();
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(
+ "LICENSE.txt"), "UTF-8"))) {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ licenseField.append(line);
+ licenseField.append(LINE_FEED);
+ }
+ } catch (IOException ex) {
+ logger.error(null, ex);
+ }
+
+ licenseField.setCaretPosition(0);
+ licenseField.setEditable(false);
+ final JScrollPane licensePane = new JScrollPane(licenseField);
+ licensePane.setPreferredSize(new Dimension(400, 400));
+ return licensePane;
+ }
+
+ /**
+ * ボタンイベントでダイアログを閉じる
+ *
+ * @param actionEvent
+ * ActionEvent
+ */
+ @Override
+ public void actionPerformed(ActionEvent actionEvent) {
+ if (actionEvent.getSource() == btnOk) {
+ dispose();
+ }
+ }
+
+ public static void main(String[] args) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ MainFrame_AboutBox frame = new MainFrame_AboutBox();
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
}