KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Map JavaDoc;
29
30 /**
31  * ComplexLabel should be an example for some kind of complex label
32  * this label could hold meta information about itself
33  * @author Marco Mosconi
34  * @version $Id: ComplexLabel.java 1776 2004-11-08 08:37:03Z leo $
35  */

36 public class ComplexLabel extends BaseLabel {
37     public ComplexLabel() {
38         super();
39         setPriority(1);
40         setSupervisor("");
41     }
42
43     public ComplexLabel(String JavaDoc name, String JavaDoc value) {
44         super(name, value);
45         setPriority(1);
46         setSupervisor("");
47     }
48
49     protected String JavaDoc supervisor;
50     protected int priority;
51
52     public String JavaDoc getType() {
53         return "ComplexLabel";
54     }
55
56     public String JavaDoc getInputProxy() {
57         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
58         buffer.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\">");
59         buffer.append("<tr>");
60         buffer.append("<td>Label name: </td>");
61         buffer.append("<td><input type=\"text\" value=\"");
62         buffer.append(name);
63         buffer.append("\" name=\"label.name\"/></td>");
64         buffer.append("</tr><tr>");
65         buffer.append("<td>Label value: </td>");
66         buffer.append("<td><input type=\"text\" value=\"");
67         buffer.append(value);
68         buffer.append("\" name=\"label.value\"/></td>");
69         buffer.append("</tr><tr>");
70         buffer.append("<td>Priority: </td>");
71         buffer.append("<td><select name=\"label.priority\">");
72         buffer.append("<option>1</option>");
73         buffer.append("<option>2</option>");
74         buffer.append("<option>3</option>");
75         buffer.append("<option>4</option>");
76         buffer.append("</select></td>");
77         buffer.append("</tr><tr>");
78         buffer.append("<td>Supervisor: </td>");
79         buffer.append("<td><input type=\"text\" value=\"");
80         buffer.append(getSupervisor());
81         buffer.append("\" name=\"label.supervisor\"/></td>");
82         buffer.append("</tr></table>");
83         return buffer.toString();
84     }
85
86     public void handleInput(Map JavaDoc input) {
87         if (input.containsKey("label.name")) {
88             this.name = (String JavaDoc)input.get("label.name");
89         }
90         if (input.containsKey("label.value")) {
91             this.value = (String JavaDoc)input.get("label.value");
92         }
93         if (input.containsKey("label.priority")) {
94             this.setPriority(Integer.valueOf((String JavaDoc)input.get("label.priority")).intValue());
95         }
96         if (input.containsKey("label.supervisor")) {
97             this.setSupervisor((String JavaDoc)input.get("label.supervisor"));
98         }
99     }
100
101     public String JavaDoc getSupervisor() {
102         return supervisor;
103     }
104
105     public void setSupervisor(String JavaDoc supervisor) {
106         this.supervisor = supervisor;
107     }
108
109     public int getPriority() {
110         return priority;
111     }
112
113     public void setPriority(int priority) {
114         this.priority = priority;
115     }
116 }
117
Popular Tags