001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.web.wiki.macros;
034:
035: import org.radeox.api.engine.context.InitialRenderContext;
036:
037: import org.radeox.macro.Preserved;
038: import org.radeox.macro.parameter.MacroParameter;
039:
040: import java.io.IOException;
041: import java.io.Writer;
042:
043: public class BoxMacro extends Preserved {
044: public BoxMacro() throws Exception {
045: super ();
046: addSpecial('[');
047: addSpecial(']');
048: addSpecial('{');
049: addSpecial('}');
050: addSpecial('*');
051: addSpecial('-');
052: addSpecial('\\');
053: }
054:
055: public String getName() {
056: return "box";
057: }
058:
059: public void execute(Writer writer, MacroParameter params)
060: throws IllegalArgumentException, IOException {
061: try {
062: // start box
063: writer.write("<div class=\"box\" style=\"");
064:
065: // float property
066: String position = (String) params.getParams().get("float");
067:
068: if (position != null) {
069: writer.write("float:" + position + ";");
070: }
071:
072: // width property
073: String width = (String) params.getParams().get("width");
074:
075: if (width != null) {
076: writer.write("width:" + width + ";");
077: }
078:
079: writer.write("\">");
080:
081: // title of the box
082: String title = (String) params.getParams().get("title");
083:
084: if (title != null) {
085: writer.write("<span class=\"title\"><b>" + title
086: + "</b></span>");
087: } else {
088: writer.write("<span style=\"display:none;\"></span>");
089: }
090:
091: // content with style from param
092: writer.write("<span class=\"content\" style=\"");
093:
094: // height property
095: String height = (String) params.getParams().get("height");
096:
097: if (height != null) {
098: writer.write("height:" + height + ";");
099: }
100:
101: writer.write("\">" + params.getContent());
102: writer.write("</span>");
103:
104: // end box
105: writer.write("</div>");
106: } catch (IOException e) {
107: throw e;
108: } catch (IllegalArgumentException e) {
109: throw e;
110: } catch (Exception e) {
111: throw new IllegalArgumentException("error in box macro : "
112: + e.getMessage());
113: }
114: }
115:
116: public String getDescription() {
117: return "Create a box in order to change the basic disposition.";
118: }
119:
120: public String[] getParamDescription() {
121: return new String[] { "1. the box title (optional)",
122: "2. the floating behaviour (left or right) (optional)",
123: "3. the height of the box (px,%) (optional)",
124: "4. the width of the box (px,%) (optional)" };
125: }
126:
127: public void setInitialContext(InitialRenderContext arg0) {
128: }
129:
130: public int compareTo(Object arg0) {
131: return 0;
132: }
133: }
|