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.SQLGroupBy;
046: import org.netbeans.modules.sql.framework.model.TargetTable;
047: import org.netbeans.modules.sql.framework.ui.view.ConditionPropertyEditor;
048: import org.netbeans.modules.sql.framework.ui.view.GroupByPropertyEditor;
049: import org.netbeans.modules.sql.framework.ui.view.IGraphViewContainer;
050: import org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea;
051: import org.openide.nodes.Node;
052: import com.sun.sql.framework.exception.BaseException;
053:
054: /**
055: * @author Ritesh Adval
056: */
057: public class TargetTableProperties extends TableProperties {
058:
059: private TargetTable table;
060:
061: public TargetTableProperties(IGraphViewContainer editor,
062: SQLBasicTableArea gNode, TargetTable table) {
063: this .editor = editor;
064: this .gNode = gNode;
065: this .table = table;
066: initializeProperties(table);
067: }
068:
069: public SQLCondition getJoinCondition() {
070: SQLCondition joinCond = table.getJoinCondition();
071: return joinCond;
072: }
073:
074: /**
075: * get condition text
076: *
077: * @return sql condition
078: */
079: public String getJoinConditionText() {
080: return this .table.getJoinConditionText();
081: }
082:
083: public SQLCondition getFilterCondition() {
084: SQLCondition joinCond = table.getFilterCondition();
085: return joinCond;
086: }
087:
088: /**
089: * get condition text
090: *
091: * @return sql condition
092: */
093: public String getFilterConditionText() {
094: return this .table.getFilterConditionText();
095: }
096:
097: @Override
098: public PropertyEditor getCustomEditor(Node.Property property) {
099: if (property.getName().equals("joinCondition")) {
100: ConditionPropertyEditor f = new ConditionPropertyEditor(
101: editor, table);
102: return f;
103: } else if (property.getName().equals("joinConditionText")) {
104: ConditionPropertyEditor f = new ConditionPropertyEditor(
105: editor, table);
106: return f;
107: } else if (property.getName().equals("filterCondition")) {
108: ConditionPropertyEditor f = new ConditionPropertyEditor.OuterFilter(
109: editor, table);
110: return f;
111: } else if (property.getName().equals("filterConditionText")) {
112: ConditionPropertyEditor f = new ConditionPropertyEditor.OuterFilter(
113: editor, table);
114: return f;
115: } else if (property.getName().equals("SQLGroupBy")) {
116: return new GroupByPropertyEditor(editor, table);
117: } else {
118: return super .getCustomEditor(property);
119: }
120: }
121:
122: /**
123: * get report group by object
124: *
125: * @return SQLGroupBy
126: */
127: public SQLGroupBy getSQLGroupBy() {
128: return table.getSQLGroupBy();
129: }
130:
131: /**
132: * get string representation of statement type
133: *
134: * @return statement type
135: */
136: public String getStrStatementType() {
137: return table.getStrStatementType();
138: }
139:
140: /**
141: * get whether to create target table
142: *
143: * @return whether to create target table
144: */
145: public boolean isCreateTargetTable() {
146: return table.isCreateTargetTable();
147: }
148:
149: /**
150: * Indicates whether contents of target table should be truncated before loading new
151: * data.
152: *
153: * @return true if contents should be truncated; false otherwise
154: */
155: public boolean isTruncateBeforeLoad() {
156: return this .table.isTruncateBeforeLoad();
157: }
158:
159: public void setJoinCondition(SQLCondition filter)
160: throws BaseException {
161: table.setJoinCondition(filter);
162: gNode.setConditionIcons();
163: setDirty(true);
164: }
165:
166: /**
167: * set the condition text
168: *
169: * @param cond sql condition
170: */
171: public void setJoinConditionText(String cond) {
172: this .table.setJoinConditionText(cond);
173: }
174:
175: public void setFilterCondition(SQLCondition filter)
176: throws BaseException {
177: table.setFilterCondition(filter);
178: gNode.setConditionIcons();
179: setDirty(true);
180: }
181:
182: /**
183: * set the condition text
184: *
185: * @param cond sql condition
186: */
187: public void setFilterConditionText(String cond) {
188: this .table.setFilterConditionText(cond);
189: }
190:
191: /**
192: * set whether to create target table if does not exist
193: *
194: * @param create whether to create target table
195: */
196: public void setCreateTargetTable(boolean create) {
197: table.setCreateTargetTable(create);
198: setDirty(true);
199: }
200:
201: /**
202: * set group by object
203: *
204: * @param groupBy - SQLGroupBy
205: */
206: public void setSQLGroupBy(SQLGroupBy groupBy) {
207: table.setSQLGroupBy(groupBy);
208: setDirty(true);
209: }
210:
211: public void setStrStatementType(String sType) {
212: table.setStrStatementType(sType);
213: setDirty(true);
214: }
215:
216: /**
217: * Sets whether contents of target table should be truncated before loading new data.
218: *
219: * @param flag true if contents should be truncated; false otherwise
220: */
221: public void setTruncateBeforeLoad(boolean flag) {
222: this .table.setTruncateBeforeLoad(flag);
223: setDirty(true);
224: }
225: }
|