KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > wad > controls > WADMemo


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18 */

19 package org.openbravo.wad.controls;
20
21 import java.util.*;
22 import org.openbravo.xmlEngine.XmlDocument;
23
24 public class WADMemo extends WADControl {
25
26   public WADMemo() {
27   }
28
29   public WADMemo(Properties prop) {
30     setInfo(prop);
31     initialize();
32   }
33
34   public void initialize() {
35     generateJSCode();
36   }
37
38   private void generateJSCode() {
39     addImport("ValidationTextArea", "../../../../../web/js/default/ValidationTextArea.js");
40     generateMessages();
41     if (getData("IsMandatory").equals("Y")) {
42       XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADMemoJSValidation").createXmlDocument();
43
44       xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
45       setValidation(replaceHTML(xmlDocument.print()));
46     }
47     setCalloutJS();
48   }
49
50   public String JavaDoc getType() {
51     return "TextArea";
52   }
53
54   public String JavaDoc editMode() {
55     double rowLength = ((Integer.valueOf(getData("FieldLength")).intValue() *20)/ 4000);
56     if (rowLength<3.0) rowLength = 3.0;
57     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADMemo").createXmlDocument();
58
59     xmlDocument.setParameter("columnName", getData("ColumnName"));
60     xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
61     xmlDocument.setParameter("size", getData("CssSize"));
62     xmlDocument.setParameter("maxlength", getData("FieldLength"));
63     xmlDocument.setParameter("invalid", this.invalid);
64     xmlDocument.setParameter("missing", this.missing);
65     xmlDocument.setParameter("range", this.range);
66
67     boolean isDisabled = (getData("IsReadOnly").equals("Y") || getData("IsReadOnlyTab").equals("Y") || getData("IsUpdateable").equals("N"));
68     xmlDocument.setParameter("disabled", (isDisabled?"Y":"N"));
69     if (!isDisabled && getData("IsMandatory").equals("Y")) {
70       xmlDocument.setParameter("required", "true");
71       xmlDocument.setParameter("requiredClass", " required");
72     } else {
73       xmlDocument.setParameter("required", "false");
74       xmlDocument.setParameter("requiredClass", (isDisabled?" readonly":""));
75     }
76
77     xmlDocument.setParameter("callout", getOnChangeCode());
78
79     return replaceHTML(xmlDocument.print());
80   }
81
82   public String JavaDoc newMode() {
83     double rowLength = ((Integer.valueOf(getData("FieldLength")).intValue() *20)/ 4000);
84     if (rowLength<3.0) rowLength = 3.0;
85     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADMemo").createXmlDocument();
86
87     xmlDocument.setParameter("columnName", getData("ColumnName"));
88     xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
89     xmlDocument.setParameter("size", getData("CssSize"));
90     xmlDocument.setParameter("maxlength", getData("FieldLength"));
91     xmlDocument.setParameter("invalid", this.invalid);
92     xmlDocument.setParameter("missing", this.missing);
93     xmlDocument.setParameter("range", this.range);
94
95     boolean isDisabled = (getData("IsReadOnly").equals("Y") || getData("IsReadOnlyTab").equals("Y"));
96     xmlDocument.setParameter("disabled", (isDisabled?"Y":"N"));
97     if (!isDisabled && getData("IsMandatory").equals("Y")) {
98       xmlDocument.setParameter("required", "true");
99       xmlDocument.setParameter("requiredClass", " required");
100     } else {
101       xmlDocument.setParameter("required", "false");
102       xmlDocument.setParameter("requiredClass", (isDisabled?" readonly":""));
103     }
104
105     xmlDocument.setParameter("callout", getOnChangeCode());
106
107     return replaceHTML(xmlDocument.print());
108   }
109
110   public String JavaDoc toXml() {
111     String JavaDoc[] discard = {"xx_PARAM", "xx_PARAMHIDDEN", "xx_HIDDEN"};
112     if (getData("IsDisplayed").equals("N")) {
113       if (getData("IsParameter").equals("Y")) discard[1] = new String JavaDoc("xx");
114       else discard[2] = new String JavaDoc("xx");
115     } else {
116       if (getData("IsParameter").equals("Y")) discard[0] = new String JavaDoc("xx");
117     }
118     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADMemoXML", discard).createXmlDocument();
119     xmlDocument.setParameter("columnName", getData("ColumnName"));
120     return replaceHTML(xmlDocument.print());
121   }
122
123   public String JavaDoc toJava() {
124     return "";
125   }
126 }
127
Popular Tags