]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/tools/NexuizDemoRecorder/main/src/main/java/com/nexuiz/demorecorder/ui/swinggui/RecordJobTemplate.java
Merge branch 'master' of ssh://git.xonotic.org/xonotic
[xonotic/xonotic.git] / misc / tools / NexuizDemoRecorder / main / src / main / java / com / nexuiz / demorecorder / ui / swinggui / RecordJobTemplate.java
1 package com.nexuiz.demorecorder.ui.swinggui;
2
3 import java.io.File;
4
5 import com.nexuiz.demorecorder.application.DemoRecorderException;
6 import com.nexuiz.demorecorder.application.jobs.RecordJob;
7
8 public class RecordJobTemplate extends RecordJob {
9
10         private static final long serialVersionUID = 8311386509410161395L;
11         private String templateName;
12         private String summary;
13
14         public RecordJobTemplate(
15                 String templateName,
16                 String summary,
17                 String jobName,
18                 File enginePath,
19                 String engineParameters,
20                 File demoFile,
21                 String relativeDemoPath,
22                 File dpVideoPath,
23                 File videoDestination,
24                 String executeBeforeCap,
25                 String executeAfterCap
26                 ) {
27                 super();
28                 
29                 /*
30                  * Differences to jobs:
31                  * - name and summary exist
32                  * - "Demo file:" -> "Demo directory:"
33                  * - no start/end second
34                  */
35                 
36                 if (templateName == null || summary == null || jobName == null || enginePath == null || engineParameters == null || 
37                                 demoFile == null || relativeDemoPath == null || dpVideoPath == null || videoDestination == null 
38                                 || executeBeforeCap == null || executeAfterCap == null) {
39                         throw new DemoRecorderException("Error: Make sure that you filled the necessary fields! (file choosers!)");
40                 }
41                 
42                 this.templateName = templateName;
43                 this.summary = summary;
44                 this.jobName = jobName;
45                 this.enginePath = enginePath;
46                 this.engineParameters = engineParameters;
47                 this.demoFile = demoFile;
48                 this.relativeDemoPath = relativeDemoPath;
49                 this.dpVideoPath = dpVideoPath;
50                 this.videoDestination = videoDestination;
51                 this.executeBeforeCap = executeBeforeCap;
52                 this.executeAfterCap = executeAfterCap;
53         }
54
55         public String getName() {
56                 return templateName;
57         }
58
59         public String getSummary() {
60                 return summary;
61         }
62         
63         public void setName(String name) {
64                 this.templateName = name;
65         }
66
67         public void setSummary(String summary) {
68                 this.summary = summary;
69         }
70
71         /*
72          * (non-Javadoc)
73          * Overwrite this method because here we want to do the read/write test for the path directly
74          * (as this one already is the directory), and not its parent directory.
75          * @see com.nexuiz.demorecorder.application.jobs.RecordJob#setDemoFile(java.io.File)
76          */
77         public void setDemoFile(File demoFile) {
78                 if (demoFile == null || !demoFile.exists()) {
79                         throw new DemoRecorderException("Could not locate demo file!");
80                 }
81                 if (!doReadWriteTest(demoFile)) {
82                         throw new DemoRecorderException("The directory you specified for the demo to be recorded is not writable!");
83                 }
84                 this.demoFile = demoFile.getAbsoluteFile();
85         }
86         
87         /*
88          * (non-Javadoc)
89          * Overwrite this method because here we want to do the read/write test for the path directly
90          * (as this one already is the directory), and not its parent directory.
91          * @see com.nexuiz.demorecorder.application.jobs.RecordJob#setVideoDestination(java.io.File)
92          */
93         public void setVideoDestination(File videoDestination) {
94                 //keep in mind, here videoDestination points to the destination directory, not the destination file
95                 if (videoDestination == null || !videoDestination.isDirectory()) {
96                         throw new DemoRecorderException("Could not locate the specified video destination directory");
97                 }
98                 
99                 if (!this.doReadWriteTest(videoDestination)) {
100                         throw new DemoRecorderException("The video destination directory is not writable! It needs to be writable so that the file can be moved to its new location");
101                 }
102                 
103                 this.videoDestination = videoDestination.getAbsoluteFile();
104         }
105         
106         public String getJobName() {
107                 return this.jobName;
108         }
109         
110         public void setJobName(String jobName) {
111                 this.jobName = jobName;
112         }
113 }