gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.swing / org.gvsig.scripting.swing.impl / src / main / java / org / gvsig / scripting / swing / impl / composer / JNewScriptModel.java @ 989
History | View | Annotate | Download (2.26 KB)
1 |
package org.gvsig.scripting.swing.impl.composer; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import javax.swing.tree.TreePath; |
5 |
|
6 |
import org.gvsig.scripting.ScriptingFolder; |
7 |
import org.gvsig.scripting.ScriptingManager; |
8 |
|
9 |
public class JNewScriptModel { |
10 |
|
11 |
public final static int ACTION_CANCEL = 0; |
12 |
public final static int ACTION_ACCEPT = 1; |
13 |
|
14 |
private String type; |
15 |
private String name; |
16 |
private String description; |
17 |
private String language; |
18 |
private File path; |
19 |
private String createdBy; |
20 |
private String version; |
21 |
private int action; |
22 |
private final ScriptingManager manager; |
23 |
private TreePath initialSelectedPath = null; |
24 |
|
25 |
public JNewScriptModel(ScriptingManager manager){
|
26 |
this.manager = manager;
|
27 |
} |
28 |
|
29 |
public void validate() throws Exception{ |
30 |
if(this.getName().length()==0){ |
31 |
throw new Exception( "Name must not be empty."); |
32 |
} |
33 |
|
34 |
ScriptingFolder folder = manager.getFolder(this.getPath());
|
35 |
if(!manager.validateUnitId(folder,this.getName())){ |
36 |
throw new Exception("This file already exists.\nWrite another name for the script"); |
37 |
} |
38 |
} |
39 |
|
40 |
public String getExtension(){ |
41 |
return manager.getExtensionOfLanguage(this.getLanguage()); |
42 |
} |
43 |
|
44 |
public void setVersion(String version) { |
45 |
this.version = version;
|
46 |
} |
47 |
public String getVersion() { |
48 |
return version;
|
49 |
} |
50 |
public void setCreatedBy(String createdBy) { |
51 |
this.createdBy = createdBy;
|
52 |
} |
53 |
public String getCreatedBy() { |
54 |
return createdBy;
|
55 |
} |
56 |
public void setPath(File path) { |
57 |
this.path = path.getAbsoluteFile();
|
58 |
} |
59 |
public File getPath() { |
60 |
return path;
|
61 |
} |
62 |
public void setLanguage(String language) { |
63 |
this.language = language;
|
64 |
} |
65 |
public String getLanguage() { |
66 |
return language;
|
67 |
} |
68 |
public void setDescription(String description) { |
69 |
this.description = description;
|
70 |
} |
71 |
public String getDescription() { |
72 |
return description;
|
73 |
} |
74 |
public void setName(String name) { |
75 |
this.name = name;
|
76 |
} |
77 |
public String getName() { |
78 |
return name;
|
79 |
} |
80 |
public void setType(String type) { |
81 |
this.type = type;
|
82 |
} |
83 |
public String getType() { |
84 |
return type;
|
85 |
} |
86 |
public void setAction(int action) { |
87 |
this.action = action;
|
88 |
} |
89 |
public int getAction() { |
90 |
return action;
|
91 |
} |
92 |
|
93 |
void setSelectionPath(TreePath path) { |
94 |
this.initialSelectedPath = path;
|
95 |
} |
96 |
|
97 |
TreePath getSelectionPath() {
|
98 |
return this.initialSelectedPath; |
99 |
} |
100 |
|
101 |
} |