1 package com.nexuiz.demorecorder.ui.swinggui;
3 import java.awt.Dimension;
5 import java.awt.Toolkit;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
9 import java.util.HashMap;
11 import java.util.Properties;
14 import javax.swing.JButton;
15 import javax.swing.JCheckBox;
16 import javax.swing.JComponent;
17 import javax.swing.JDialog;
18 import javax.swing.JFileChooser;
19 import javax.swing.JLabel;
20 import javax.swing.JPanel;
21 import javax.swing.JScrollPane;
22 import javax.swing.JTextArea;
23 import javax.swing.JTextField;
24 import javax.swing.ScrollPaneConstants;
25 import javax.swing.border.EmptyBorder;
26 import javax.swing.filechooser.FileFilter;
28 import net.miginfocom.swing.MigLayout;
30 import org.jdesktop.swingx.JXTable;
31 import org.jdesktop.swingx.JXTitledSeparator;
33 import com.nexuiz.demorecorder.application.DemoRecorderApplication;
34 import com.nexuiz.demorecorder.application.DemoRecorderUtils;
35 import com.nexuiz.demorecorder.application.NDRPreferences;
36 import com.nexuiz.demorecorder.application.jobs.RecordJob;
37 import com.nexuiz.demorecorder.application.plugins.EncoderPlugin;
38 import com.nexuiz.demorecorder.ui.swinggui.tablemodels.RecordJobTemplatesTableModel;
39 import com.nexuiz.demorecorder.ui.swinggui.utils.SwingGUIUtils;
42 * Shows the dialog that allows to create a new job, create one from a template
43 * or edit an existing job.
46 public class JobDialog extends JDialog implements ActionListener {
47 private static final long serialVersionUID = 6926246716804560522L;
48 public static final int CREATE_NEW_JOB = 0;
49 public static final int EDIT_JOB = 1;
50 public static final int CREATE_NEW_TEMPLATE = 2;
51 public static final int EDIT_TEMPLATE = 3;
52 public static final int CREATE_JOB_FROM_TEMPLATE = 4;
54 private DemoRecorderApplication appLayer;
55 private RecordJobTemplatesTableModel tableModel;
56 // private JXTable templatesTable;
57 private Frame parentFrame;
58 private int dialogType;
59 private RecordJob job = null;
60 private JPanel inputPanel;
61 private JPanel buttonPanel;
63 private JTextField templateNameField;
64 private JTextField templateSummaryField;
65 private JTextField enginePathField;
66 private JButton enginePathChooserButton;
67 private JTextField engineParameterField;
68 private JTextField dpVideoDirField;
69 private JButton dpVideoDirChooserButton;
70 private JTextField relativeDemoPathField;
71 private JTextField jobNameField;
72 private JTextField demoFileField;
73 private JButton demoFileChooserButton;
74 private JTextField startSecondField;
75 private JTextField endSecondField;
76 private JTextArea execBeforeField;
77 private JTextArea execAfterField;
78 private JTextField videoDestinationField;
79 private JButton videoDestinationChooserButton;
81 private JButton createButton;
82 private JButton cancelButton;
85 private JFileChooser enginePathFC;
86 private JFileChooser dpVideoDirFC;
87 private JFileChooser demoFileFC;
88 private JFileChooser videoDestinationFC;
90 private FileFilter userDirFilter = new NexuizUserDirFilter();
92 private Map<String, JComponent> pluginDialogSettings = new HashMap<String, JComponent>();
95 * Constructor to create a dialog when creating a new job.
99 public JobDialog(Frame owner, DemoRecorderApplication appLayer) {
101 this.parentFrame = owner;
102 this.dialogType = CREATE_NEW_JOB;
103 this.appLayer = appLayer;
104 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
106 setTitle("Create new job");
112 * Constructor to create a dialog when creating a new template.
117 public JobDialog(Frame owner, RecordJobTemplatesTableModel tableModel, JXTable templatesTable, DemoRecorderApplication appLayer) {
119 this.parentFrame = owner;
120 this.dialogType = CREATE_NEW_TEMPLATE;
121 this.tableModel = tableModel;
122 this.appLayer = appLayer;
123 // this.templatesTable = templatesTable; seems we don't need it
124 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
125 setTitle("Create new template");
131 * Constructor to use when creating a new job from a template, or when editing a template.
134 * @param type either CREATE_JOB_FROM_TEMPLATE or EDIT_TEMPLATE
136 public JobDialog(Frame owner, RecordJobTemplate template, DemoRecorderApplication appLayer, int type) {
138 this.parentFrame = owner;
141 this.appLayer = appLayer;
142 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
144 if (type != CREATE_JOB_FROM_TEMPLATE && type != EDIT_TEMPLATE) {
145 throw new RuntimeException("Illegal paraameter \"type\"");
148 this.dialogType = type;
149 if (type == CREATE_JOB_FROM_TEMPLATE) {
150 setTitle("Create job from template");
152 setTitle("Edit template");
159 * Constructor to create a dialog to be used when editing an existing job.
163 public JobDialog(Frame owner, RecordJob job, DemoRecorderApplication appLayer) {
165 this.parentFrame = owner;
166 this.dialogType = EDIT_JOB;
167 this.appLayer = appLayer;
168 setDefaultCloseOperation(DISPOSE_ON_CLOSE);
170 setTitle("Edit job");
178 public void showDialog() {
180 Toolkit t = Toolkit.getDefaultToolkit();
181 Dimension screenSize = t.getScreenSize();
182 if (getHeight() > screenSize.height) {
183 Dimension newPreferredSize = getPreferredSize();
184 newPreferredSize.height = screenSize.height - 100;
185 setPreferredSize(newPreferredSize);
188 this.setLocationRelativeTo(this.parentFrame);
189 this.setVisible(true);
192 private void setupLayout() {
193 // setLayout(new MigLayout("wrap 1", "[grow,fill]", "[]20[]"));
194 setLayout(new MigLayout("wrap 1", "[grow,fill]", "[][]"));
195 this.setupInputMask();
196 this.setupButtonPart();
200 private void setupInputMask() {
201 inputPanel = new JPanel(new MigLayout("insets 0,wrap 3", "[][250::,grow,fill][30::]"));
202 JScrollPane inputScrollPane = new JScrollPane(inputPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
203 inputScrollPane.setBorder(new EmptyBorder(0,0,0,0));
205 JXTitledSeparator environmentHeading = new JXTitledSeparator("Environment settings");
206 inputPanel.add(environmentHeading, "span 3,grow");
208 this.setupTemplateNameAndSummary();
209 this.setupEnginePath();
210 this.setupEngineParameters();
211 this.setupDPVideoDir();
212 this.setupRelativeDemoPath();
214 JXTitledSeparator jobSettingsHeading = new JXTitledSeparator("Job settings");
215 inputPanel.add(jobSettingsHeading, "span 3,grow");
218 this.setupDemoFile();
219 this.setupStartSecond();
220 this.setupEndSecond();
221 this.setupExecBefore();
222 this.setupExecAfter();
223 this.setupVideoDestination();
225 this.setupPluginPreferences();
227 getContentPane().add(inputScrollPane);
230 private void setupTemplateNameAndSummary() {
231 if (this.dialogType != CREATE_NEW_TEMPLATE && this.dialogType != EDIT_TEMPLATE) {
236 inputPanel.add(new JLabel("Template name:"));
237 templateNameField = new JTextField();
238 inputPanel.add(templateNameField, "wrap");
240 inputPanel.add(new JLabel("Summary:"));
241 templateSummaryField = new JTextField();
242 inputPanel.add(templateSummaryField, "wrap");
245 if (this.dialogType == EDIT_TEMPLATE) {
246 RecordJobTemplate template = (RecordJobTemplate) this.job;
247 templateNameField.setText(template.getName());
248 templateSummaryField.setText(template.getSummary());
252 private void setupEnginePath() {
254 inputPanel.add(new JLabel("Engine:"));
255 enginePathField = new JTextField();
256 enginePathField.setEditable(false);
257 inputPanel.add(enginePathField);
258 enginePathChooserButton = new FileChooserButton();
259 inputPanel.add(enginePathChooserButton);
262 this.enginePathFC = createConfiguredFileChooser();
263 enginePathChooserButton.addActionListener(this);
264 if (this.dialogType == EDIT_JOB || this.dialogType == EDIT_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
265 this.enginePathFC.setSelectedFile(this.job.getEnginePath());
266 this.enginePathField.setText(this.job.getEnginePath().getAbsolutePath());
270 private void setupEngineParameters() {
272 inputPanel.add(new JLabel("Engine parameters:"));
273 engineParameterField = new JTextField();
274 inputPanel.add(engineParameterField, "wrap");
277 if (this.dialogType == EDIT_JOB || this.dialogType == EDIT_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
278 engineParameterField.setText(this.job.getEngineParameters());
282 private void setupDPVideoDir() {
284 inputPanel.add(new JLabel("DPVideo directory:"));
285 dpVideoDirField = new JTextField();
286 dpVideoDirField.setEditable(false);
287 inputPanel.add(dpVideoDirField);
288 dpVideoDirChooserButton = new FileChooserButton();
289 inputPanel.add(dpVideoDirChooserButton);
292 dpVideoDirChooserButton.addActionListener(this);
293 this.dpVideoDirFC = createConfiguredFileChooser();
294 this.dpVideoDirFC.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
295 if (this.dialogType == EDIT_JOB || this.dialogType == EDIT_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
296 this.dpVideoDirFC.setSelectedFile(this.job.getDpVideoPath());
297 this.dpVideoDirField.setText(this.job.getDpVideoPath().getAbsolutePath());
301 private void setupRelativeDemoPath() {
303 inputPanel.add(new JLabel("Relative demo path:"));
304 relativeDemoPathField = new JTextField();
305 inputPanel.add(relativeDemoPathField, "wrap 20");
308 if (this.dialogType == CREATE_NEW_JOB || this.dialogType == CREATE_NEW_TEMPLATE) {
309 relativeDemoPathField.setText("demos");
311 if (this.dialogType == EDIT_JOB || this.dialogType == EDIT_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
312 relativeDemoPathField.setText(this.job.getRelativeDemoPath());
316 private void setupJobName() {
317 inputPanel.add(new JLabel("Job name:"));
319 jobNameField = new JTextField();
320 inputPanel.add(jobNameField, "wrap");
323 if (this.dialogType != CREATE_NEW_TEMPLATE && this.dialogType != CREATE_NEW_JOB) {
324 jobNameField.setText(this.job.getJobName());
328 private void setupDemoFile() {
330 if (this.dialogType == CREATE_NEW_JOB || this.dialogType == EDIT_JOB || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
331 label = "Demo file:";
333 label = "Demo directory:";
337 inputPanel.add(new JLabel(label));
338 demoFileField = new JTextField();
339 demoFileField.setEditable(false);
340 inputPanel.add(demoFileField);
341 demoFileChooserButton = new FileChooserButton();
342 inputPanel.add(demoFileChooserButton);
345 this.demoFileFC = createConfiguredFileChooser();
346 demoFileChooserButton.addActionListener(this);
347 if (this.dialogType == EDIT_JOB || this.dialogType == EDIT_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
348 if (this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
349 this.demoFileFC.setCurrentDirectory(this.job.getDemoFile());
351 this.demoFileFC.setSelectedFile(this.job.getDemoFile());
354 this.demoFileField.setText(this.job.getDemoFile().getAbsolutePath());
357 //only specify directories for templates
358 if (this.dialogType == CREATE_NEW_TEMPLATE || this.dialogType == EDIT_TEMPLATE) {
359 this.demoFileFC.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
363 private void setupStartSecond() {
364 //only exists for jobs, not for templates
365 if (this.dialogType != CREATE_NEW_JOB && this.dialogType != EDIT_JOB && this.dialogType != CREATE_JOB_FROM_TEMPLATE) {
370 inputPanel.add(new JLabel("Start second:"));
371 startSecondField = new JTextField();
372 inputPanel.add(startSecondField, "wrap");
375 if (this.dialogType == EDIT_JOB) {
376 startSecondField.setText(String.valueOf( this.job.getStartSecond() ));
380 private void setupEndSecond() {
381 //only exists for jobs, not for templates
382 if (this.dialogType != CREATE_NEW_JOB && this.dialogType != EDIT_JOB && this.dialogType != CREATE_JOB_FROM_TEMPLATE) {
387 inputPanel.add(new JLabel("End second:"));
388 endSecondField = new JTextField();
389 inputPanel.add(endSecondField, "wrap");
392 if (this.dialogType == EDIT_JOB) {
393 endSecondField.setText(String.valueOf( this.job.getEndSecond() ));
397 private void setupExecBefore() {
399 inputPanel.add(new JLabel("Exec before capture:"));
400 execBeforeField = new JTextArea(3, 1);
401 inputPanel.add(new JScrollPane(execBeforeField), "wrap");
404 if (this.dialogType == EDIT_JOB || this.dialogType == EDIT_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
405 execBeforeField.setText(this.job.getExecuteBeforeCap());
409 private void setupExecAfter() {
411 inputPanel.add(new JLabel("Exec after capture:"));
412 execAfterField = new JTextArea(3, 1);
413 inputPanel.add(new JScrollPane(execAfterField), "wrap");
416 if (this.dialogType == EDIT_JOB || this.dialogType == EDIT_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
417 execAfterField.setText(this.job.getExecuteAfterCap());
421 private void setupVideoDestination() {
423 inputPanel.add(new JLabel("Video destination:"));
424 videoDestinationField = new JTextField();
425 videoDestinationField.setEditable(false);
426 inputPanel.add(videoDestinationField);
427 videoDestinationChooserButton = new FileChooserButton();
428 inputPanel.add(videoDestinationChooserButton, "wrap 20");
431 videoDestinationChooserButton.addActionListener(this);
432 this.videoDestinationFC = createConfiguredFileChooser();
433 if (this.dialogType == EDIT_JOB || this.dialogType == EDIT_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
434 if (this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
435 this.videoDestinationFC.setCurrentDirectory(this.job.getVideoDestination());
437 this.videoDestinationFC.setSelectedFile(this.job.getVideoDestination());
440 this.videoDestinationField.setText(this.job.getVideoDestination().getAbsolutePath());
442 if (this.dialogType == CREATE_NEW_TEMPLATE || this.dialogType == EDIT_TEMPLATE) {
443 this.videoDestinationFC.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
447 private void setupPluginPreferences() {
448 for (EncoderPlugin plugin : this.appLayer.getEncoderPlugins()) {
449 String pluginName = plugin.getName();
450 //only display settings if the plugin actually has any...
451 Properties jobSpecificDefaultPluginPreferences = plugin.getJobSpecificPreferences();
452 Properties jobPluginPreferences = null;
453 if (this.job != null) {
454 jobPluginPreferences = this.job.getEncoderPluginSettings(plugin);
456 if (jobSpecificDefaultPluginPreferences.size() > 0 && plugin.isEnabled()) {
458 JXTitledSeparator pluginHeading = new JXTitledSeparator(pluginName + " plugin settings");
459 inputPanel.add(pluginHeading, "span 3,grow");
461 for (String pluginPreferenceKey : plugin.getJobSpecificPreferencesOrder()) {
462 String value = jobSpecificDefaultPluginPreferences.getProperty(pluginPreferenceKey);
463 if (this.job != null) {
464 if (jobPluginPreferences.containsKey(pluginPreferenceKey)) {
465 value = jobPluginPreferences.getProperty(pluginPreferenceKey);
469 this.setupSinglePluginSetting(plugin, pluginPreferenceKey, value);
475 private void setupSinglePluginSetting(EncoderPlugin plugin, String key, String value) {
476 inputPanel.add(new JLabel(key + ":"));
478 if (SwingGUIUtils.isBooleanValue(value)) {
479 JCheckBox checkbox = new JCheckBox();
480 checkbox.setSelected(Boolean.valueOf(value));
481 inputPanel.add(checkbox, "wrap");
482 this.pluginDialogSettings.put(NDRPreferences.getConcatenatedKey(plugin.getName(), key), checkbox);
483 } else if (SwingGUIUtils.isFileChooser(value)) {
484 final JFileChooser fc = new JFileChooser();
485 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
486 JButton fcButton = new JButton("...");
487 final JTextField filePathField = new JTextField();
488 filePathField.setEditable(false);
489 inputPanel.add(filePathField);
490 fcButton.addActionListener(new ActionListener() {
492 public void actionPerformed(ActionEvent e) {
493 int returnValue = fc.showOpenDialog(JobDialog.this);
494 if (returnValue == JFileChooser.APPROVE_OPTION) {
495 File selectedFile = fc.getSelectedFile();
496 filePathField.setText(selectedFile.getAbsolutePath());
502 File selectedFile = new File(value);
503 if (selectedFile.exists()) {
504 fc.setSelectedFile(selectedFile);
505 filePathField.setText(selectedFile.getAbsolutePath());
507 } catch (Throwable e) {}
508 this.pluginDialogSettings.put(NDRPreferences.getConcatenatedKey(plugin.getName(), key), fc);
509 inputPanel.add(fcButton);
512 JTextField textField = new JTextField();
513 textField.setText(value);
514 this.pluginDialogSettings.put(NDRPreferences.getConcatenatedKey(plugin.getName(), key), textField);
515 inputPanel.add(textField, "wrap");
519 private void setupButtonPart() {
520 String createButtonText;
521 if (this.dialogType == CREATE_NEW_JOB || this.dialogType == CREATE_NEW_TEMPLATE || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
522 createButtonText = "Create";
524 createButtonText = "Save";
526 buttonPanel = new JPanel(new MigLayout("insets 0"));
527 createButton = new JButton(createButtonText);
528 createButton.addActionListener(this);
529 cancelButton = new JButton("Cancel");
530 cancelButton.addActionListener(this);
532 buttonPanel.add(createButton);
533 buttonPanel.add(cancelButton);
535 getContentPane().add(buttonPanel);
539 public void actionPerformed(ActionEvent e) {
540 if (e.getSource() == enginePathChooserButton) {
541 int returnValue = this.enginePathFC.showOpenDialog(this);
542 if (returnValue == JFileChooser.APPROVE_OPTION) {
543 File selectedFile = this.enginePathFC.getSelectedFile();
544 this.enginePathField.setText(selectedFile.getAbsolutePath());
546 } else if (e.getSource() == dpVideoDirChooserButton) {
547 int returnValue = this.dpVideoDirFC.showOpenDialog(this);
548 if (returnValue == JFileChooser.APPROVE_OPTION) {
549 File selectedFile = this.dpVideoDirFC.getSelectedFile();
550 this.dpVideoDirField.setText(selectedFile.getAbsolutePath());
552 } else if (e.getSource() == demoFileChooserButton) {
553 int returnValue = this.demoFileFC.showOpenDialog(this);
554 if (returnValue == JFileChooser.APPROVE_OPTION) {
555 File selectedFile = this.demoFileFC.getSelectedFile();
556 if (this.dialogType == CREATE_NEW_JOB || this.dialogType == EDIT_JOB || this.dialogType == CREATE_JOB_FROM_TEMPLATE) {
557 this.demoFileField.setText(DemoRecorderUtils.getJustFileNameOfPath(selectedFile));
559 //template, show full path of directory
560 this.demoFileField.setText(selectedFile.getAbsolutePath());
564 } else if (e.getSource() == videoDestinationChooserButton) {
565 int returnValue = this.videoDestinationFC.showSaveDialog(this);
566 if (returnValue == JFileChooser.APPROVE_OPTION) {
567 File selectedFile = this.videoDestinationFC.getSelectedFile();
568 this.videoDestinationField.setText(selectedFile.getAbsolutePath());
570 } else if (e.getSource() == createButton) {
571 switch (this.dialogType) {
573 case CREATE_JOB_FROM_TEMPLATE:
574 this.requestNewRecordJob(); break;
575 case CREATE_NEW_TEMPLATE:
576 this.createNewTemplate();
585 } else if (e.getSource() == cancelButton) {
590 private void requestNewRecordJob() {
591 float startSecond, endSecond = -1;
593 startSecond = Float.valueOf(this.startSecondField.getText());
594 endSecond = Float.valueOf(this.endSecondField.getText());
595 } catch (Exception e) {
596 DemoRecorderUtils.showNonCriticalErrorDialog("Make sure that start and end second are floating point numbers", e, true);
601 RecordJob j = this.appLayer.createRecordJob(
602 this.jobNameField.getText(),
603 this.enginePathFC.getSelectedFile(),
604 this.engineParameterField.getText(),
605 this.demoFileFC.getSelectedFile(),
606 this.relativeDemoPathField.getText(),
607 this.dpVideoDirFC.getSelectedFile(),
608 this.videoDestinationFC.getSelectedFile(),
609 this.execBeforeField.getText(),
610 this.execAfterField.getText(),
614 this.saveEncoderPluginSettings(j);
616 } catch (Exception e) {
617 DemoRecorderUtils.showNonCriticalErrorDialog(e);
623 private void editJob() {
624 float startSecond, endSecond = -1;
626 startSecond = Float.valueOf(this.startSecondField.getText());
627 endSecond = Float.valueOf(this.endSecondField.getText());
628 } catch (Exception e) {
629 DemoRecorderUtils.showNonCriticalErrorDialog("Make sure that start and end second are floating point numbers", e, true);
634 this.job.setJobName(this.jobNameField.getText());
635 this.job.setEnginePath(this.enginePathFC.getSelectedFile());
636 this.job.setEngineParameters(this.engineParameterField.getText());
637 this.job.setDemoFile(this.demoFileFC.getSelectedFile());
638 this.job.setRelativeDemoPath(this.relativeDemoPathField.getText());
639 this.job.setDpVideoPath(this.dpVideoDirFC.getSelectedFile());
640 this.job.setVideoDestination(this.videoDestinationFC.getSelectedFile());
641 this.job.setExecuteBeforeCap(this.execBeforeField.getText());
642 this.job.setExecuteAfterCap(this.execAfterField.getText());
643 this.job.setStartSecond(startSecond);
644 this.job.setEndSecond(endSecond);
645 this.saveEncoderPluginSettings(this.job);
646 this.appLayer.fireUserInterfaceUpdate(this.job);
648 } catch (Exception e) {
649 DemoRecorderUtils.showNonCriticalErrorDialog(e);
655 private void createNewTemplate() {
657 RecordJobTemplate templ = new RecordJobTemplate(
658 this.templateNameField.getText(),
659 this.templateSummaryField.getText(),
660 this.jobNameField.getText(),
661 this.enginePathFC.getSelectedFile(),
662 this.engineParameterField.getText(),
663 this.demoFileFC.getSelectedFile(),
664 this.relativeDemoPathField.getText(),
665 this.dpVideoDirFC.getSelectedFile(),
666 this.videoDestinationFC.getSelectedFile(),
667 this.execBeforeField.getText(),
668 this.execAfterField.getText()
670 this.saveEncoderPluginSettings(templ);
671 this.tableModel.addRecordJobTemplate(templ);
673 } catch (NullPointerException e) {
674 DemoRecorderUtils.showNonCriticalErrorDialog("Make sure that you chose a file/directory in each case!", e, true);
675 } catch (Exception e) {
676 DemoRecorderUtils.showNonCriticalErrorDialog(e);
681 private void editTemplate() {
683 RecordJobTemplate template = (RecordJobTemplate) this.job;
684 template.setName(this.templateNameField.getText());
685 template.setSummary(this.templateSummaryField.getText());
686 template.setJobName(this.jobNameField.getText());
687 template.setEnginePath(this.enginePathFC.getSelectedFile());
688 template.setEngineParameters(this.engineParameterField.getText());
689 template.setDpVideoPath(this.dpVideoDirFC.getSelectedFile());
690 template.setRelativeDemoPath(this.relativeDemoPathField.getText());
691 template.setDemoFile(this.demoFileFC.getSelectedFile());
692 template.setExecuteBeforeCap(this.execBeforeField.getText());
693 template.setExecuteAfterCap(this.execAfterField.getText());
694 template.setVideoDestination(this.videoDestinationFC.getSelectedFile());
695 this.saveEncoderPluginSettings(template);
697 } catch (Exception e) {
698 DemoRecorderUtils.showNonCriticalErrorDialog(e);
703 private void saveEncoderPluginSettings(RecordJob job) {
704 Set<String> keys = this.pluginDialogSettings.keySet();
705 //remember, the keys are concatenated, containing both the category and actual key
706 for (String key : keys) {
707 JComponent component = this.pluginDialogSettings.get(key);
708 if (component instanceof JCheckBox) {
709 JCheckBox checkbox = (JCheckBox) component;
710 job.setEncoderPluginSetting(NDRPreferences.getCategory(key), NDRPreferences.getKey(key), String.valueOf(checkbox.isSelected()));
711 } else if (component instanceof JFileChooser) {
712 JFileChooser fileChooser = (JFileChooser) component;
713 if (fileChooser.getSelectedFile() != null) {
714 String path = fileChooser.getSelectedFile().getAbsolutePath();
715 job.setEncoderPluginSetting(NDRPreferences.getCategory(key), NDRPreferences.getKey(key), path);
717 } else if (component instanceof JTextField) {
718 JTextField textField = (JTextField) component;
719 job.setEncoderPluginSetting(NDRPreferences.getCategory(key), NDRPreferences.getKey(key), textField.getText());
724 private static class FileChooserButton extends JButton {
725 private static final long serialVersionUID = 1335571540372856959L;
726 public FileChooserButton() {
731 private JFileChooser createConfiguredFileChooser() {
732 JFileChooser fc = new JFileChooser();
733 fc.setFileHidingEnabled(false);
734 fc.setFileFilter(userDirFilter);