KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > exceptions > web > DuplicatesTagHandler


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.exceptions.web;
20
21 import java.io.IOException JavaDoc;
22 import javax.servlet.jsp.tagext.*;
23 import javax.servlet.jsp.JspWriter JavaDoc;
24 import javax.servlet.jsp.JspException JavaDoc;
25 import org.netbeans.modules.exceptions.entity.Issue;
26
27 /**
28  *
29  * @author Jan Horvath
30  * @version
31  */

32
33 public class DuplicatesTagHandler extends SimpleTagSupport {
34     private static final int MAX_WIDTH = 60;
35     private static final String JavaDoc COLOR = "#EE6B00";
36     
37     /**Called by the container to invoke this tag.
38      * The implementation of this method is provided by the tag library developer,
39      * and handles all tag processing, body iteration, etc.
40      */

41         private Issue issue;
42
43     /**Called by the container to invoke this tag.
44      * The implementation of this method is provided by the tag library developer,
45      * and handles all tag processing, body iteration, etc.
46      */

47     public void doTag() throws JspException JavaDoc {
48         
49         JspWriter JavaDoc out=getJspContext().getOut();
50         
51         try {
52             int dup = issue.getCommentCollection().size() - 1;
53             printBar(out, dup);
54             JspFragment f=getJspBody();
55             if (f != null) f.invoke(out);
56             
57         } catch (java.io.IOException JavaDoc ex) {
58             throw new JspException JavaDoc(ex.getMessage());
59         }
60         
61     }
62
63     public void setIssue(Issue issue) {
64         this.issue = issue;
65     }
66     
67     private void printBar(JspWriter JavaDoc out, int d) throws IOException JavaDoc {
68         int width = d * MAX_WIDTH / 15;
69         if (width > MAX_WIDTH) width = MAX_WIDTH;
70         out.println("<div style='border-style:solid;" +
71                 "border-color:" + COLOR + ";border-width:1px;width:" + MAX_WIDTH + "px;height:10px;z-index:2;'>");
72         out.print("<div style='border-style:solid;border-color:" + COLOR + ";" +
73                 "border-width:1px;background-color:" + COLOR + ";width:" + width + "px;height:8px;z-index:1;'/>");
74         out.println("<div style='zindex:3;position:relative;top:-3px;'>" + d + "</div></div>"); //position:relative;top:-14px;
75
}
76 }
77
Popular Tags