KickJava   Java API By Example, From Geeks To Geeks.

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


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.utils.FormatUtilities;
23 import org.openbravo.xmlEngine.XmlDocument;
24
25 public class WADButton extends WADControl {
26
27   public WADButton() {
28   }
29
30   public WADButton(Properties prop) {
31     setInfo(prop);
32     initialize();
33   }
34
35   public void initialize() {
36     generateJSCode();
37   }
38
39   private void generateJSCode() {
40     setValidation("");
41     setCalloutJS();
42   }
43
44   public String JavaDoc getType() {
45     return "Button_CenterAlign";
46   }
47
48   public String JavaDoc editMode() {
49     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADButton").createXmlDocument();
50
51     xmlDocument.setParameter("columnName", getData("ColumnName"));
52     xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
53     xmlDocument.setParameter("name", getData("Name"));
54
55     xmlDocument.setParameter("callout", getOnChangeCode());
56     StringBuffer JavaDoc text = new StringBuffer JavaDoc();
57     text = new StringBuffer JavaDoc();
58     if (getData("MappingName").equals("")) {
59       text.append("openServletNewWindow('BUTTON").append(FormatUtilities.replace(getData("ColumnName"))).append(getData("AD_Process_ID"));
60       text.append("', false, '").append(getData("TabName")).append("_Edition.html', 'BUTTON', null, true");
61       if (getData("ColumnName").equalsIgnoreCase("CreateFrom")) text.append(",600, 900");
62       else text.append(", 600, 900");
63       text.append(");");
64     } else {
65       text.append("openServletNewWindow('DEFAULT', false, '..");
66       if (!getData("MappingName").startsWith("/")) text.append("/");
67       text.append(getData("MappingName")).append("', 'BUTTON', '").append(getData("AD_Process_ID")).append("', true");
68       text.append(",600, 900);");
69     }
70     /*if (getData("IsReadOnly").equals("Y") || getData("IsReadOnlyTab").equals("Y") || getData("IsUpdateable").equals("N")) {
71       xmlDocument.setParameter("action", "");
72     } else */
xmlDocument.setParameter("action", text.toString());
73     return replaceHTML(xmlDocument.print());
74   }
75
76   public String JavaDoc newMode() {
77     XmlDocument xmlDocument = getReportEngine().readXmlTemplate("org/openbravo/wad/controls/WADButton").createXmlDocument();
78
79     xmlDocument.setParameter("columnName", getData("ColumnName"));
80     xmlDocument.setParameter("columnNameInp", getData("ColumnNameInp"));
81     xmlDocument.setParameter("name", getData("Name"));
82
83     xmlDocument.setParameter("callout", getOnChangeCode());
84     StringBuffer JavaDoc text = new StringBuffer JavaDoc();
85     text = new StringBuffer JavaDoc();
86     if (getData("MappingName").equals("")) {
87       text.append("openServletNewWindow('BUTTON").append(FormatUtilities.replace(getData("ColumnName"))).append(getData("AD_Process_ID"));
88       text.append("', false, '").append(getData("TabName")).append("_Edition.html', 'BUTTON', null, true");
89       if (getData("ColumnName").equalsIgnoreCase("CreateFrom")) text.append(",600, 900");
90       else text.append(", 600, 900");
91       text.append(");");
92     } else {
93       text.append("openServletNewWindow('DEFAULT', false, '..");
94       if (!getData("MappingName").startsWith("/")) text.append("/");
95       text.append(getData("MappingName")).append("', 'BUTTON', '").append(getData("AD_Process_ID")).append("', true");
96       text.append(",600, 900);");
97     }
98     /*if (getData("IsReadOnly").equals("Y") || getData("IsReadOnlyTab").equals("Y")) {
99       xmlDocument.setParameter("action", "");
100     } else */
xmlDocument.setParameter("action", text.toString());
101     return replaceHTML(xmlDocument.print());
102   }
103
104   public String JavaDoc toXml() {
105     StringBuffer JavaDoc text = new StringBuffer JavaDoc();
106     if (getData("IsParameter").equals("Y")) {
107       text.append("<PARAMETER id=\"").append(getData("ColumnName"));
108       text.append("\" name=\"").append(getData("ColumnName"));
109       text.append("\" attribute=\"value\"/>");
110       if (getData("IsDisplayed").equals("Y") && !getData("AD_Reference_Value_ID").equals("") && !getData("ColumnName").equalsIgnoreCase("ChangeProjectStatus")) {
111         text.append("\n<PARAMETER id=\"").append(getData("ColumnName")).append("_BTN\" name=\"");
112         text.append(getData("ColumnName"));
113         text.append("_BTN\" replaceCharacters=\"htmlPreformated\"/>");
114       }
115     } else {
116       text.append("<FIELD id=\"").append(getData("ColumnName"));
117       text.append("\" attribute=\"value\">").append(getData("ColumnName")).append("</FIELD>");
118       if (getData("IsDisplayed").equals("Y") && !getData("AD_Reference_Value_ID").equals("") && !getData("ColumnName").equalsIgnoreCase("ChangeProjectStatus")) {
119         text.append("\n<FIELD id=\"").append(getData("ColumnName")).append("_BTN\" replaceCharacters=\"htmlPreformated\">");
120         text.append(getData("ColumnName")).append("_BTN</FIELD>");
121       }
122     }
123     return text.toString();
124   }
125
126   public String JavaDoc toJava() {
127     return "";
128   }
129 }
130
Popular Tags