001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.core.gui.externaltools;
017:
018: import java.awt.BorderLayout;
019: import java.awt.Font;
020: import java.net.URL;
021:
022: import javax.swing.JComponent;
023: import javax.swing.JPanel;
024: import javax.swing.JScrollPane;
025: import javax.swing.JTextPane;
026: import javax.swing.UIManager;
027: import javax.swing.text.html.HTMLEditorKit;
028: import javax.swing.text.html.StyleSheet;
029:
030: import net.javaprog.ui.wizard.AbstractStep;
031: import net.javaprog.ui.wizard.DataModel;
032:
033: import org.columba.core.gui.util.URLLabel;
034: import org.columba.core.resourceloader.GlobalResourceLoader;
035:
036: /**
037: * Presents some information about the external tool which the
038: * user is going to configure in further steps.
039: * <p>
040: * Usually this should should include a short explanation about
041: * what the tool does, where to download, etc.
042: *
043: * @author fdietz
044: */
045: class DescriptionStep extends AbstractStep {
046: private static final String RESOURCE_PATH = "org.columba.core.i18n.dialog";
047: protected DataModel data;
048:
049: /**
050: * @param arg0
051: * @param arg1
052: */
053: public DescriptionStep(DataModel data) {
054: super (GlobalResourceLoader.getString(RESOURCE_PATH,
055: "externaltools", "DescriptionStep.title"),
056: GlobalResourceLoader.getString(RESOURCE_PATH,
057: "externaltools", "DescriptionStep.description"));
058:
059: this .data = data;
060: }
061:
062: /* (non-Javadoc)
063: * @see net.javaprog.ui.wizard.AbstractStep#createComponent()
064: */
065: protected JComponent createComponent() {
066: JPanel panel = new JPanel();
067: panel.setLayout(new BorderLayout());
068:
069: AbstractExternalToolsPlugin plugin = (AbstractExternalToolsPlugin) data
070: .getData("Plugin");
071:
072: Font font = UIManager.getFont("Label.font");
073: String name = font.getName();
074: int size = font.getSize();
075:
076: JTextPane textPane = new JTextPane();
077: HTMLEditorKit editorKit = new HTMLEditorKit();
078: StyleSheet styles = new StyleSheet();
079: String css = "<style type=\"text/css\"><!--p {font-family:\""
080: + name + "\"; font-size:\"" + size + "pt\"}--></style>";
081: styles.addRule(css);
082: editorKit.setStyleSheet(styles);
083:
084: textPane.setEditorKit(editorKit);
085:
086: textPane.setText(plugin.getDescription());
087: textPane.setCaretPosition(0);
088: textPane.setEditable(false);
089:
090: JScrollPane sp = new JScrollPane(textPane);
091:
092: panel.add(sp, BorderLayout.CENTER);
093:
094: URL url = plugin.getWebsite();
095:
096: if (url != null) {
097: panel.add(new URLLabel(url), BorderLayout.SOUTH);
098: }
099:
100: return panel;
101: }
102:
103: /* (non-Javadoc)
104: * @see net.javaprog.ui.wizard.Step#prepareRendering()
105: */
106: public void prepareRendering() {
107: }
108: }
|