01: /*
02: * JBoss, a division of Red Hat
03: * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
04: * by the @authors tag. See the copyright.txt in the distribution for a
05: * full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22:
23: package org.jboss.portal.core.admin.ui;
24:
25: import org.jboss.portal.core.model.portal.PortalObject;
26:
27: import javax.faces.event.ValueChangeEvent;
28:
29: /**
30: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
31: * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
32: * @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot com">Boleslaw Dawidowicz</a>
33: * @version $Revision: 8785 $
34: */
35: public class ControlPropertyBean extends PropertyBean {
36:
37: /** . */
38: private final ControlPropertiesBean container;
39:
40: public ControlPropertyBean(ControlPropertiesBean container,
41: PropertyInfo info, boolean inherited, boolean inheritable,
42: String value) {
43: super (container, info, inherited, inheritable, value);
44: //
45: this .container = container;
46: }
47:
48: public void setInherited(boolean inherited) {
49: this .inherited = inherited;
50: }
51:
52: public void inherit(ValueChangeEvent event) {
53: PortalObject portalObject = container.getRelatedObject();
54:
55: //
56:
57: //
58: if (event.getNewValue().toString().equalsIgnoreCase("true")) {
59: portalObject.setDeclaredProperty(getName(), null);
60: } else {
61: portalObject.setDeclaredProperty(getName(), value);
62: }
63: }
64:
65: public void setValue(Object value) {
66: if (!inherited) {
67: this .value = value.toString();
68:
69: // Need to use the container as it will contain the refreshed object
70: PortalObject portalObject = container.pomgr
71: .getSelectedObject();
72: portalObject.setDeclaredProperty(getName(), value
73: .toString());
74: }
75:
76: }
77:
78: public boolean isControlProperty() {
79: return PropertiesInfo.isControlProperty(info.getName());
80: }
81: }
|