001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package com.sun.rave.web.ui.component.util.handlers;
042:
043: import com.sun.rave.web.ui.component.Property;
044: import com.sun.rave.web.ui.component.PropertySheet;
045: import com.sun.rave.web.ui.component.PropertySheetSection;
046: import com.sun.rave.web.ui.component.util.event.HandlerContext;
047:
048: /**
049: * <P> This class contains {@link com.sun.rave.web.ui.component.util.event.Handler}
050: * methods that perform PropertySheet specific functions.</P>
051: *
052: * @author Ken Paulsen (ken.paulsen@sun.com)
053: */
054: public class PropertySheetHandlers {
055:
056: /**
057: * <P> Default Constructor.</P>
058: */
059: public PropertySheetHandlers() {
060: }
061:
062: /**
063: * <p> This method calculates the number of visible
064: * {@link PropertySheetSection}s. A {@link PropertySheetSection} can
065: * be made not visible by setting its rendered propety to false.</p>
066: *
067: * <p> This method expects the {@link PropertySheet} to be passed in as
068: * an input value ({@link #PROP_SHEET}). It returns "numSections" as
069: * the number of visible {@link PropertySheetSection}s.</p>
070: *
071: * @param context The {@link HandlerContext}
072: */
073: public void getSectionCount(HandlerContext context) {
074: // Get the PropertySheet
075: PropertySheet propSheet = (PropertySheet) context
076: .getInputValue(PROP_SHEET);
077:
078: // Set the output value
079: context.setOutputValue("numSections", new Integer(propSheet
080: .getSectionCount()));
081: }
082:
083: /**
084: * <p> This method calculates the number of visible child
085: * {@link PropertySheetSection} or {@link Property}
086: * <code>UIComponent</code>s. A {@link PropertySheetSection} or
087: * {@link Property} can be made not visible by setting its rendered
088: * propety to false.</p>
089: *
090: * <p> This method expects the {@link PropertySheetSection} to be passed
091: * in as an input value ({@link #SECTION}). It returns the result in
092: * "numChildren".</p>
093: *
094: * @param context The {@link HandlerContext}
095: */
096: public void getSectionChildrenCount(HandlerContext context) {
097: // Get the Section
098: PropertySheetSection section = (PropertySheetSection) context
099: .getInputValue(SECTION);
100:
101: // Set the output value
102: context.setOutputValue("numChildren", new Integer(section
103: .getSectionChildrenCount()));
104: }
105:
106: /**
107: * <p> This {@link com.sun.rave.web.ui.component.util.event.Handler} creates a
108: * <code>List</code> of visible (rendered=true) child
109: * {@link PropertySheetSection} or {@link Property} components.</p>
110: *
111: * @param context The {@link HandlerContext}.
112: */
113: public void getVisibleSectionChildren(HandlerContext context) {
114: // Get the Section
115: PropertySheetSection section = (PropertySheetSection) context
116: .getInputValue(SECTION);
117:
118: // Set the output value
119: context.setOutputValue("children", section
120: .getVisibleSectionChildren());
121: }
122:
123: /**
124: * <p> This {@link com.sun.rave.web.ui.component.util.event.Handler} creates a
125: * <code>List</code> of visible (rendered=true)
126: * {@link PropertySheetSection} components.</p>
127: *
128: * @param context The {@link HandlerContext}.
129: */
130: public void getVisibleSections(HandlerContext context) {
131: // Get the PropertySheet
132: PropertySheet propSheet = (PropertySheet) context
133: .getInputValue(PROP_SHEET);
134:
135: // Set the output value
136: context.setOutputValue("sections", propSheet
137: .getVisibleSections());
138: }
139:
140: /**
141: * <p> This {@link com.sun.rave.web.ui.component.util.event.Handler} creates a
142: * <code>List</code> of visible (rendered=true)
143: * {@link PropertySheetSection} components.</p>
144: *
145: * @param context The {@link HandlerContext}.
146: */
147: public void getLabelTarget(HandlerContext context) {
148: // Get the Property
149: Property prop = (Property) context.getInputValue(PROPERTY);
150:
151: // Delegate to the Property UIComponent
152: context.setOutputValue("target", prop
153: .getPrimaryElementID(context.getFacesContext()));
154: }
155:
156: /**
157: * <p> This constant defines the input parameter key used to pass in the
158: * {@link PropertySheet}. ("propSheet")</p>
159: */
160: public static final String PROP_SHEET = "propSheet"; // NO18N
161:
162: /**
163: * <p> This constant defines the input parameter key used to pass in the
164: * {@link PropertySheetSection}. ("section")</p>
165: */
166: public static final String SECTION = "section"; // NO18N
167:
168: /**
169: * <p> This constant defines the input parameter key used to pass in the
170: * {@link Property}. ("property")</p>
171: */
172: public static final String PROPERTY = "property"; // NO18N
173: }
|