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.faces.dt_1_2.component.html;
042:
043: import com.sun.rave.designtime.*;
044: import java.util.ArrayList;
045: import javax.faces.component.html.HtmlOutputFormat;
046: import org.netbeans.modules.visualweb.faces.dt.util.ComponentBundle;
047: import org.netbeans.modules.visualweb.propertyeditors.binding.data.DataBindingHelper;
048:
049: //import org.openide.ErrorManager;
050:
051: public class HtmlOutputFormatDesignInfo implements DesignInfo {
052:
053: private static final ComponentBundle bundle = ComponentBundle
054: .getBundle(HtmlOutputFormatDesignInfo.class);
055:
056: public Class getBeanClass() {
057: return HtmlOutputFormat.class;
058: }
059:
060: public boolean acceptParent(DesignBean parentBean,
061: DesignBean childBean, Class childClass) {
062: return true;
063: }
064:
065: public boolean acceptChild(DesignBean parentBean,
066: DesignBean childBean, Class childClass) {
067: return true;
068: }
069:
070: public Result beanCreatedSetup(DesignBean bean) {
071: try {
072: bean.getProperty("value").setValue(
073: bundle.getMessage("htmlOutputFormat")); //NOI18N
074: } catch (Exception x) {
075: // send the error to the log
076: //ErrorManager.getDefault().notify(x);
077: x.printStackTrace();
078: }
079: return Result.SUCCESS;
080: }
081:
082: public Result beanPastedSetup(DesignBean bean) {
083: return Result.SUCCESS;
084: }
085:
086: public Result beanDeletedCleanup(DesignBean bean) {
087: return Result.SUCCESS;
088: }
089:
090: public DisplayAction[] getContextItems(DesignBean bean) {
091: // Use the new data binding dialogs that support Data providers
092: ArrayList actions = new ArrayList();
093: DesignProperty property = bean.getProperty("value");
094: if (property != null) {
095: Class bindingPanelClass = DataBindingHelper.BIND_VALUE_TO_DATAPROVIDER;
096: DisplayAction bindToDataAction = DataBindingHelper
097: .getDataBindingAction(
098: bean,
099: property.getPropertyDescriptor().getName(),
100: new Class[] {
101: bindingPanelClass,
102: DataBindingHelper.BIND_VALUE_TO_OBJECT });
103: actions.add(bindToDataAction);
104: }
105: return (DisplayAction[]) actions
106: .toArray(new DisplayAction[actions.size()]);
107: }
108:
109: public boolean acceptLink(DesignBean targetBean,
110: DesignBean sourceBean, Class sourceClass) {
111: return false;
112: }
113:
114: public Result linkBeans(DesignBean targetBean, DesignBean sourceBean) {
115: return null;
116: }
117:
118: public void beanContextActivated(DesignBean bean) {
119: }
120:
121: public void beanContextDeactivated(DesignBean bean) {
122: }
123:
124: public void instanceNameChanged(DesignBean bean,
125: String oldInstanceName) {
126: }
127:
128: public void beanChanged(DesignBean bean) {
129: }
130:
131: public void propertyChanged(DesignProperty prop, Object oldValue) {
132: }
133:
134: public void eventChanged(DesignEvent event) {
135: }
136:
137: /*
138: public MarkupMouseRegion[] annotateRender(DesignBean bean, DocumentFragment documentFragment, MarkupPosition begin, MarkupPosition end) {
139: NodeList nodeList = documentFragment.getChildNodes();
140: int len = nodeList.getLength();
141: for (int i = 0; i < len; i++) {
142: Node child = nodeList.item(i);
143: if (child.getNodeType() == Node.ELEMENT_NODE) {
144: Element element = (Element)child;
145: if ("output_message".equals(element.getTagName())) { //NOI18N
146: String value = element.getAttribute("value"); //NOI18N
147: if (value == null || value.length() == 0 || "null".equals(value)) {
148: String newValue = bean.getInstanceName();
149: String valueRef = bean.getProperty("valueRef").getValueAsText();
150: if (valueRef != null && value.length() > 0) {
151: valueRef = valueRef.substring(valueRef.lastIndexOf("."));
152: newValue = valueRef;
153: } else {
154: Object bindValue = bean.getDesignContext().getContextData(bean.getInstanceName() + ".databind");
155: if (bindValue != null) {
156: newValue = "" + bindValue;
157: }
158: }
159: element.setAttribute("value", newValue);
160: }
161: }
162: }
163: }
164: return null;
165: }
166: */
167: }
|