KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > toolbar > ToolButtonTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.toolbar;
14
15 import javax.servlet.jsp.JspException JavaDoc;
16 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
17
18 import org.apache.log4j.Logger;
19
20 import com.tonbeller.wcf.controller.RequestContext;
21
22 /**
23  * @author av
24  */

25 public abstract class ToolButtonTag extends TagSupport JavaDoc {
26   String JavaDoc img;
27   String JavaDoc radioGroup;
28   String JavaDoc tooltip;
29   String JavaDoc visibleRef;
30   String JavaDoc role;
31   
32     private static Logger logger = Logger.getLogger(ToolButtonTag.class);
33
34   /**
35    * Returns the radioGroup.
36    * @return String
37    */

38   public String JavaDoc getRadioGroup() {
39     return radioGroup;
40   }
41
42   /**
43    * Sets the radioGroup.
44    * @param radioGroup The radioGroup to set
45    */

46   public void setRadioGroup(String JavaDoc radioGroup) {
47     this.radioGroup = radioGroup;
48   }
49
50   public int doStartTag() throws JspException JavaDoc {
51     logger.info("enter " + id);
52     RequestContext context = RequestContext.instance();
53
54     // find the toolbar
55
ToolBarTag tbt = (ToolBarTag)findAncestorWithClass(this, ToolBarTag.class);
56     if (tbt == null)
57       throw new JspException JavaDoc("ToolButtonTag must be nested in ToolBarTag");
58     ToolBar tbar = tbt.getToolBar();
59
60     ToolButtonModel tbm = getToolButtonModel(context);
61     
62     // create a button
63
ToolButton tbut = new ToolButton(tbm, getImg()+"-up", getImg()+"-down");
64     tbut.setId(getId());
65     tbut.setRadioGroup(getRadioGroup());
66     tbut.setTooltip(tooltip);
67     tbut.setVisibleExpr(visibleRef);
68     tbut.setRole(role);
69     tbar.addButton(tbut);
70   
71     logger.info("leave " + id);
72     return EVAL_BODY_INCLUDE;
73   }
74
75
76   /**
77    * factory method to create the button model
78    */

79   protected abstract ToolButtonModel getToolButtonModel(RequestContext context) throws JspException JavaDoc;
80
81   /**
82    * Returns the img.
83    * @return String
84    */

85   public String JavaDoc getImg() {
86     return img;
87   }
88
89   /**
90    * Sets the img.
91    * @param img The img to set
92    */

93   public void setImg(String JavaDoc img) {
94     this.img = img;
95   }
96
97   /**
98    * @return
99    */

100   public String JavaDoc getTooltip() {
101     return tooltip;
102   }
103
104   /**
105    * @param string
106    */

107   public void setTooltip(String JavaDoc string) {
108     tooltip = string;
109   }
110
111   /**
112    * @param string
113    */

114   public void setVisibleRef(String JavaDoc string) {
115     visibleRef = string;
116   }
117
118   /**
119    * @param role
120    */

121   public void setRole(String JavaDoc role) {
122     this.role = role;
123   }
124
125   /**
126    * @return
127    */

128   public String JavaDoc getRole() {
129     return role;
130   }
131
132   /**
133    * @return
134    */

135   public String JavaDoc getVisibleRef() {
136     return visibleRef;
137   }
138
139 }
140
Popular Tags