1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.blossom.dialog;
35
36 import java.util.ArrayList;
37 import java.util.List;
38
39 import javax.jcr.Node;
40 import javax.servlet.http.HttpServletRequest;
41 import javax.servlet.http.HttpServletResponse;
42
43 import info.magnolia.cms.core.Content;
44 import info.magnolia.cms.gui.dialog.Dialog;
45 import info.magnolia.cms.gui.dialog.DialogTab;
46 import info.magnolia.cms.util.ContentUtil;
47 import info.magnolia.module.admininterface.SaveHandler;
48
49
50
51
52
53
54 public class DialogCreationContext {
55
56 private HttpServletRequest request;
57 private HttpServletResponse response;
58 private Content configNode;
59 private Node contentNode;
60 private Dialog dialog;
61 private String contentPath;
62 private List<ValidationCallback> validators = new ArrayList<ValidationCallback>();
63 private SaveHandler saveHandler;
64
65 public HttpServletRequest getRequest() {
66 return request;
67 }
68
69 public void setRequest(HttpServletRequest request) {
70 this.request = request;
71 }
72
73 public HttpServletResponse getResponse() {
74 return response;
75 }
76
77 public void setResponse(HttpServletResponse response) {
78 this.response = response;
79 }
80
81 public Content getConfigNode() {
82 return configNode;
83 }
84
85 public void setConfigNode(Content configNode) {
86 this.configNode = configNode;
87 }
88
89 public Node getContentNode() {
90 return contentNode;
91 }
92
93 public void setContentNode(Node contentNode) {
94 this.contentNode = contentNode;
95 }
96
97
98
99
100 @Deprecated
101 public Content getWebsiteNode() {
102 return ContentUtil.asContent(contentNode);
103 }
104
105
106
107
108 @Deprecated
109 public void setWebsiteNode(Content websiteNode) {
110 this.contentNode = websiteNode.getJCRNode();
111 }
112
113 public Dialog getDialog() {
114 return dialog;
115 }
116
117 public void setDialog(Dialog dialog) {
118 this.dialog = dialog;
119 }
120
121 public String getContentPath() {
122 return contentPath;
123 }
124
125 public void setContentPath(String contentPath) {
126 this.contentPath = contentPath;
127 }
128
129
130
131
132 @Deprecated
133 public String getWebsitePath() {
134 return contentPath;
135 }
136
137
138
139
140 @Deprecated
141 public void setWebsitePath(String websitePath) {
142 this.contentPath = websitePath;
143 }
144
145 public SaveHandler getSaveHandler() {
146 return saveHandler;
147 }
148
149 public void setSaveHandler(SaveHandler saveHandler) {
150 this.saveHandler = saveHandler;
151 }
152
153 public void addValidator(ValidationCallback validator) {
154 validators.add(validator);
155 }
156
157 public List<ValidationCallback> getValidators() {
158 return validators;
159 }
160
161 public DialogTab getTab(String label) {
162 for (Object sub : dialog.getSubs()) {
163 if (sub instanceof DialogTab) {
164 DialogTab d = (DialogTab) sub;
165 if (d.getLabel().equals(label)) {
166 return d;
167 }
168 }
169 }
170 return null;
171 }
172
173 public void executeValidators() {
174 for (ValidationCallback validator : validators) {
175 validator.validate(dialog);
176 }
177 }
178 }