KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > snip > label > RenderEngineLabel


1 /*
2  * This file is part of "SnipSnap Wiki/Weblog".
3  *
4  * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
5  * All Rights Reserved.
6  *
7  * Please visit http://snipsnap.org/ for updates and contact.
8  *
9  * --LICENSE NOTICE--
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  * --LICENSE NOTICE--
24  */

25
26 package org.snipsnap.snip.label;
27
28 import org.apache.lucene.document.Document;
29 import org.apache.lucene.document.Field;
30 import org.snipsnap.container.Components;
31 import org.snipsnap.snip.Snip;
32 import org.snipsnap.serialization.LabelContext;
33 import org.radeox.api.engine.RenderEngine;
34
35 import java.util.Map JavaDoc;
36
37 /**
38  * Label that changes how a snip is displayed bu changing the default rendering
39  * engine. It is honoured by the Snip implementation.
40  *
41  * @author Matthias L. Jugel
42  * @version $Id: RenderEngineLabel.java 1263 2003-12-12 08:58:25Z stephan $
43  */

44
45 public class RenderEngineLabel implements Label {
46   protected String JavaDoc name;
47   protected String JavaDoc engine;
48   protected Snip snip;
49
50   public RenderEngineLabel() {
51     name = "RenderEngine";
52     engine = Components.DEFAULT_ENGINE;
53   }
54
55   public void create() {
56   }
57
58   public void remove() {
59   }
60
61   public void change() {
62   }
63
64   public LabelContext getContext() {
65     return new LabelContext(snip, this);
66   }
67
68   public void setSnip(Snip snip) {
69     this.snip = snip;
70   }
71
72   public Snip getSnip() {
73     return snip;
74   }
75
76   public RenderEngineLabel(String JavaDoc name, String JavaDoc engine) {
77     this.name = name;
78     this.engine = engine;
79   }
80
81   public String JavaDoc getInputProxy() {
82     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
83     buffer.append("<select name=\"label.renderEngine\">");
84     buffer.append("<option value=\"org.snipsnap.render.PlainTextRenderEngine\">");
85     buffer.append("Plain Text</option>");
86     buffer.append("<option value=\"defaultRenderEngine\">default</option>");
87     buffer.append("</select>");
88     return buffer.toString();
89   }
90
91   public String JavaDoc getListProxy() {
92 // StringBuffer buffer = new StringBuffer();
93
// buffer.append("<td>");
94
// buffer.append(name);
95
// buffer.append("</td><td>");
96
// buffer.append(engine.substring(engine.lastIndexOf(".")));
97
// buffer.append("</td>");
98
// return buffer.toString();
99
return ""; // this label is not displayed
100
}
101
102   public void handleInput(Map JavaDoc input) {
103     if (input.containsKey("label.renderEngine")) {
104       this.engine = (String JavaDoc) input.get("label.renderEngine");
105       this.name = "RenderEngine";
106     }
107
108   }
109
110   public String JavaDoc getType() {
111     return "RenderEngine";
112   }
113
114   public String JavaDoc getName() {
115     return name;
116   }
117
118   public String JavaDoc getValue() {
119     return engine;
120   }
121
122   public void setName(String JavaDoc name) {
123     this.name = name;
124   }
125
126   public void setValue(String JavaDoc value) {
127     this.engine = value;
128   }
129
130   public void index(Document document) {
131     //System.out.println("Label index: " + name + ", " + engine);
132
document.add(Field.Text(name, "" + engine));
133   }
134 }
135
Popular Tags