-package jp.co.areaweb.tools.gui;
-import java.awt.*;
-import java.io.*;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-import javax.swing.*;
-
-/**
- * 「NewFileList」処理
- */
-@SuppressWarnings("serial")
-public class NewFileListDialog extends JDialog {
- public static final String TITLE = "NewFileList";
-
- // Used for addNotify check.
- boolean fComponentsAdjusted = false;
-
- //{{DECLARE_CONTROLS
- JFrame parentFrame; // Manager.class
- JPanel argsPanel; // パラメータ設定パネル (上部)
- ParameterPanel arg1Panel; // parameter 1
- ParameterPanel arg2Panel; // parameter 2
-
- JPanel buttonPanel; // ボタン配置パネル (下部)
- JButton closeButton; // [クローズ]ボタン
- JButton doButton; // [実行]ボタン
- TextArea textArea; // 実行結果を表示するJTextArea (中央)
- //}}
-
- class SymAction implements java.awt.event.ActionListener {
- public void actionPerformed(java.awt.event.ActionEvent event) {
- Object object = event.getSource();
- if (object == closeButton) {
- closeButton_Action(event);
- }
- else if (object == doButton) {
- doButton_Action(event);
- }
- }
- }
-
- public NewFileListDialog(JFrame parentFrame) {
- super(parentFrame, true); // モーダルダイアログを基盤にする
- this.parentFrame = parentFrame;
-
- // INIT_CONTROLS
- Container container = getContentPane();
- container.setLayout(new BorderLayout());
- setVisible(false);
- setSize(getInsets().left + getInsets().right + 500,getInsets().top + getInsets().bottom + 480);
- setTitle(NewFileListDialog.TITLE);
- setSize(500,480);
-
- // パラメータ設定パネル
- argsPanel = new JPanel();
- argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS));
-
- arg1Panel = new ParameterPanel("基準フォルダ: ", "C:\\TEMP");
- argsPanel.add(arg1Panel);
-
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.DATE, -1); // 前日にする
- arg2Panel = new ParameterPanel("基準日時: ", (new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss")).format(cal.getTime()));
- argsPanel.add(arg2Panel);
-
- this.getContentPane().add("North", argsPanel);
-
- // コントロールパネル
- buttonPanel = new JPanel();
-
- doButton = new JButton("実行");
- doButton.setToolTipText("処理を実行します.");
- doButton.setEnabled(true);
- buttonPanel.add(doButton);
-
- closeButton = new JButton("閉じる");
- closeButton.setToolTipText("処理を終了します.");
- buttonPanel.add(closeButton);
-
- this.getContentPane().add("South", buttonPanel);
-
- // 説明文
- textArea = new TextArea();
- try {
- textArea.append("/**\n");
- textArea.append(" * "+ TITLE +"\n");
- textArea.append(" * 指定された時刻以降に更新されたファイルをリストアップし、その絶対パス名を標準出力に出力する。\n");
- textArea.append(" * jp.co.areaweb.tools.command.NewFileList [directory] [CCYY.MM.DD-HH:mm:ss]\n");
- textArea.append(" * exp) java -cp hayashi.jar jp.co.areaweb.tools.command.NewFileList \\Server01\\Share\\フォルダ 2002.05.29-00:50:00\n");
- textArea.append(" */\n\n");
- }
- catch (Exception e) {
- System.out.println(e.toString());
- }
- this.getContentPane().add("Center", textArea);
-
- //{{REGISTER_LISTENERS
- SymAction lSymAction = new SymAction();
- closeButton.addActionListener(lSymAction);
- doButton.addActionListener(lSymAction);
- //}}
- }
-
- /**
- * Shows or hides the component depending on the boolean flag b.
- * @param b trueのときコンポーネントを表示; その他のとき, componentを隠す.
- * @see java.awt.Component#isVisible
- */
- public void setVisible(boolean b) {
- if(b) {
- setLocation(80, 80);
- }
- super.setVisible(b);
- }
-
- public void addNotify() {
- // Record the size of the window prior to calling parents addNotify.
- Dimension d = getSize();
-
- super.addNotify();
-
- if (fComponentsAdjusted)
- return;
-
- // Adjust components according to the insets
- setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
- Component components[] = getComponents();
- for (int i = 0; i < components.length; i++) {
- Point p = components[i].getLocation();
- p.translate(getInsets().left, getInsets().top);
- components[i].setLocation(p);
- }
- fComponentsAdjusted = true;
- }
-
- /**
- * [実行]ボタンをクリックしたときの動作
- * @param event
- */
- void doButton_Action(java.awt.event.ActionEvent event) {
- doButton.setEnabled(false);
-
- PrintStream defOut = System.out;
- PrintStream defErr = System.err;
-
- ByteArrayOutputStream stdout = new ByteArrayOutputStream();
- try {
- System.setOut(new PrintStream(stdout));
- System.setErr(new PrintStream(stdout));
-
- Command command = new Command(jp.co.areaweb.tools.command.NewFileList.class);
- String[] args = new String[2];
- args[0] = arg1Panel.getText();
- args[1] = arg2Panel.getText();
- command.setArgs(args);
- command.start(); // コマンドを実行
- while (command.isAlive()) {
- Thread.sleep(1000);
- textArea.append(stdout.toString());
- stdout.reset();
- }
- textArea.append(stdout.toString());
- JOptionPane.showMessageDialog(this, "'"+ TITLE +"'処理を完了しました。", "処理完了", JOptionPane.INFORMATION_MESSAGE);
- }
- catch(Exception e) {
- e.printStackTrace();
- JOptionPane.showMessageDialog(this, e.toString(), "Exception", JOptionPane.ERROR_MESSAGE);
- }
- finally {
- System.setOut(defOut);
- System.setErr(defErr);
- doButton.setEnabled(true);
- }
- }
-
- void closeButton_Action(java.awt.event.ActionEvent event) {
- dispose();
- }
-
- void changeSQL_Action(java.awt.event.ActionEvent event) {
- textArea.setText("");
- }
-}
+package jp.co.areaweb.tools.gui;\r
+import java.awt.*;\r
+import java.io.*;\r
+import java.text.SimpleDateFormat;\r
+import java.util.Calendar;\r
+\r
+import javax.swing.*;\r
+\r
+/**\r
+ * 「NewFileList」処理 \r
+ */\r
+@SuppressWarnings("serial")\r
+public class NewFileListDialog extends JDialog {\r
+ public static final String TITLE = "NewFileList";\r
+ \r
+ // Used for addNotify check.\r
+ boolean fComponentsAdjusted = false;\r
+ \r
+ //{{DECLARE_CONTROLS\r
+ JFrame parentFrame; // Manager.class\r
+ JPanel argsPanel; // パラメータ設定パネル (上部)\r
+ ParameterPanel arg1Panel; // parameter 1\r
+ ParameterPanel arg2Panel; // parameter 2\r
+ \r
+ JPanel buttonPanel; // ボタン配置パネル (下部)\r
+ JButton closeButton; // [クローズ]ボタン\r
+ JButton doButton; // [実行]ボタン\r
+ TextArea textArea; // 実行結果を表示するJTextArea (中央)\r
+ //}}\r
+\r
+ class SymAction implements java.awt.event.ActionListener {\r
+ public void actionPerformed(java.awt.event.ActionEvent event) {\r
+ Object object = event.getSource();\r
+ if (object == closeButton) {\r
+ closeButton_Action(event);\r
+ }\r
+ else if (object == doButton) {\r
+ doButton_Action(event);\r
+ }\r
+ }\r
+ }\r
+\r
+ public NewFileListDialog(JFrame parentFrame) {\r
+ super(parentFrame, true); // モーダルダイアログを基盤にする\r
+ this.parentFrame = parentFrame;\r
+ \r
+ // INIT_CONTROLS\r
+ Container container = getContentPane();\r
+ container.setLayout(new BorderLayout());\r
+ setVisible(false);\r
+ setSize(getInsets().left + getInsets().right + 500,getInsets().top + getInsets().bottom + 480);\r
+ setTitle(NewFileListDialog.TITLE);\r
+ setSize(500,480);\r
+ \r
+ // パラメータ設定パネル\r
+ argsPanel = new JPanel();\r
+ argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS));\r
+ \r
+ arg1Panel = new ParameterPanel("基準フォルダ: ", "C:\\TEMP");\r
+ argsPanel.add(arg1Panel);\r
+ \r
+ Calendar cal = Calendar.getInstance();\r
+ cal.add(Calendar.DATE, -1); // 前日にする\r
+ arg2Panel = new ParameterPanel("基準日時: ", (new SimpleDateFormat("yyyy.MM.dd-HH:mm:ss")).format(cal.getTime()));\r
+ argsPanel.add(arg2Panel);\r
+ \r
+ this.getContentPane().add("North", argsPanel);\r
+ \r
+ // コントロールパネル\r
+ buttonPanel = new JPanel();\r
+\r
+ doButton = new JButton("実行");\r
+ doButton.setToolTipText("処理を実行します.");\r
+ doButton.setEnabled(true);\r
+ buttonPanel.add(doButton);\r
+\r
+ closeButton = new JButton("閉じる");\r
+ closeButton.setToolTipText("処理を終了します.");\r
+ buttonPanel.add(closeButton);\r
+ \r
+ this.getContentPane().add("South", buttonPanel);\r
+ \r
+ // 説明文\r
+ textArea = new TextArea();\r
+ try {\r
+ textArea.append("/**\n");\r
+ textArea.append(" * "+ TITLE +"\n");\r
+ textArea.append(" * 指定された時刻以降に更新されたファイルをリストアップし、その絶対パス名を標準出力に出力する。\n");\r
+ textArea.append(" * jp.co.areaweb.tools.command.NewFileList [directory] [CCYY.MM.DD-HH:mm:ss]\n");\r
+ textArea.append(" * exp) java -cp hayashi.jar jp.co.areaweb.tools.command.NewFileList \\Server01\\Share\\フォルダ 2002.05.29-00:50:00\n");\r
+ textArea.append(" */\n\n");\r
+ }\r
+ catch (Exception e) {\r
+ System.out.println(e.toString());\r
+ }\r
+ this.getContentPane().add("Center", textArea);\r
+\r
+ //{{REGISTER_LISTENERS\r
+ SymAction lSymAction = new SymAction();\r
+ closeButton.addActionListener(lSymAction);\r
+ doButton.addActionListener(lSymAction);\r
+ //}}\r
+ }\r
+\r
+ /**\r
+ * Shows or hides the component depending on the boolean flag b.\r
+ * @param b trueのときコンポーネントを表示; その他のとき, componentを隠す.\r
+ * @see java.awt.Component#isVisible\r
+ */\r
+ public void setVisible(boolean b) {\r
+ if(b) {\r
+ setLocation(80, 80);\r
+ }\r
+ super.setVisible(b);\r
+ }\r
+\r
+ public void addNotify() {\r
+ // Record the size of the window prior to calling parents addNotify.\r
+ Dimension d = getSize();\r
+\r
+ super.addNotify();\r
+\r
+ if (fComponentsAdjusted)\r
+ return;\r
+\r
+ // Adjust components according to the insets\r
+ setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);\r
+ Component components[] = getComponents();\r
+ for (int i = 0; i < components.length; i++) {\r
+ Point p = components[i].getLocation();\r
+ p.translate(getInsets().left, getInsets().top);\r
+ components[i].setLocation(p);\r
+ }\r
+ fComponentsAdjusted = true;\r
+ }\r
+\r
+ /**\r
+ * [実行]ボタンをクリックしたときの動作\r
+ * @param event\r
+ */\r
+ void doButton_Action(java.awt.event.ActionEvent event) {\r
+ doButton.setEnabled(false);\r
+ \r
+ PrintStream defOut = System.out;\r
+ PrintStream defErr = System.err;\r
+\r
+ ByteArrayOutputStream stdout = new ByteArrayOutputStream();\r
+ try {\r
+ System.setOut(new PrintStream(stdout));\r
+ System.setErr(new PrintStream(stdout));\r
+\r
+ Command command = new Command(jp.co.areaweb.tools.command.NewFileList.class);\r
+ String[] args = new String[2];\r
+ args[0] = arg1Panel.getText();\r
+ args[1] = arg2Panel.getText();\r
+ command.setArgs(args);\r
+ command.start(); // コマンドを実行\r
+ while (command.isAlive()) {\r
+ Thread.sleep(1000);\r
+ textArea.append(stdout.toString());\r
+ stdout.reset();\r
+ }\r
+ textArea.append(stdout.toString());\r
+ JOptionPane.showMessageDialog(this, "'"+ TITLE +"'処理を完了しました。", "処理完了", JOptionPane.INFORMATION_MESSAGE);\r
+ }\r
+ catch(Exception e) {\r
+ e.printStackTrace();\r
+ JOptionPane.showMessageDialog(this, e.toString(), "Exception", JOptionPane.ERROR_MESSAGE);\r
+ }\r
+ finally {\r
+ System.setOut(defOut);\r
+ System.setErr(defErr);\r
+ doButton.setEnabled(true);\r
+ }\r
+ }\r
+\r
+ void closeButton_Action(java.awt.event.ActionEvent event) {\r
+ dispose();\r
+ }\r
+ \r
+ void changeSQL_Action(java.awt.event.ActionEvent event) {\r
+ textArea.setText("");\r
+ }\r
+}\r