KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > utility > ToolBar


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.erpCommon.utility;
20
21 import org.openbravo.database.ConnectionProvider;
22 import java.util.Hashtable JavaDoc;
23 import java.util.Vector JavaDoc;
24 import org.apache.log4j.Logger ;
25
26 public class ToolBar {
27   static Logger log4j = Logger.getLogger(ToolBar.class);
28   ConnectionProvider conn;
29   String JavaDoc language = "en_US";
30   String JavaDoc servlet_action = "";
31   boolean isNew = false;
32   String JavaDoc keyfield = "";
33   String JavaDoc form = "document.forms[0]";
34   String JavaDoc grid_id = "";
35   String JavaDoc pdf = "";
36   boolean isDirectPrint = false;
37   String JavaDoc window_name = "";
38   String JavaDoc base_direction = "";
39   boolean debug = false;
40   boolean isSrcWindow = false;
41   boolean isFrame = false;
42   boolean isRelation = false;
43   Hashtable JavaDoc<String JavaDoc, HTMLElement> buttons = new Hashtable JavaDoc<String JavaDoc, HTMLElement>();
44
45   public ToolBar(ConnectionProvider _conn, String JavaDoc _language, String JavaDoc _action, boolean _isNew, String JavaDoc _keyINP, String JavaDoc _gridID, String JavaDoc _PDFName, boolean _isDirectPrinting, String JavaDoc _windowName, String JavaDoc _baseDirection, boolean _debug) {
46     this(_conn, _language, _action, _isNew, _keyINP, _gridID, _PDFName, _isDirectPrinting, _windowName, _baseDirection, _debug, false);
47   }
48
49   public ToolBar(ConnectionProvider _conn, String JavaDoc _language, String JavaDoc _action, boolean _isNew, String JavaDoc _keyINP, String JavaDoc _gridID, String JavaDoc _PDFName, boolean _isDirectPrinting, String JavaDoc _windowName, String JavaDoc _baseDirection, boolean _debug, boolean _isSrcWindow){
50     this(_conn, _language, _action, _isNew, _keyINP, _gridID, _PDFName, _isDirectPrinting, _windowName, _baseDirection, _debug, _isSrcWindow, false);
51   }
52   public ToolBar(ConnectionProvider _conn, String JavaDoc _language, String JavaDoc _action, boolean _isNew, String JavaDoc _keyINP, String JavaDoc _gridID, String JavaDoc _PDFName, boolean _isDirectPrinting, String JavaDoc _windowName, String JavaDoc _baseDirection, boolean _debug, boolean _isSrcWindow, boolean _isFrame) {
53     this.conn = _conn;
54     this.language = _language;
55     this.servlet_action = _action;
56     this.isNew = _isNew;
57     this.keyfield = _keyINP;
58     if (_gridID!=null) this.grid_id = _gridID;
59     if (_PDFName!=null) this.pdf = _PDFName;
60     this.isDirectPrint = _isDirectPrinting;
61     this.window_name = _windowName;
62     this.base_direction = _baseDirection;
63     this.debug = _debug;
64     this.isFrame = _isFrame;
65     int i=this.keyfield.lastIndexOf(".");
66     if (i!=-1) this.form = this.keyfield.substring(0, i);
67     this.isSrcWindow = _isSrcWindow;
68     createAllButtons();
69   }
70
71
72
73   public void removeElement(String JavaDoc name) {
74     try {
75       if (buttons!=null && !buttons.isEmpty()) buttons.remove(name);
76     } catch (NullPointerException JavaDoc ignored) {
77     }
78   }
79
80   private String JavaDoc getButtonScript(String JavaDoc name) {
81     if (name.equals("RELATED_INFO")) {
82       return "openServletNewWindow('DEFAULT', true, '../utility/UsedByLink.html', 'LINKS', null, true, 500, 600, true);";
83     } else if (name.equals("EDIT")) {
84       return "submitCommandForm('" + name + "', true, null, '" + servlet_action + (isSrcWindow?"":"_Relation") + ".html', '_self', null, " + (debug?"true":"false") + ");";
85     } else if (name.startsWith("SAVE")) {
86       return "submitCommandForm('SAVE_" + (isNew?"NEW":"EDIT") + name.substring(4) + "', true, null, '" + servlet_action + (isSrcWindow?"":"_Relation") + ".html', '_self', true, false);";
87     } else if (name.equals("TREE")) {
88       return "openServletNewWindow('DEFAULT', false, '../utility/WindowTree.html', 'TREE', null, null,625, 750, true);";
89     } else if (name.equals("ATTACHMENT")) {
90       return "openServletNewWindow('DEFAULT', false, '../businessUtility/TabAttachments_FS.html?inpKey=' + " + ((grid_id==null || grid_id.equals(""))?keyfield + ".value":"dojo.widget.byId('" + grid_id + "').getSelectedRows()") + ", 'ATTACHMENT', null, true, 600, 700, true);";
91     } else if (name.equals("EXCEL")) {
92       return "abrirExcel('" + servlet_action + "_Excel.xls?Command=RELATION_XLS', '_blank');";
93     } else if (name.equals("GRIDEXCEL")) {
94       return "openServletNewWindow('EXCEL', false, '../utility/ExportGrid.xls?inpTabId=' + document.forms[0].inpTabId.value, 'GRIDEXCEL', null, null, 500, 350, true );";
95     } else if (name.equals("GRIDCSV")) {
96       return "openServletNewWindow('CSV', false, '../utility/ExportGrid.csv?inpTabId=' + document.forms[0].inpTabId.value, 'GRIDCSV', null, null, 500, 350, true );";
97     } else if (name.equals("GRIDPDF")) {
98       return "openServletNewWindow('PDF', false, '../utility/ExportGrid.pdf?inpTabId=' + document.forms[0].inpTabId.value, 'GRIDPDF', null, null, 500, 350, true );";
99     } else if (name.equals("PRINT")) {
100       return "abrirPDFSession('" + pdf + "', '" + (isDirectPrint?"Printing":"") + "', " + keyfield + ".name, " + ((grid_id==null || grid_id.equals(""))?"null":"dojo.widget.byId('" + grid_id + "').getSelectedRows()") + ", " + ((grid_id==null || grid_id.equals(""))?"true":"null") + ");";
101     } else if (name.equals("UNDO")) {
102       return form + ".reset();displayLogic();";
103     } else if (name.equals("SEARCH")) {
104       return "abrirBusqueda('../businessUtility/Buscador.html', 'BUSCADOR', " + form + ".inpTabId.value, '" + window_name + "/" + servlet_action + (isSrcWindow?"":"_Relation") + ".html', " + form + ".inpwindowId.value, " + (debug?"true":"false") + ");";
105     } else if (grid_id!=null && !grid_id.equals("") && name.equals("PREVIOUS")) {
106       return "dojo.widget.byId('grid').goToPreviousRow();";
107     } else if (grid_id!=null && !grid_id.equals("") && name.equals("NEXT")) {
108       return "dojo.widget.byId('grid').goToNextRow();";
109     } else if (name.equals("DELETE_RELATION")) {
110       return "dojo.widget.byId('grid').deleteRow();";
111     } else if (name.equals("FIRST_RELATION")) {
112       return "dojo.widget.byId('grid').goToFirstRow();";
113       } else if (name.equals("LAST_RELATION")) {
114       return "dojo.widget.byId('grid').goToLastRow();";
115     } else {
116       return "submitCommandForm('" + (name.equals("REFRESH")?"DEFAULT":name) + "', false, null, '" + servlet_action + (isSrcWindow?"":"_Relation") + ".html', '"+(isFrame?"_parent":"_self")+"', null, " + (debug?"true":"false") + ");";
117     }
118   }
119
120
121   private void createAllButtons() {
122     buttons.put("NEW", new ToolBar_Button(base_direction, "New", Utility.messageBD(conn, "New", language), getButtonScript("NEW")));
123     buttons.put("EDIT", new ToolBar_Button(base_direction, "Edit", Utility.messageBD(conn, "Edit", language), getButtonScript("EDIT")));
124     buttons.put("RELATION", new ToolBar_Button(base_direction, "Relation", Utility.messageBD(conn, "Relation", language), getButtonScript("RELATION")));
125     buttons.put("FIND", new ToolBar_Button(base_direction, "Find", Utility.messageBD(conn, "Find", language), getButtonScript("FIND")));
126     buttons.put("SEPARATOR2", new ToolBar_Space(base_direction));
127     buttons.put("SAVE_RELATION", new ToolBar_Button(base_direction, "Save_Relation", Utility.messageBD(conn, "SaveRelation", language), getButtonScript("SAVE_RELATION")));
128     buttons.put("SAVE_NEW", new ToolBar_Button(base_direction, "Save_New", Utility.messageBD(conn, "SaveNew", language), getButtonScript("SAVE_NEW")));
129     buttons.put("SAVE_EDIT", new ToolBar_Button(base_direction, "Save", Utility.messageBD(conn, "SaveEdit", language), getButtonScript("SAVE_EDIT")));
130     buttons.put("SAVE_NEXT", new ToolBar_Button(base_direction, "Save_Next", Utility.messageBD(conn, "SaveNext", language), getButtonScript("SAVE_NEXT")));
131     buttons.put("SEPARATOR3", new ToolBar_Space(base_direction));
132     buttons.put("DELETE", new ToolBar_Button(base_direction, "Delete", Utility.messageBD(conn, "Delete", language), getButtonScript("DELETE")));
133     buttons.put("DELETE_RELATION", new ToolBar_Button(base_direction, "Delete", Utility.messageBD(conn, "Delete", language), getButtonScript("DELETE_RELATION")));
134     buttons.put("SEPARATOR4", new ToolBar_Space(base_direction));
135     //buttons.put("REFRESH", new ToolBar_Button(base_direction, "Refresh", Utility.messageBD(conn, "Refresh", language), getButtonScript("REFRESH")));
136
buttons.put("UNDO", new ToolBar_Button(base_direction, "Undo", Utility.messageBD(conn, "Undo", language), getButtonScript("UNDO")));
137     buttons.put("TREE", new ToolBar_Button(base_direction, "Tree", Utility.messageBD(conn, "Tree", language), getButtonScript("TREE")));
138     buttons.put("ATTACHMENT", new ToolBar_Button(base_direction, "Attachment", Utility.messageBD(conn, "Attachment", language), getButtonScript("ATTACHMENT")));
139     buttons.put("EXCEL", new ToolBar_Button(base_direction, "Excel", Utility.messageBD(conn, "ExportExcel", language), getButtonScript("EXCEL")));
140     buttons.put("GRIDEXCEL", new ToolBar_Button(base_direction, "ExportExcel", Utility.messageBD(conn, "ExportExcel", language), getButtonScript("GRIDEXCEL")));
141     buttons.put("GRIDCSV", new ToolBar_Button(base_direction, "ExportCsv", Utility.messageBD(conn, "ExportCsv", language), getButtonScript("GRIDCSV")));
142     buttons.put("GRIDPDF", new ToolBar_Button(base_direction, "ExportPDF", Utility.messageBD(conn, "ExportPDF", language), getButtonScript("GRIDPDF")));
143     if (pdf!=null && !pdf.equals("") && !pdf.equals("..")) buttons.put("PRINT", new ToolBar_Button(base_direction, "Print", Utility.messageBD(conn, "Print", language), getButtonScript("PRINT")));
144     buttons.put("SEARCH", new ToolBar_Button(base_direction, "Search", Utility.messageBD(conn, "Search", language), getButtonScript("SEARCH")));
145     buttons.put("SEARCH_FILTERED", new ToolBar_Button(base_direction, "SearchFiltered", Utility.messageBD(conn, "Search", language), getButtonScript("SEARCH")));
146     buttons.put("SEPARATOR5", new ToolBar_Space(base_direction));
147     buttons.put("FIRST", new ToolBar_Button(base_direction, "First", Utility.messageBD(conn, "GotoFirst", language), getButtonScript("FIRST")));
148     buttons.put("FIRST_RELATION", new ToolBar_Button(base_direction, "First", Utility.messageBD(conn, "GotoFirst", language), getButtonScript("FIRST_RELATION")));
149     buttons.put("PREVIOUS", new ToolBar_Button(base_direction, "Previous", Utility.messageBD(conn, "GotoPrevious", language), getButtonScript("PREVIOUS")));
150     buttons.put("NEXT", new ToolBar_Button(base_direction, "Next", Utility.messageBD(conn, "GotoNext", language), getButtonScript("NEXT")));
151     buttons.put("LAST", new ToolBar_Button(base_direction, "Last", Utility.messageBD(conn, "GotoLast", language), getButtonScript("LAST")));
152     buttons.put("LAST_RELATION", new ToolBar_Button(base_direction, "Last", Utility.messageBD(conn, "GotoLast", language), getButtonScript("LAST_RELATION")));
153     
154     
155     buttons.put("SEPARATOR6", new ToolBar_Space(base_direction));
156   // buttons.put("PREVIOUS_RELATION", new ToolBar_Button(base_direction, "PreviousRange", Utility.messageBD(conn, "GotoPreviousRange", language), getButtonScript("PREVIOUS_RELATION")));
157
buttons.put("PREVIOUS_RELATION", new ToolBar_Button(base_direction, "Previous", Utility.messageBD(conn, "GotoPreviousRange", language), getButtonScript("PREVIOUS_RELATION")));
158     buttons.put("PREVIOUS_RELATION_DISABLED", new ToolBar_Button(base_direction, "PreviousRangeDisabled", Utility.messageBD(conn, "GotoPreviousRange", language), ""));
159    // buttons.put("NEXT_RELATION", new ToolBar_Button(base_direction, "NextRange", Utility.messageBD(conn, "GotoNextRange", language), getButtonScript("NEXT_RELATION")));
160
buttons.put("NEXT_RELATION", new ToolBar_Button(base_direction, "Next", Utility.messageBD(conn, "GotoNextRange", language), getButtonScript("NEXT_RELATION")));
161     buttons.put("NEXT_RELATION_DISABLED", new ToolBar_Button(base_direction, "NextRangeDisabled", Utility.messageBD(conn, "GotoNextRange", language), ""));
162     
163     
164     
165     
166     buttons.put("SEPARATOR7", new ToolBar_Space(base_direction));
167     buttons.put("CAPTURE", new ToolBar_Button(base_direction, "Capture", Utility.messageBD(conn, "Capture", language), ""));
168     buttons.put("CHECK_CONTENT", new ToolBar_Button(base_direction, "CheckContent", Utility.messageBD(conn, "CheckContent", language), ""));
169     buttons.put("CHECK_ELEMENT", new ToolBar_Button(base_direction, "CheckElement", Utility.messageBD(conn, "CheckElement", language), ""));
170     buttons.put("HR1", new ToolBar_HR());
171     buttons.put("RELATED_INFO", new ToolBar_Button(base_direction, "RelatedInfo", Utility.messageBD(conn, "Linked Items", language), getButtonScript("RELATED_INFO")));
172   }
173
174   public void prepareInfoTemplate(boolean hasPrevious, boolean hasNext, boolean isTest) {
175     removeElement("NEW");
176     removeElement("EDIT");
177     removeElement("RELATION");
178     removeElement("FIND");
179     removeElement("SEPARATOR2");
180     removeElement("SAVE_RELATION");
181     removeElement("SAVE_NEW");
182     removeElement("SAVE_EDIT");
183     removeElement("SAVE_NEXT");
184     removeElement("SEPARATOR3");
185     removeElement("DELETE");
186     removeElement("DELETE_RELATION");
187     removeElement("SEPARATOR4");
188     //removeElement("REFRESH");
189
removeElement("UNDO");
190     removeElement("TREE");
191     removeElement("ATTACHMENT");
192     removeElement("EXCEL");
193     removeElement("GRIDEXCEL");
194     removeElement("GRIDCSV");
195     removeElement("GRIDPDF");
196     removeElement("PRINT");
197     removeElement("SEARCH");
198     removeElement("SEARCH_FILTERED");
199     removeElement("SEPARATOR5");
200     removeElement("FIRST");
201     removeElement("FIRST_RELATION");
202     removeElement("PREVIOUS");
203     removeElement("NEXT");
204     removeElement("LAST");
205     removeElement("LAST_RELATION");
206     removeElement("SEPARATOR6");
207
208     if (!hasPrevious) removeElement("PREVIOUS_RELATION");
209     else removeElement("PREVIOUS_RELATION_DISABLED");
210     if (!hasNext) removeElement("NEXT_RELATION");
211     else removeElement("NEXT_RELATION_DISABLED");
212     if (!isTest) removeAllTests();
213   }
214
215   public void prepareEditionTemplate(boolean hasTree, boolean isFiltered, boolean isTest, boolean isReadOnly) {
216     removeElement("EDIT");
217     removeElement("RELATION");
218     removeElement("DELETE_RELATION");
219     removeElement("EXCEL");
220     removeElement("GRIDEXCEL");
221     removeElement("GRIDCSV");
222     removeElement("GRIDPDF");
223     removeElement("FIRST_RELATION");
224     removeElement("LAST_RELATION");
225     removeElement("FIND");
226     
227     
228     removeElement("PREVIOUS_RELATION");
229     removeElement("PREVIOUS_RELATION_DISABLED");
230     removeElement("NEXT_RELATION");
231     removeElement("NEXT_RELATION_DISABLED");
232     
233     if (!hasTree) removeElement("TREE");
234     if (isNew) {
235       removeElement("SAVE_NEXT");
236       removeElement("DELETE");
237       removeElement("ATTACHMENT");
238     }
239     if (isFiltered) removeElement("SEARCH");
240     else removeElement("SEARCH_FILTERED");
241     if (!isTest) removeAllTests();
242     if (isReadOnly) removeReadOnly();
243   }
244
245   public void prepareRelationTemplate(boolean hasTree, boolean isFiltered, boolean isTest, boolean isReadOnly) {
246     isRelation = true;
247     removeElement("EDIT");
248     removeElement("RELATION");
249     removeElement("DELETE");
250     removeElement("SAVE_RELATION");
251     removeElement("SAVE_NEW");
252     removeElement("SAVE_EDIT");
253     removeElement("SAVE_NEXT");
254     removeElement("UNDO");
255     removeElement("FIRST");
256     removeElement("LAST");
257     removeElement("FIND");
258     removeElement("EXCEL");
259     
260     removeElement("PREVIOUS_RELATION");
261     removeElement("PREVIOUS_RELATION_DISABLED");
262     removeElement("NEXT_RELATION");
263     removeElement("NEXT_RELATION_DISABLED");
264     
265     if (!hasTree) removeElement("TREE");
266     if (isFiltered) removeElement("SEARCH");
267     else removeElement("SEARCH_FILTERED");
268     if (!isTest) removeAllTests();
269     if (isReadOnly) removeReadOnly();
270   }
271
272   //AL New toolbars
273
public void prepareSimpleToolBarTemplateFrame() {
274   
275   }
276   public void prepareSimpleToolBarTemplate() {
277     removeElement("SEPARATOR1");
278     removeElement("NEW");
279     removeElement("EDIT");
280     removeElement("RELATION");
281     removeElement("FIND");
282     removeElement("SEPARATOR2");
283     removeElement("SAVE_RELATION");
284     removeElement("SAVE_NEW");
285     removeElement("SAVE_EDIT");
286     removeElement("SAVE_NEXT");
287     removeElement("DELETE");
288     removeElement("DELETE_RELATION");
289     removeElement("UNDO");
290     removeElement("TREE");
291     removeElement("ATTACHMENT");
292     removeElement("EXCEL");
293     removeElement("GRIDEXCEL");
294     removeElement("GRIDCSV");
295     removeElement("GRIDPDF");
296     removeElement("SEARCH");
297     removeElement("SEARCH_FILTERED");
298     removeElement("ORDERBY");
299     removeElement("ORDERBY_FILTERED");
300     removeElement("FIRST");
301     removeElement("FIRST_RELATION");
302     removeElement("PREVIOUS");
303     removeElement("NEXT");
304     removeElement("LAST");
305     removeElement("LAST_RELATION");
306     removeElement("PREVIOUS_RELATION");
307     removeElement("PREVIOUS_RELATION_DISABLED");
308     removeElement("NEXT_RELATION");
309     removeElement("NEXT_RELATION_DISABLED");
310     removeElement("CAPTURE");
311     removeElement("CHECK_CONTENT");
312     removeElement("CHECK_ELEMENT");
313     if (pdf!=null && !pdf.equals("") && !pdf.equals(".."))
314        buttons.put("PRINT", new ToolBar_Button(base_direction, "Print", Utility.messageBD(conn, "Print", language), pdf));
315     removeElement("RELATED_INFO");
316   }
317
318   //Simple toolbar with save button
319
public void prepareSimpleSaveToolBarTemplate() {
320     removeElement("RELATED_INFO");
321     removeElement("SEPARATOR1");
322     removeElement("NEW");
323     removeElement("EDIT");
324     removeElement("RELATION");
325     removeElement("FIND");
326     removeElement("SEPARATOR2");
327     removeElement("SAVE_RELATION");
328     removeElement("SAVE_NEW");
329     removeElement("SAVE_NEXT");
330     removeElement("DELETE");
331     removeElement("DELETE_RELATION");
332     removeElement("UNDO");
333     removeElement("TREE");
334     removeElement("ATTACHMENT");
335     removeElement("EXCEL");
336     removeElement("GRIDEXCEL");
337     removeElement("GRIDCSV");
338     removeElement("GRIDPDF");
339     removeElement("SEARCH");
340     removeElement("SEARCH_FILTERED");
341     removeElement("ORDERBY");
342     removeElement("ORDERBY_FILTERED");
343     removeElement("FIRST");
344     removeElement("FIRST_RELATION");
345     removeElement("PREVIOUS");
346     removeElement("NEXT");
347     removeElement("LAST");
348     removeElement("LAST_RELATION");
349     removeElement("PREVIOUS_RELATION");
350     removeElement("PREVIOUS_RELATION_DISABLED");
351     removeElement("NEXT_RELATION");
352     removeElement("NEXT_RELATION_DISABLED");
353     removeElement("CAPTURE");
354     removeElement("CHECK_CONTENT");
355     removeElement("CHECK_ELEMENT");
356     if (pdf!=null && !pdf.equals("") && !pdf.equals(".."))
357        buttons.put("PRINT", new ToolBar_Button(base_direction, "Print", Utility.messageBD(conn, "Print", language), pdf));
358   }
359   
360   public void prepareRelationBarTemplate(boolean hasPrevious, boolean hasNext) {
361     prepareRelationBarTemplate(hasPrevious, hasNext,"");
362   }
363   public void prepareRelationBarTemplate(boolean hasPrevious, boolean hasNext, String JavaDoc excelScript) {
364     removeElement("SEPARATOR1");
365     removeElement("NEW");
366     removeElement("EDIT");
367     removeElement("RELATION");
368     removeElement("FIND");
369     removeElement("SEPARATOR2");
370     removeElement("SAVE_RELATION");
371     removeElement("SAVE_NEW");
372     removeElement("SAVE_EDIT");
373     removeElement("SAVE_NEXT");
374     removeElement("DELETE");
375     removeElement("DELETE_RELATION");
376     removeElement("UNDO");
377     removeElement("TREE");
378     removeElement("ATTACHMENT");
379     removeElement("EXCEL");
380     removeElement("GRIDEXCEL");
381     removeElement("GRIDCSV");
382     removeElement("GRIDPDF");
383     removeElement("SEARCH");
384     removeElement("SEARCH_FILTERED");
385     removeElement("ORDERBY");
386     removeElement("ORDERBY_FILTERED");
387     removeElement("FIRST");
388     removeElement("FIRST_RELATION");
389     removeElement("PREVIOUS");
390     removeElement("NEXT");
391     removeElement("LAST");
392     removeElement("LAST_RELATION");
393   
394     removeElement(hasPrevious?"PREVIOUS_RELATION_DISABLED":"PREVIOUS_RELATION");
395     removeElement(hasNext?"NEXT_RELATION_DISABLED":"NEXT_RELATION");
396     
397     removeElement("CAPTURE");
398     removeElement("CHECK_CONTENT");
399     removeElement("CHECK_ELEMENT");
400     if (pdf!=null && !pdf.equals("") && !pdf.equals(".."))
401        buttons.put("PRINT", new ToolBar_Button(base_direction, "Print", Utility.messageBD(conn, "Print", language), pdf));
402     if (!excelScript.equals("") && excelScript != null)
403         buttons.put("EXCEL", new ToolBar_Button(base_direction, "Excel", Utility.messageBD(conn, "ExportExcel", language), excelScript));
404   }
405     public void prepareSimpleExcelToolBarTemplate(String JavaDoc excelScript) {
406     removeElement("SEPARATOR1");
407     removeElement("NEW");
408     removeElement("EDIT");
409     removeElement("RELATION");
410     removeElement("FIND");
411     removeElement("SEPARATOR2");
412     removeElement("SAVE_RELATION");
413     removeElement("SAVE_NEW");
414     removeElement("SAVE_EDIT");
415     removeElement("SAVE_NEXT");
416     removeElement("DELETE");
417     removeElement("DELETE_RELATION");
418     removeElement("UNDO");
419     removeElement("TREE");
420     removeElement("ATTACHMENT");
421     removeElement("GRIDEXCEL");
422     removeElement("GRIDCSV");
423     removeElement("GRIDPDF");
424     removeElement("SEARCH");
425     removeElement("SEARCH_FILTERED");
426     removeElement("ORDERBY");
427     removeElement("ORDERBY_FILTERED");
428     removeElement("FIRST");
429     removeElement("FIRST_RELATION");
430     removeElement("PREVIOUS");
431     removeElement("NEXT");
432     removeElement("LAST");
433     removeElement("LAST_RELATION");
434     removeElement("PREVIOUS_RELATION");
435     removeElement("PREVIOUS_RELATION_DISABLED");
436     removeElement("NEXT_RELATION");
437     removeElement("NEXT_RELATION_DISABLED");
438     removeElement("CAPTURE");
439     removeElement("CHECK_CONTENT");
440     removeElement("CHECK_ELEMENT");
441
442     if (!excelScript.equals("") && excelScript != null)
443         buttons.put("EXCEL", new ToolBar_Button(base_direction, "Excel", Utility.messageBD(conn, "ExportExcel", language), excelScript));
444
445   }
446   //GD Toolbar with Menu, Refresh and Excel buttons
447
public void prepareExcelToolBarTemplate() {
448     removeElement("NEW");
449     removeElement("EDIT");
450     removeElement("RELATION");
451     removeElement("FIND");
452     removeElement("SEPARATOR2");
453     removeElement("SAVE_RELATION");
454     removeElement("SAVE_NEW");
455     removeElement("SAVE_EDIT");
456     removeElement("SAVE_NEXT");
457     removeElement("DELETE");
458     removeElement("DELETE_RELATION");
459     removeElement("UNDO");
460     removeElement("TREE");
461     removeElement("GRIDEXCEL");
462     removeElement("GRIDCSV");
463     removeElement("GRIDPDF");
464     removeElement("ATTACHMENT");
465     removeElement("SEARCH");
466     removeElement("SEARCH_FILTERED");
467     removeElement("ORDERBY");
468     removeElement("ORDERBY_FILTERED");
469     removeElement("FIRST");
470     removeElement("FIRST_RELATION");
471     removeElement("PREVIOUS");
472     removeElement("NEXT");
473     removeElement("LAST");
474     removeElement("LAST_RELATION");
475     removeElement("PREVIOUS_RELATION");
476     removeElement("PREVIOUS_RELATION_DISABLED");
477     removeElement("NEXT_RELATION");
478     removeElement("NEXT_RELATION_DISABLED");
479     removeElement("CAPTURE");
480     removeElement("CHECK_CONTENT");
481     removeElement("CHECK_ELEMENT");
482   }
483
484 //AL
485
public void prepareSortableTemplate(boolean isTest) {
486     removeElement("NEW");
487     removeElement("EDIT");
488     removeElement("RELATION");
489     removeElement("SAVE_RELATION");
490     removeElement("SAVE_NEW");
491     removeElement("SAVE_NEXT");
492     removeElement("DELETE");
493     removeElement("DELETE_RELATION");
494     removeElement("UNDO");
495     removeElement("TREE");
496     removeElement("ATTACHMENT");
497     removeElement("EXCEL");
498     removeElement("GRIDEXCEL");
499     removeElement("GRIDCSV");
500     removeElement("GRIDPDF");
501     removeElement("SEARCH");
502     removeElement("SEARCH_FILTERED");
503     removeElement("ORDERBY");
504     removeElement("ORDERBY_FILTERED");
505     removeElement("FIRST");
506     removeElement("FIRST_RELATION");
507     removeElement("PREVIOUS");
508     removeElement("NEXT");
509     removeElement("LAST");
510     removeElement("LAST_RELATION");
511     removeElement("PREVIOUS_RELATION");
512     removeElement("PREVIOUS_RELATION_DISABLED");
513     removeElement("NEXT_RELATION");
514     removeElement("NEXT_RELATION_DISABLED");
515     removeElement("FIND");
516     removeElement("RELATED_INFO");
517     if (!isTest) removeAllTests();
518   }
519
520   public void prepareQueryTemplate(boolean hasPrevious, boolean hasNext, boolean isTest) {
521     removeElement("NEW");
522     removeElement("EDIT");
523     removeElement("RELATION");
524     removeElement("SAVE_RELATION");
525     removeElement("SAVE_NEW");
526     removeElement("SAVE_EDIT");
527     removeElement("SAVE_NEXT");
528     removeElement("DELETE");
529     removeElement("DELETE_RELATION");
530     removeElement("UNDO");
531     removeElement("TREE");
532     removeElement("GRIDEXCEL");
533     removeElement("GRIDCSV");
534     removeElement("GRIDPDF");
535     removeElement("ATTACHMENT");
536     removeElement("SEARCH");
537     removeElement("SEARCH_FILTERED");
538     removeElement("ORDERBY");
539     removeElement("ORDERBY_FILTERED");
540     removeElement("FIRST");
541     removeElement("LAST");
542     if (!hasPrevious) removeElement("PREVIOUS_RELATION");
543     else removeElement("PREVIOUS_RELATION_DISABLED");
544     if (!hasNext) removeElement("NEXT_RELATION");
545     else removeElement("NEXT_RELATION_DISABLED");
546     if (!isTest) removeAllTests();
547   }
548
549   public void removeAllTests() {
550     removeElement("CAPTURE");
551     removeElement("CHECK_CONTENT");
552     removeElement("CHECK_ELEMENT");
553   }
554
555   public void removeReadOnly() {
556     removeElement("NEW");
557     removeElement("SAVE_NEW");
558     removeElement("SAVE_RELATION");
559     removeElement("SAVE_EDIT");
560     removeElement("SAVE_NEXT");
561     removeElement("DELETE");
562     removeElement("DELETE_RELATION");
563   }
564
565   private String JavaDoc transformElementsToString(HTMLElement element, Vector JavaDoc<String JavaDoc> vecLastType, boolean isReference) {
566     if (element==null) return "";
567     if (vecLastType==null) vecLastType = new Vector JavaDoc<String JavaDoc>(0);
568     StringBuffer JavaDoc sbElement = new StringBuffer JavaDoc();
569     String JavaDoc lastType = "";
570     if (vecLastType.size()>0) lastType = vecLastType.elementAt(0);
571     if (lastType.equals("SPACE") && element.elementType().equals("SPACE")) return "";
572     if (isReference) {
573       sbElement.append("<TD width=\"1\">");
574       sbElement.append("<IMG SRC=\"").append(base_direction).append("/images/blank.gif\" class=\"Main_ToolBar_textlabel_bg_left\" border=\"0\">");
575       sbElement.append("</TD>\n");
576       sbElement.append("<TD class=\"Main_ToolBar_textlabel_bg_body\">");
577       sbElement.append("<a class=\"Main_ToolBar_text_relatedinfo\" HREF=\"#\" onclick=\"openServletNewWindow('DEFAULT', true, '../utility/UsedByLink.html', 'LINKS', null, true, 500, 600, true);\">").append(Utility.messageBD(conn, "Linked Items", language)).append("</a></TD>\n");
578     }
579     sbElement.append("<td ");
580     if (isReference) sbElement.append("class=\"Main_ToolBar_textlabel_bg_right\" ");
581     if (element.elementType().equals("SPACE")) sbElement.append("class=\"Main_ToolBar_Separator_cell\" ");
582     else if (!element.elementType().equals("HR")) sbElement.append("width=\"").append(element.getWidth()).append("\" ");
583     else sbElement.append("class=\"Main_ToolBar_Space\"");
584     sbElement.append(">");
585     if (!element.elementType().equals("HR")) sbElement.append(element);
586     sbElement.append("</td>\n");
587     vecLastType.clear();
588     vecLastType.addElement(element.elementType());
589     return sbElement.toString();
590   }
591
592   public String JavaDoc toString() {
593     StringBuffer JavaDoc toolbar = new StringBuffer JavaDoc();
594     toolbar.append("<table class=\"Main_ContentPane_ToolBar Main_ToolBar_bg\" id=\"tdToolBar\">\n");
595     toolbar.append("<tr>\n");
596     if (buttons!=null) {
597       Vector JavaDoc<String JavaDoc> lastType = new Vector JavaDoc<String JavaDoc>(0);
598       toolbar.append(transformElementsToString(buttons.get("NEW"), lastType, false));
599       toolbar.append(transformElementsToString(buttons.get("EDIT"), lastType, false));
600       toolbar.append(transformElementsToString(buttons.get("RELATION"), lastType, false));
601       toolbar.append(transformElementsToString(buttons.get("FIND"), lastType, false));
602       toolbar.append(transformElementsToString(buttons.get("SEPARATOR2"), lastType, false));
603       toolbar.append(transformElementsToString(buttons.get("SAVE_RELATION"), lastType, false));
604       toolbar.append(transformElementsToString(buttons.get("SAVE_NEW"), lastType, false));
605       toolbar.append(transformElementsToString(buttons.get("SAVE_EDIT"), lastType, false));
606       toolbar.append(transformElementsToString(buttons.get("SAVE_NEXT"), lastType, false));
607       toolbar.append(transformElementsToString(buttons.get("SEPARATOR3"), lastType, false));
608       toolbar.append(transformElementsToString(buttons.get("DELETE"), lastType, false));
609       toolbar.append(transformElementsToString(buttons.get("DELETE_RELATION"), lastType, false));
610       toolbar.append(transformElementsToString(buttons.get("SEPARATOR4"), lastType, false));
611       //toolbar.append(transformElementsToString(buttons.get("REFRESH"), lastType, false));
612
toolbar.append(transformElementsToString(buttons.get("UNDO"), lastType, false));
613       toolbar.append(transformElementsToString(buttons.get("TREE"), lastType, false));
614       toolbar.append(transformElementsToString(buttons.get("ATTACHMENT"), lastType, false));
615       toolbar.append(transformElementsToString(buttons.get("EXCEL"), lastType, false));
616       toolbar.append(transformElementsToString(buttons.get("GRIDEXCEL"), lastType, false));
617       toolbar.append(transformElementsToString(buttons.get("GRIDCSV"), lastType, false));
618       toolbar.append(transformElementsToString(buttons.get("GRIDPDF"), lastType, false));
619       toolbar.append(transformElementsToString(buttons.get("PRINT"), lastType, false));
620       toolbar.append(transformElementsToString(buttons.get("SEARCH"), lastType, false));
621       toolbar.append(transformElementsToString(buttons.get("SEARCH_FILTERED"), lastType, false));
622       toolbar.append(transformElementsToString(buttons.get("ORDERBY"), lastType, false));
623       toolbar.append(transformElementsToString(buttons.get("ORDERBY_FILTERED"), lastType, false));
624       toolbar.append(transformElementsToString(buttons.get("SEPARATOR5"), lastType, false));
625       toolbar.append(transformElementsToString(buttons.get("FIRST"), lastType, false));
626       toolbar.append(transformElementsToString(buttons.get("FIRST_RELATION"), lastType, false));
627       toolbar.append(transformElementsToString(buttons.get("PREVIOUS"), lastType, false));
628       //toolbar.append("<td class=\"TB_Bookmark\" width=\"5px\"><nobr id=\"bookmark\"></nobr></td>\n");
629
toolbar.append(transformElementsToString(buttons.get("NEXT"), lastType, false));
630       toolbar.append(transformElementsToString(buttons.get("LAST"), lastType, false));
631       toolbar.append(transformElementsToString(buttons.get("LAST_RELATION"), lastType, false));
632       if (isRelation) {
633         toolbar.append("<TD width=\"1\"><IMG SRC=\"").append(base_direction).append("/images/blank.gif\" class=\"Main_ToolBar_textlabel_bg_left\" border=\"0\">");
634         toolbar.append("</TD>\n");
635         toolbar.append("<TD class=\"Main_ToolBar_textlabel_bg_body\">\n");
636         toolbar.append("<nobr id=\"bookmark\" class=\"Main_ToolBar_text_bookmark\">");
637         toolbar.append("</nobr>");
638         toolbar.append("</TD>\n");
639         toolbar.append("<TD width=\"1\">");
640         toolbar.append("<IMG SRC=\"").append(base_direction).append("/images/blank.gif\" class=\"Main_ToolBar_textlabel_bg_right\" border=\"0\">");
641         toolbar.append("</TD>\n");
642       }
643       toolbar.append(transformElementsToString(buttons.get("SEPARATOR6"), lastType, false));
644       toolbar.append(transformElementsToString(buttons.get("PREVIOUS_RELATION"), lastType, false));
645       toolbar.append(transformElementsToString(buttons.get("PREVIOUS_RELATION_DISABLED"), lastType, false));
646       toolbar.append(transformElementsToString(buttons.get("NEXT_RELATION"), lastType, false));
647       toolbar.append(transformElementsToString(buttons.get("NEXT_RELATION_DISABLED"), lastType, false));
648       toolbar.append(transformElementsToString(buttons.get("SEPARATOR7"), lastType, false));
649       toolbar.append(transformElementsToString(buttons.get("CAPTURE"), lastType, false));
650       toolbar.append(transformElementsToString(buttons.get("CHECK_CONTENT"), lastType, false));
651       toolbar.append(transformElementsToString(buttons.get("CHECK_ELEMENT"), lastType, false));
652       toolbar.append(transformElementsToString(buttons.get("HR1"), lastType, false));
653       toolbar.append(transformElementsToString(buttons.get("RELATED_INFO"), lastType, true));
654     }
655     toolbar.append("</tr>\n");
656     toolbar.append("</table>\n");
657     return toolbar.toString();
658   }
659 }
660
Popular Tags