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 org.netbeans.modules.visualweb.insync.live;
042:
043: import org.netbeans.modules.visualweb.insync.java.JavaClass;
044: import java.beans.PropertyDescriptor;
045: import java.util.ArrayList;
046:
047: import javax.faces.component.UIViewRoot;
048:
049: import com.sun.rave.designtime.EventDescriptor;
050: import org.netbeans.modules.visualweb.insync.beans.BeansUnit;
051:
052: /**
053: * Internal SourceDesignBean root container.
054: *
055: * @author Carl Quinn
056: */
057: public class SourceLiveRoot extends SourceDesignBean {
058:
059: /**
060: * @param unit
061: */
062: SourceLiveRoot(LiveUnit unit) {
063: super (unit, BeansUnit.getBeanInfo(Object.class, unit.getModel()
064: .getFacesModelSet().getProjectClassLoader()), null,
065: null, null);
066: children = new ArrayList();
067: }
068:
069: //------------------------------------------------------------------------------- SourceDesignBean
070:
071: /*
072: * @see com.sun.rave.designtime.DesignBean#getInstanceName()
073: */
074: public String getInstanceName() {
075: if (unit.sourceUnit != null) {
076: JavaClass adapterClass = unit.sourceUnit.getThisClass();
077: if (adapterClass != null)
078: return adapterClass.getShortName();
079: }
080: return null;
081: }
082:
083: /**
084: * Invoke the registered cleanup method for the bean's instance
085: */
086: public void invokeCleanupMethod() {
087: if (instance instanceof UIViewRoot) {
088: UIViewRoot uiViewRoot = ((UIViewRoot) instance);
089: uiViewRoot.getChildren().clear();
090: uiViewRoot.getFacets().clear();
091: }
092: }
093:
094: /*
095: * @see com.sun.rave.designtime.DesignBean#canSetInstanceName()
096: */
097: public boolean canSetInstanceName() {
098: return false; // don't allow renaming host class from here
099: }
100:
101: /*
102: * @see com.sun.rave.designtime.DesignBean#setInstanceName(java.lang.String)
103: */
104: public boolean setInstanceName(String name) {
105: return false; // don't allow renaming host class from here
106: }
107:
108: /*
109: * @see org.netbeans.modules.visualweb.insync.live.SourceDesignBean#newDesignProperty(java.beans.PropertyDescriptor)
110: */
111: protected SourceDesignProperty newDesignProperty(
112: PropertyDescriptor descriptor) {
113: return null;
114: }
115:
116: /*
117: * @see org.netbeans.modules.visualweb.insync.live.SourceDesignBean#newDesignEvent(com.sun.rave.designtime.EventDescriptor)
118: */
119: protected SourceDesignEvent newDesignEvent(
120: EventDescriptor descriptor) {
121: return null;
122: }
123:
124: //--------------------------------------------------------------------------------------- Object
125:
126: public String toString() {
127: StringBuffer sb = new StringBuffer();
128: sb.append("[SLR instance:" + getInstance() + " "); // + getChildCount() + " kids:");
129: //liveChildren.toString(sb);
130: sb.append("]");
131: return sb.toString();
132: }
133:
134: }
|