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.dataconnectivity;
042:
043: import org.openide.options.SystemOption;
044: import org.openide.util.HelpCtx;
045: import org.openide.util.NbBundle;
046:
047: /** Dataconnectivity settings.
048: *
049: * @author joel brown
050: */
051: public class DataconnectivitySettings extends SystemOption {
052: /** generated Serialized Version UID */
053: static final long serialVersionUID = 1L;
054:
055: /** create on page by default */
056: public static final String PROP_MAKE_IN_SESSION = "1makeInSession"; // NOI18N
057: public static final String PROP_CHECK_ROWSET = "2checkRowset"; // NOI18N
058: public static final String PROP_PROMPT_FOR_NAME = "3checkRowset"; // NOI18N
059: public static final String PROP_DATAPROVIDER = "4dataprovider"; // NOI18N
060: public static final String PROP_ROWSET = "5rowset"; // NOI18N
061:
062: // Default instance of this system option, for the convenience of associated classes.
063: public static DataconnectivitySettings getInstance() {
064: return (DataconnectivitySettings) findObject(
065: DataconnectivitySettings.class, true);
066: }
067:
068: // do NOT use constructore for setting default values
069: protected void initialize() {
070: // Set default values of properties
071: super .initialize();
072:
073: setMakeInSession(true); // EA default
074: setCheckRowSetProp(true); // this checking is new in thresher FCS.
075: setPromptForName(false);
076: setRowSetSuffixProp("RowSet"); //NOI18N
077: setDataProviderSuffixProp("DataProvider"); // NOI18N
078: }
079:
080: public void setDataProviderSuffixProp(String dpSuffix) {
081: putProperty(PROP_DATAPROVIDER, dpSuffix, true);
082: }
083:
084: public String getDataProviderSuffixProp() {
085: return (String) getProperty(PROP_DATAPROVIDER);
086: }
087:
088: public void setRowSetSuffixProp(String rowsetSuffix) {
089: putProperty(PROP_ROWSET, rowsetSuffix, true);
090: }
091:
092: public String getRowSetSuffixProp() {
093: return (String) getProperty(PROP_ROWSET);
094: }
095:
096: public static String getRsSuffix() {
097: return DataconnectivitySettings.getInstance()
098: .getRowSetSuffixProp();
099: }
100:
101: public static String getDpSuffix() {
102: return DataconnectivitySettings.getInstance()
103: .getDataProviderSuffixProp();
104: }
105:
106: // This method must be overriden. It returns display name of this options.
107: public String displayName() {
108: return NbBundle.getBundle(DataconnectivitySettings.class)
109: .getString("CTL_DataconnectivitySettings");
110: }
111:
112: public HelpCtx getHelpCtx() {
113: return HelpCtx.DEFAULT_HELP;
114: }
115:
116: /****
117: * whether of not all drags should create rowsets on the page.
118: * false is the default - then rowsets are created in the session.
119: */
120: public boolean getMakeInSession() {
121: // why the "!"(not)? the option description wording changed from
122: // "create in page" to "create in session".
123: return ((Boolean) getProperty(PROP_MAKE_IN_SESSION))
124: .booleanValue();
125: }
126:
127: public void setMakeInSession(boolean makeInSession) {
128: putProperty(PROP_MAKE_IN_SESSION, makeInSession ? Boolean.TRUE
129: : Boolean.FALSE, true);
130: }
131:
132: public boolean getCheckRowSetProp() {
133: return ((Boolean) getProperty(PROP_CHECK_ROWSET))
134: .booleanValue();
135: }
136:
137: public void setCheckRowSetProp(boolean checkStuff) {
138: putProperty(PROP_CHECK_ROWSET, checkStuff ? Boolean.TRUE
139: : Boolean.FALSE, true);
140: }
141:
142: public boolean getPromptForName() {
143: return ((Boolean) getProperty(PROP_PROMPT_FOR_NAME))
144: .booleanValue();
145: }
146:
147: public void setPromptForName(boolean prompt) {
148: putProperty(PROP_PROMPT_FOR_NAME, prompt ? Boolean.TRUE
149: : Boolean.FALSE, true);
150: }
151:
152: public static boolean canDropAnywhere() {
153: return !DataconnectivitySettings.getInstance()
154: .getMakeInSession();
155: }
156:
157: public static boolean checkRowsets() {
158: return DataconnectivitySettings.getInstance()
159: .getCheckRowSetProp();
160: }
161:
162: public static boolean promptForName() {
163: return DataconnectivitySettings.getInstance()
164: .getPromptForName();
165: }
166:
167: }
|