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: * Farid Ibrahim <faridibrahim@lycos.com>
22: *
23: */
24:
25: package org.swingml.model;
26:
27: import java.net.*;
28:
29: import org.swingml.*;
30: import org.swingml.system.*;
31:
32: public class JButtonModel extends SwingMLModel {
33:
34: private boolean enabled = true;
35:
36: public JButtonModel() {
37: super ();
38: }
39:
40: public boolean isEnabled() {
41: return this .enabled;
42: }
43:
44: public void setEnabled(boolean aEnabled) {
45: this .enabled = aEnabled;
46: }
47:
48: public void validate() {
49: if (super .getParent().getLayout() != null
50: && super .getParent().getLayout().equalsIgnoreCase(
51: Constants.BORDERLAYOUT)) {
52: if (super .getOrientation() == null) {
53: SwingMLLogger
54: .getInstance()
55: .log(
56: "Syntax error: The parameter ORIENTATION in the element "
57: + super .getName()
58: + " is required since its parent's LAYOUT is BorderLayout. Add the parameter ORIENTATION to the element "
59: + super .getName()
60: + " or change its parent's LAYOUT to other than BorderLayout.");
61: }
62: }
63: if (super .getParent().getLayout() != null
64: && !super .getParent().getLayout().equalsIgnoreCase(
65: Constants.BORDERLAYOUT)) {
66: if (super .getOrientation() != null) {
67: SwingMLLogger
68: .getInstance()
69: .log(
70: "Syntax error: The parameter ORIENTATION in the element "
71: + super .getName()
72: + " 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 "
73: + super .getName() + ".");
74: }
75: }
76: try {
77: if (this .getIcon() != null) {
78: new URL(super .getIcon());
79: }
80: } catch (MalformedURLException e) {
81: SwingMLLogger.getInstance().log(
82: "Syntax error: The parameter ICON in the element "
83: + super .getName()
84: + "should be a valid URL.");
85: }
86: }
87: }
|