01: /* SwingML
02: * Copyright (C) 2002 SwingML Team
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: *
19: * Authors:
20: * Ezequiel Cuellar <ecuellar@crosslogic.com>
21: * Bram Stieperaere <bramez@users.sourceforge.net>
22: */
23:
24: package org.swingml.model;
25:
26: import java.net.*;
27:
28: import org.swingml.*;
29: import org.swingml.system.*;
30:
31: public class JEditorPaneModel extends SwingMLModel {
32:
33: private boolean editable = false;
34: private String page = null;
35:
36: public JEditorPaneModel() {
37: super ();
38: }
39:
40: public String getPage() {
41: return this .page;
42: }
43:
44: public boolean isEditable() {
45: return this .editable;
46: }
47:
48: public void setEditable(boolean aEditable) {
49: this .editable = aEditable;
50: }
51:
52: public void setPage(String aPage) {
53: this .page = aPage;
54: }
55:
56: public void validate() {
57: try {
58: new URL(this .getPage());
59: } catch (MalformedURLException e) {
60: SwingMLLogger.getInstance().log(
61: "Syntax error: The parameter PAGE in the element "
62: + super .getName()
63: + " should be a well formed URL");
64: }
65: if (super .getParent().getLayout() != null
66: && super .getParent().getLayout().equalsIgnoreCase(
67: Constants.BORDERLAYOUT)) {
68: if (super .getOrientation() == null) {
69: SwingMLLogger
70: .getInstance()
71: .log(
72: "Syntax error: The parameter ORIENTATION in the element "
73: + super .getName()
74: + " is required since its parent's LAYOUT is BorderLayout. Add the parameter ORIENTATION to the element "
75: + super .getName()
76: + " or change its parent's LAYOUT to other than BorderLayout.");
77: }
78: }
79: if (super .getParent().getLayout() != null
80: && !super .getParent().getLayout().equalsIgnoreCase(
81: Constants.BORDERLAYOUT)) {
82: if (super .getOrientation() != null) {
83: SwingMLLogger
84: .getInstance()
85: .log(
86: "Syntax error: The parameter ORIENTATION in the element "
87: + super .getName()
88: + " should be used only when its parent's LAYOUT is BorderLayout. Change its parent's LAYOUT to BorderLayout or delete the parameter ORIENTATION from the element "
89: + super .getName() + ".");
90: }
91: }
92: }
93: }
|