KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > externaltools > DescriptionStep


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.core.gui.externaltools;
17
18 import java.awt.BorderLayout JavaDoc;
19 import java.awt.Font JavaDoc;
20 import java.net.URL JavaDoc;
21
22 import javax.swing.JComponent JavaDoc;
23 import javax.swing.JPanel JavaDoc;
24 import javax.swing.JScrollPane JavaDoc;
25 import javax.swing.JTextPane JavaDoc;
26 import javax.swing.UIManager JavaDoc;
27 import javax.swing.text.html.HTMLEditorKit JavaDoc;
28 import javax.swing.text.html.StyleSheet JavaDoc;
29
30 import net.javaprog.ui.wizard.AbstractStep;
31 import net.javaprog.ui.wizard.DataModel;
32
33 import org.columba.core.gui.util.URLLabel;
34 import org.columba.core.resourceloader.GlobalResourceLoader;
35
36
37 /**
38  * Presents some information about the external tool which the
39  * user is going to configure in further steps.
40  * <p>
41  * Usually this should should include a short explanation about
42  * what the tool does, where to download, etc.
43  *
44  * @author fdietz
45  */

46 class DescriptionStep extends AbstractStep {
47     private static final String JavaDoc RESOURCE_PATH = "org.columba.core.i18n.dialog";
48     protected DataModel data;
49
50     /**
51  * @param arg0
52  * @param arg1
53  */

54     public DescriptionStep(DataModel data) {
55         super(GlobalResourceLoader.getString(RESOURCE_PATH, "externaltools",
56                 "DescriptionStep.title"),
57             GlobalResourceLoader.getString(RESOURCE_PATH, "externaltools",
58                 "DescriptionStep.description"));
59
60         this.data = data;
61     }
62
63     /* (non-Javadoc)
64  * @see net.javaprog.ui.wizard.AbstractStep#createComponent()
65  */

66     protected JComponent JavaDoc createComponent() {
67         JPanel JavaDoc panel = new JPanel JavaDoc();
68         panel.setLayout(new BorderLayout JavaDoc());
69
70         AbstractExternalToolsPlugin plugin = (AbstractExternalToolsPlugin) data.getData(
71                 "Plugin");
72
73         Font JavaDoc font = UIManager.getFont("Label.font");
74         String JavaDoc name = font.getName();
75         int size = font.getSize();
76
77         JTextPane JavaDoc textPane = new JTextPane JavaDoc();
78         HTMLEditorKit JavaDoc editorKit = new HTMLEditorKit JavaDoc();
79         StyleSheet JavaDoc styles = new StyleSheet JavaDoc();
80         String JavaDoc css = "<style type=\"text/css\"><!--p {font-family:\"" + name +
81             "\"; font-size:\"" + size + "pt\"}--></style>";
82         styles.addRule(css);
83         editorKit.setStyleSheet(styles);
84
85         textPane.setEditorKit(editorKit);
86
87         textPane.setText(plugin.getDescription());
88         textPane.setCaretPosition(0);
89         textPane.setEditable(false);
90
91         JScrollPane JavaDoc sp = new JScrollPane JavaDoc(textPane);
92
93         panel.add(sp, BorderLayout.CENTER);
94
95         URL JavaDoc url = plugin.getWebsite();
96
97         if (url != null) {
98             panel.add(new URLLabel(url), BorderLayout.SOUTH);
99         }
100
101         return panel;
102     }
103
104     /* (non-Javadoc)
105  * @see net.javaprog.ui.wizard.Step#prepareRendering()
106  */

107     public void prepareRendering() {
108     }
109 }
110
Popular Tags