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