OSDN Git Service

b36e5955dc4e5dfdd8ff6d58a6ee67e220b76811
[restamp/Restamp-gui.git] / src / main / java / osm / surveyor / matchtime / gui / restamp / CardPerformFile.java
1 package osm.surveyor.matchtime.gui.restamp;
2
3 import java.awt.BorderLayout;
4 import java.io.File;
5 import java.util.ArrayList;
6 import javax.swing.BoxLayout;
7 import javax.swing.JButton;
8 import javax.swing.JLabel;
9 import javax.swing.JPanel;
10 import javax.swing.JTabbedPane;
11 import osm.surveyor.matchtime.gui.ReStamp;
12 import static osm.surveyor.matchtime.gui.ReStamp.i18n;
13 import osm.surveyor.matchtime.gui.Card;
14 import osm.surveyor.matchtime.gui.PanelAction;
15 import osm.surveyor.matchtime.gui.ParameterPanelOutput;
16 import osm.surveyor.matchtime.gui.ParameterPanelTime;
17
18 /**
19  * [基準画像(開始/終了)]選択パネル
20  * @author yuu
21  */
22 public class CardPerformFile extends Card  implements PanelAction {
23         private static final long serialVersionUID = 4781494884268871662L;
24     ParameterPanelTime arg1_basetime;
25     ParameterPanelTime arg2_basetime;
26     ParameterPanelOutput arg_output;        // EXIF & 書き出しフォルダ
27     JButton doButton;       // [処理実行]ボタン
28     
29     /**
30      * コンストラクタ
31      * @param tabbe parent panel
32      * @param arg1_basetime             // 開始画像の基準時刻:
33      * @param arg2_basetime             // 開始画像の基準時刻:
34      * @param arg_output              // EXIF & 書き出しフォルダ
35      * @param text
36      * @param pre
37      * @param next
38      */
39     public CardPerformFile(
40             JTabbedPane tabbe,
41             ParameterPanelTime arg1_basetime,
42             ParameterPanelTime arg2_basetime,
43             ParameterPanelOutput arg_output,
44             String text,
45             int pre, int next
46     ) {
47         super(tabbe, text, pre, next);
48         this.arg1_basetime = arg1_basetime;
49         this.arg2_basetime = arg2_basetime;
50         this.arg_output = arg_output;
51         
52         JPanel argsPanel = new JPanel();
53         argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.PAGE_AXIS));
54         
55         // 出力フォルダ
56         // 5. 変換先のフォルダを選択してください。
57         //    - 変換先フォルダには、書き込み権限と、十分な空き容量が必要です。
58         JLabel label5 = new JLabel();
59         label5.setText(
60             String.format(
61                 "<html><p>%s</p><ul><li>%s</li></ul>",
62                 i18n.getString("label.restamp.500"),
63                 i18n.getString("label.restamp.501")
64             )
65         );
66         argsPanel.add(packLine(label5, new JPanel()));
67         argsPanel.add(arg_output);
68         argsPanel.add(arg_output.outputOverwite);
69
70         // [処理実行]ボタン
71         doButton = new JButton(
72             i18n.getString("button.execute"),
73             ReStamp.createImageIcon("/images/media_playback_start.png")
74         );
75         argsPanel.add(doButton);
76                 
77         this.mainPanel.add(argsPanel, BorderLayout.CENTER);
78
79         //{{REGISTER_LISTENERS
80         SymAction lSymAction = new SymAction();
81         doButton.addActionListener(lSymAction);
82         //}}
83     }
84     
85     class SymAction implements java.awt.event.ActionListener {
86         @Override
87         public void actionPerformed(java.awt.event.ActionEvent event) {
88             Object object = event.getSource();
89             if (object == doButton) {
90                 doButton_Action(event);
91             }
92         }
93     }
94     
95     /**
96      * [実行]ボタンをクリックしたときの動作
97      * @param event
98      */
99     void doButton_Action(java.awt.event.ActionEvent event) {
100         doButton.setEnabled(false);
101         
102         ArrayList<String> arry = new ArrayList<>();
103         File file = arg1_basetime.getImageFile().getImageFile();
104         File dir = file.getParentFile();
105         arry.add(dir.getAbsolutePath());
106         arry.add(file.getName());
107         arry.add(arg1_basetime.argField.getText());
108         file = arg2_basetime.getImageFile().getImageFile();
109         arry.add(file.getName());
110         arry.add(arg2_basetime.argField.getText());
111         arry.add(arg_output.getText());
112         
113         String[] argv = arry.toArray(new String[arry.size()]);
114         (new DoRestamp(argv)).setVisible(true);
115         
116         doButton.setEnabled(true);
117     }
118
119     /**
120      *  入力条件が満たされているかどうか
121      * @return
122      */
123     @Override
124     public boolean isEnable() {
125        return (arg1_basetime.isEnable() && arg2_basetime.isEnable());
126     }
127     
128     @Override
129     public void openAction() {
130        ; // 何もしない
131     }
132 }