01: /*
02: * SwingML Copyright (C) 2003 Ezequiel Cuellar.
03: *
04: * This library is free software; you can redistribute it and/or modify it under
05: * the terms of the GNU Lesser General Public License as published by the Free
06: * Software Foundation; either version 2 of the License, or (at your option) any
07: * later version.
08: *
09: * This library is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12: * details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with this library; if not, write to the Free Software Foundation, Inc.,
16: * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: * Authors: Ezequiel Cuellar <ecuellar@crosslogic.com> Farid Ibrahim
19: * <faridibrahim@lycos.com>
20: *
21: */
22:
23: package org.swingml.component;
24:
25: import java.io.*;
26: import java.net.*;
27:
28: import javax.swing.*;
29: import javax.swing.event.*;
30: import javax.swing.text.html.*;
31:
32: import org.swingml.*;
33: import org.swingml.model.*;
34: import org.swingml.system.*;
35:
36: public class JEditorPaneComponent extends JEditorPane implements
37: XMLTranslatable, HyperlinkListener {
38:
39: public JEditorPaneComponent(JEditorPaneModel aModel) {
40: try {
41: JEditorPaneModel theModel = aModel;
42: super .setEditable(false);
43: super .setName(theModel.getName());
44: super .setPage(new URL(theModel.getPage()));
45: super .setToolTipText(theModel.getTooltip());
46: super .setEditable(theModel.isEditable());
47: super .addHyperlinkListener(this );
48: } catch (MalformedURLException e) {
49: } catch (IOException e) {
50: }
51: }
52:
53: public String getXMLValue() {
54: return super .getText();
55: }
56:
57: public void hyperlinkUpdate(HyperlinkEvent anEvt) {
58: if (anEvt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
59: if (anEvt instanceof HTMLFrameHyperlinkEvent) {
60: HTMLDocument theDocument = (HTMLDocument) getDocument();
61: theDocument
62: .processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) anEvt);
63: } else {
64: try {
65: setPage(anEvt.getURL());
66: } catch (IOException e) {
67: SwingMLLogger.getInstance().log(e);
68: }
69: }
70: }
71: }
72: }
|