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.sql.framework.ui.view.property;
042:
043: import java.beans.PropertyEditor;
044: import org.netbeans.modules.sql.framework.model.SQLCondition;
045: import org.netbeans.modules.sql.framework.model.SourceTable;
046: import org.netbeans.modules.sql.framework.ui.view.ConditionPropertyEditor;
047: import org.netbeans.modules.sql.framework.ui.view.IGraphViewContainer;
048: import org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea;
049: import org.openide.nodes.Node;
050: import com.sun.sql.framework.exception.BaseException;
051:
052: /**
053: * @author Ritesh Adval
054: * @author Ahimanikya Satapathy
055: */
056: public class SourceTableProperties extends TableProperties {
057:
058: protected SourceTable table;
059:
060: public SourceTableProperties(IGraphViewContainer editor,
061: SQLBasicTableArea gNode, SourceTable table) {
062: this .editor = editor;
063: this .gNode = gNode;
064: this .table = table;
065: initializeProperties(table);
066: }
067:
068: @Override
069: public PropertyEditor getCustomEditor(Node.Property property) {
070: if (property.getName().equals("extractionCondition")) {
071: ConditionPropertyEditor f = new ConditionPropertyEditor(
072: editor, table);
073: return f;
074: } else if (property.getName().equals("extractionConditionText")) {
075: ConditionPropertyEditor f = new ConditionPropertyEditor(
076: editor, table);
077: return f;
078: } else if (property.getName().equals("validationCondition")) {
079: ConditionPropertyEditor f = new ConditionPropertyEditor.Validation(
080: editor, table);
081: return f;
082: } else if (property.getName().equals("validationConditionText")) {
083: ConditionPropertyEditor f = new ConditionPropertyEditor.Validation(
084: editor, table);
085: return f;
086: } else {
087: return super .getCustomEditor(property);
088: }
089: }
090:
091: /**
092: * Gets data extraction condition.
093: *
094: * @return
095: */
096: public SQLCondition getExtractionCondition() {
097: return table.getExtractionCondition();
098: }
099:
100: /**
101: * Gets data validation condition.
102: *
103: * @return
104: */
105: public SQLCondition getValidationCondition() {
106: return table.getDataValidationCondition();
107: }
108:
109: /**
110: * get the extraction conidition text
111: *
112: * @return sql condition
113: */
114: public String getExtractionConditionText() {
115: return table.getExtractionConditionText();
116: }
117:
118: /**
119: * get the validation conidition text
120: *
121: * @return sql condition
122: */
123: public String getValitionConditionText() {
124: return table.getDataValidationConditionText();
125: }
126:
127: public String getExtractionType() {
128: return table.getExtractionType();
129: }
130:
131: /**
132: * get whether to Drop Staging table before extraction
133: *
134: * @return whether to drop Staging table
135: */
136: public boolean isDropStagingTable() {
137: return table.isDropStagingTable();
138: }
139:
140: /**
141: * get whether to truncate Staging table before extraction
142: *
143: * @return whether to drop Staging table
144: */
145: public boolean isTruncateStagingTable() {
146: return table.isTruncateStagingTable();
147: }
148:
149: /**
150: * check if distinct rows of a column needs to be selected
151: *
152: * @return distinct
153: */
154: public boolean isSelectDistinct() {
155: return table.isSelectDistinct();
156: }
157:
158: public void setBatchSize(int batchS) {
159: table.setBatchSize(batchS);
160: setDirty(true);
161: }
162:
163: /**
164: * Drop Staging table before extraction
165: *
166: * @param dropTable whether to drop staging table
167: */
168: public void setDropStagingTable(boolean dropTable) {
169: table.setDropStagingTable(dropTable);
170: setDirty(true);
171: }
172:
173: /**
174: * Truncate Staging table before extraction
175: *
176: * @param truncateTable whether to truncate staging table
177: */
178: public void setTruncateStagingTable(boolean truncateTable) {
179: table.setTruncateStagingTable(truncateTable);
180: setDirty(true);
181: }
182:
183: public void setExtractionCondition(SQLCondition cond)
184: throws BaseException {
185: table.setExtractionCondition(cond);
186: gNode.setConditionIcons();
187: setDirty(true);
188: }
189:
190: public void setValidationCondition(SQLCondition cond)
191: throws BaseException {
192: table.setDataValidationCondition(cond);
193: gNode.setConditionIcons();
194: setDirty(true);
195: }
196:
197: /**
198: * set the extraction condition text
199: *
200: * @param cond extraction condition text
201: */
202: public void setExtractionConditionText(String cond) {
203: this .table.setExtractionConditionText(cond);
204: }
205:
206: /**
207: * set the validation condition text
208: *
209: * @param cond extraction condition text
210: */
211: public void setValidationConditionText(String cond) {
212: this .table.setDataValidationConditionText(cond);
213: }
214:
215: public void setExtractionType(String eType) {
216: table.setExtractionType(eType);
217: setDirty(true);
218: }
219:
220: /**
221: * set wehether to select distinct rows of a column
222: *
223: * @param distinct distinct
224: */
225: public void setSelectDistinct(boolean distinct) {
226: table.setSelectDistinct(distinct);
227: setDirty(true);
228: }
229: }
|