KickJava   Java API By Example, From Geeks To Geeks.

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


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 WADImage extends WADControl {
25
26   public WADImage() {
27   }
28
29   public WADImage(Properties prop) {
30     setInfo(prop);
31     initialize();
32   }
33
34   public void initialize() {
35     addImport("searchs", "../../../../../web/js/searchs.js");
36     generateJSCode();
37   }
38
39   private void generateJSCode() {
40     if (getData("IsMandatory").equals("Y")) {
41       XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADImageJSValidation").createXmlDocument();
42
43       xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
44       setValidation(replaceHTML(xmlDocument.print()));
45     }
46     setCalloutJS();
47   }
48
49   public String JavaDoc getType() {
50     return "Image";
51   }
52
53   public String JavaDoc editMode() {
54     String JavaDoc[] discard = {"buttonxx"};
55     if (!getData("IsReadOnly").equals("Y") && !getData("IsReadOnlyTab").equals("Y") && !getData("IsUpdateable").equals("N")) discard[0] = "";
56     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADImage", discard).createXmlDocument();
57
58     xmlDocument.setParameter("columnName", getData("ColumnName"));
59     xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
60     xmlDocument.setParameter("name", getData("Name"));
61
62     xmlDocument.setParameter("callout", getOnChangeCode());
63
64     return replaceHTML(xmlDocument.print());
65   }
66
67   public String JavaDoc newMode() {
68     String JavaDoc[] discard = {"buttonxx"};
69     if (!getData("IsReadOnly").equals("Y") && !getData("IsReadOnlyTab").equals("Y")) discard[0] = "";
70     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADImage", discard).createXmlDocument();
71
72     xmlDocument.setParameter("columnName", getData("ColumnName"));
73     xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
74     xmlDocument.setParameter("name", getData("Name"));
75
76     xmlDocument.setParameter("callout", getOnChangeCode());
77
78     return replaceHTML(xmlDocument.print());
79   }
80
81   public String JavaDoc toXml() {
82     String JavaDoc[] discard = {"xx_PARAM", "xx_PARAM_R"};
83     if (getData("IsParameter").equals("Y")) {
84       discard[0] = new String JavaDoc("xx");
85       discard[1] = new String JavaDoc("xx_R");
86     }
87     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADImageXML", discard).createXmlDocument();
88
89     xmlDocument.setParameter("columnName", getData("ColumnName"));
90     return replaceHTML(xmlDocument.print());
91   }
92 }
93
Popular Tags