001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/package org.araneaframework.example.common.tags.presentation;
016:
017: import java.io.IOException;
018: import java.io.Writer;
019: import java.util.HashMap;
020: import java.util.Map;
021: import javax.servlet.jsp.JspException;
022: import org.araneaframework.http.util.FileImportUtil;
023: import org.araneaframework.jsp.tag.presentation.BaseImageHtmlTag;
024:
025: /**
026: * SAMPLE image tag.
027: *
028: * @author Oleg Mürk
029: *
030: * @jsp.tag
031: * name = "image"
032: * body-content = "JSP"
033: */
034: public class SampleImageTag extends BaseImageHtmlTag {
035: /**
036: * Static method to write out image with given code with default style.
037: */
038: public void writeImage(Writer out, String code)
039: throws JspException, IOException {
040: writeImage(out, code, "aranea-image", getStyleClass(), null);
041: }
042:
043: /**
044: * @jsp.attribute
045: * type = "java.lang.String"
046: * required = "false"
047: * description = "Image code."
048: */
049: public void setCode(String code) throws JspException {
050: super .setCode(code);
051: }
052:
053: public void writeImageLocal(Writer out, String src, String width,
054: String height, String alt, String styleClass, String title)
055: throws JspException, IOException {
056: String url = FileImportUtil.getImportString(src, pageContext
057: .getRequest());
058: writeImage(out, url, width, height, alt, styleClass, title);
059: }
060:
061: protected Info getImageInfo(String code) {
062: return (Info) imageInfo.get(code);
063: }
064:
065: /**
066: * Map: String(image code) -> Info
067: */
068: protected static final Map imageInfo = new HashMap();
069: //XXX: this is bullshit
070: static {
071: imageInfo.put("add", new Info("gfx/ico_add3.gif", "30", "16"));
072: imageInfo.put("old", new Info("gfx/ico_old.gif", "32", "32"));
073: imageInfo.put("delete", new Info("gfx/ico_delete.gif", "23",
074: "16"));
075: imageInfo.put("downArrow", new Info("gfx/dot14.gif", "9", "7"));
076: imageInfo.put("flag", new Info("gfx/ico_flag.gif", "12", "12"));
077: imageInfo.put("edit2",
078: new Info("gfx/ico_edit2.gif", "30", "16"));
079: imageInfo.put("triangle", new Info("gfx/dot05.gif", "30", "9"));
080: imageInfo.put("folder", new Info("gfx/ico_folder.gif", "25",
081: "15"));
082: imageInfo.put("clients", new Info("gfx/ico_myclients.gif",
083: "34", "22"));
084: imageInfo
085: .put("help", new Info("gfx/ico_help3.gif", "17", "16"));
086: imageInfo.put("feedback", new Info("gfx/ico_info.gif", null,
087: null));
088: imageInfo.put("projects", new Info("gfx/ico_projects.gif",
089: "34", "22"));
090: imageInfo.put("error",
091: new Info("gfx/ico_error.gif", "17", "17"));
092: imageInfo.put("forward", new Info("gfx/ico_forward.gif", "25",
093: "15"));
094: imageInfo.put("print",
095: new Info("gfx/ico_print.gif", "30", "16"));
096: imageInfo.put("back", new Info("gfx/ico_back.gif", null, null));
097: imageInfo.put("back2",
098: new Info("gfx/ico_back2.gif", "25", "15"));
099: imageInfo.put("buttonChange", new Info("gfx/butt_change3.gif",
100: null, null));
101: imageInfo.put("buttonDelete", new Info("gfx/butt_delete2.gif",
102: null, null));
103: imageInfo.put("buttonAdd", new Info("gfx/butt_add.gif", null,
104: null));
105: imageInfo.put("buttonSearch", new Info("gfx/butt_search.gif",
106: null, null));
107: imageInfo.put("calendar", new Info("gfx/ico_calendar.gif",
108: null, null));
109: }
110: }
|