01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.edl.components;
18:
19: import org.w3c.dom.Document;
20: import org.w3c.dom.Element;
21: import org.w3c.dom.Node;
22:
23: import edu.iu.uis.eden.clientapp.WorkflowDocument;
24: import edu.iu.uis.eden.edl.EDLContext;
25: import edu.iu.uis.eden.edl.EDLModelComponent;
26: import edu.iu.uis.eden.edl.EDLXmlUtils;
27: import edu.iu.uis.eden.edl.RequestParser;
28:
29: /**
30: * This class makes xml for the instructions template of widgets. Processes config elements
31: * instructions and createInstructions.
32: *
33: * @author rkirkend
34: *
35: */
36: public class InstructionsEDLComponent implements EDLModelComponent {
37:
38: public void updateDOM(Document dom, Element configElement,
39: EDLContext edlContext) {
40:
41: Element edlElement = EDLXmlUtils.getEDLContent(dom, false);
42: Element edlSubElement = EDLXmlUtils.getOrCreateChildElement(
43: edlElement, "edl", true);
44: WorkflowDocument document = (WorkflowDocument) edlContext
45: .getRequestParser().getAttribute(
46: RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY);
47: edlSubElement.setAttribute("title", document.getTitle());
48:
49: if (configElement.getTagName().equals("instructions")) {
50: Node instTextNode = configElement.getChildNodes().item(0);
51: if (instTextNode == null) {
52: return;
53: }
54: String instructions = instTextNode.getNodeValue();
55: EDLXmlUtils.createTextElementOnParent(edlSubElement,
56: "instructions", instructions);
57: edlElement.setAttribute("title", instructions);
58: } else if (configElement.getTagName().equals(
59: "createInstructions")) {
60: Node instTextNode = configElement.getChildNodes().item(0);
61: if (instTextNode == null) {
62: return;
63: }
64: String instructions = instTextNode.getNodeValue();
65: EDLXmlUtils.createTextElementOnParent(edlSubElement,
66: "createInstructions", instructions);
67: }
68: }
69:
70: }
|