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.propertyeditors.binding.data;
042:
043: import com.sun.rave.designtime.CustomizerResult;
044: import com.sun.rave.designtime.DesignBean;
045: import com.sun.rave.designtime.DisplayAction;
046: import com.sun.rave.designtime.Result;
047: import com.sun.rave.designtime.impl.BasicDisplayAction;
048: import org.netbeans.modules.visualweb.propertyeditors.util.Bundle;
049:
050: public class DataBindingHelper {
051:
052: //------------------------------------------------------------------------ Public Static Methods
053:
054: public static Class BIND_VALUE_TO_OBJECT = BindValueToObjectPanel.class;
055: public static Class BIND_VALUE_TO_DATAPROVIDER = BindValueToDataProviderPanel.class;
056: public static Class BIND_OPTIONS_TO_DATAPROVIDER = BindOptionsToDataProviderPanel.class;
057: public static Class BIND_SELECTITEMS_TO_DATAPROVIDER = BindSelectItemsToDataProviderPanel.class;
058:
059: public static DisplayAction getDataBindingAction(DesignBean bean,
060: String propName, Class[] panelClasses, boolean showExpr,
061: String menuText, String dialogTitle) {
062: return new DataBindingCustomizerAction(bean, propName,
063: panelClasses, showExpr, menuText, dialogTitle);
064: }
065:
066: public static DisplayAction getDataBindingAction(DesignBean bean,
067: String propName, Class[] panelClasses, boolean showExpr,
068: String menuText) {
069: return new DataBindingCustomizerAction(bean, propName,
070: panelClasses, showExpr, menuText);
071: }
072:
073: public static DisplayAction getDataBindingAction(DesignBean bean,
074: String propName, Class[] panelClasses, boolean showExpr) {
075: return new DataBindingCustomizerAction(bean, propName,
076: panelClasses, showExpr);
077: }
078:
079: public static DisplayAction getDataBindingAction(DesignBean bean,
080: String propName, Class[] panelClasses) {
081: return new DataBindingCustomizerAction(bean, propName,
082: panelClasses);
083: }
084:
085: public static DisplayAction getDataBindingAction(DesignBean bean,
086: String propName) {
087: return new DataBindingCustomizerAction(bean, propName);
088: }
089:
090: //------------------------------------------------------------------------------- Action Classes
091:
092: private static class DataBindingCustomizerAction extends
093: BasicDisplayAction {
094:
095: public DataBindingCustomizerAction(DesignBean bean,
096: String propName, Class[] panelClasses,
097: boolean showExpr, String menuText, String dialogTitle) {
098: super (menuText, null,
099: "projrave_ui_elements_webform_dataref_binding_db"); //NOI18N
100: this .bean = bean;
101: this .dialogTitle = dialogTitle;
102: this .propName = propName;
103: this .panelClasses = panelClasses;
104: this .showExpr = showExpr;
105: }
106:
107: public DataBindingCustomizerAction(DesignBean bean,
108: String propName, Class[] panelClasses,
109: boolean showExpr, String menuText) {
110: super (menuText, null,
111: "projrave_ui_elements_webform_dataref_binding_db"); //NOI18N
112: this .bean = bean;
113: this .propName = propName;
114: this .panelClasses = panelClasses;
115: this .showExpr = showExpr;
116: }
117:
118: public DataBindingCustomizerAction(DesignBean bean,
119: String propName, Class[] panelClasses, boolean showExpr) {
120: super (bundle.getMessage("bindToDataEllipse"), null,
121: "projrave_ui_elements_webform_dataref_binding_db"); //NOI18N
122: this .bean = bean;
123: this .propName = propName;
124: this .panelClasses = panelClasses;
125: this .showExpr = showExpr;
126: }
127:
128: public DataBindingCustomizerAction(DesignBean bean,
129: String propName, Class[] panelClasses) {
130: super (bundle.getMessage("bindToDataEllipse"), null,
131: "projrave_ui_elements_webform_dataref_binding_db"); //NOI18N
132: this .bean = bean;
133: this .propName = propName;
134: this .panelClasses = panelClasses;
135: }
136:
137: public DataBindingCustomizerAction(DesignBean bean,
138: String propName) {
139: super (bundle.getMessage("bindToDataEllipse"), null,
140: "projrave_ui_elements_webform_dataref_binding_db"); //NOI18N
141: this .bean = bean;
142: this .propName = propName;
143: }
144:
145: protected DesignBean bean;
146: protected String propName;
147: protected Class[] panelClasses;
148: protected boolean showExpr = true;
149:
150: protected String dialogTitle;
151:
152: public void setDialogTitle(String dialogTitle) {
153: this .dialogTitle = dialogTitle;
154: }
155:
156: public String getDialogTitle() {
157: return dialogTitle;
158: }
159:
160: public Result invoke() {
161: DataBindingCustomizer sdbc = dialogTitle != null ? new DataBindingCustomizer(
162: propName, panelClasses, showExpr, dialogTitle)
163: : new DataBindingCustomizer(propName, panelClasses,
164: showExpr);
165: return new CustomizerResult(bean, sdbc);
166: }
167: }
168:
169: public static final Bundle bundle = Bundle
170: .getBundle(DataBindingHelper.class);
171: }
|