Source Code Cross Referenced for BasicTopView.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » sql » framework » ui » view » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » etl.project » org.netbeans.modules.sql.framework.ui.view 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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;
042:
043:        import org.netbeans.modules.sql.framework.ui.output.dataview.DataOutputPanel;
044:        import java.awt.Component;
045:        import java.awt.Dialog;
046:        import java.awt.event.ActionEvent;
047:        import java.awt.event.ActionListener;
048:        import java.beans.PropertyChangeEvent;
049:        import java.util.HashMap;
050:        import java.util.Iterator;
051:        import java.awt.BorderLayout;
052:        import javax.swing.JPanel;
053:        import java.util.List;
054:        import javax.swing.Action;
055:
056:        import org.openide.DialogDescriptor;
057:        import org.openide.DialogDisplayer;
058:        import org.openide.NotifyDescriptor;
059:
060:        import org.netbeans.modules.etl.ui.DataObjectProvider;
061:        import org.netbeans.modules.etl.ui.ETLDataObject;
062:        import org.netbeans.modules.etl.ui.ETLEditorSupport;
063:        import org.netbeans.modules.sql.framework.model.SQLCondition;
064:        import org.netbeans.modules.sql.framework.model.SQLConstants;
065:        import org.netbeans.modules.sql.framework.model.SQLDefinition;
066:        import org.netbeans.modules.sql.framework.model.SQLJoinView;
067:        import org.netbeans.modules.sql.framework.model.SQLObject;
068:        import org.netbeans.modules.sql.framework.model.SourceTable;
069:        import org.netbeans.modules.sql.framework.model.TargetTable;
070:        import org.netbeans.modules.sql.framework.ui.editor.property.impl.PropertyViewManager;
071:        import org.netbeans.modules.sql.framework.ui.graph.ICommand;
072:        import org.netbeans.modules.sql.framework.ui.graph.IGraphNode;
073:        import org.netbeans.modules.sql.framework.ui.graph.IGraphView;
074:        import org.netbeans.modules.sql.framework.ui.model.CollabSQLUIModel;
075:        import org.netbeans.modules.sql.framework.ui.model.SQLUIModel;
076:        import org.netbeans.modules.sql.framework.ui.view.conditionbuilder.ConditionBuilderUtil;
077:        import org.netbeans.modules.sql.framework.ui.view.conditionbuilder.ConditionBuilderView;
078:        import org.netbeans.modules.sql.framework.ui.view.graph.BasicSQLViewFactory;
079:        import org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea;
080:        import org.netbeans.modules.sql.framework.ui.view.graph.SQLCollaborationView;
081:        import org.netbeans.modules.sql.framework.ui.view.join.JoinMainDialog;
082:        import org.netbeans.modules.sql.framework.ui.view.join.JoinUtility;
083:        import org.netbeans.modules.sql.framework.ui.view.property.FFSourceTableProperties;
084:        import org.netbeans.modules.sql.framework.ui.view.property.FFTargetTableProperties;
085:        import org.netbeans.modules.sql.framework.ui.view.property.SourceTableProperties;
086:        import org.netbeans.modules.sql.framework.ui.view.property.TargetTableProperties;
087:        import com.sun.sql.framework.exception.BaseException;
088:        import com.sun.sql.framework.utils.Attribute;
089:        import net.java.hulp.i18n.Logger;
090:        import java.beans.PropertyChangeListener;
091:        import org.netbeans.modules.etl.logger.Localizer;
092:        import org.netbeans.modules.etl.logger.LogUtil;
093:        import org.netbeans.modules.etl.ui.view.ETLOutputWindowTopComponent;
094:        import org.netbeans.modules.sql.framework.model.DBMetaDataFactory;
095:        import org.netbeans.modules.sql.framework.model.SQLDBTable;
096:        import org.netbeans.modules.sql.framework.model.SQLJoinOperator;
097:        import org.netbeans.modules.sql.framework.model.impl.RuntimeInputImpl;
098:        import org.netbeans.modules.sql.framework.model.impl.RuntimeOutputImpl;
099:        import org.netbeans.modules.sql.framework.model.impl.SQLJoinViewImpl;
100:        import org.netbeans.modules.sql.framework.model.utils.SQLObjectUtil;
101:        import org.netbeans.modules.sql.framework.ui.editor.property.impl.PropertyNode;
102:        import org.netbeans.modules.sql.framework.ui.editor.property.impl.TemplateFactory;
103:        import org.netbeans.modules.sql.framework.ui.output.SQLStatementPanel;
104:        import org.netbeans.modules.sql.framework.ui.output.dataview.JoinOperatorDataPanel;
105:        import org.netbeans.modules.sql.framework.ui.output.dataview.JoinViewDataPanel;
106:        import org.netbeans.modules.sql.framework.ui.output.dataview.RejectedRowsDataPanel;
107:        import org.netbeans.modules.sql.framework.ui.output.dataview.SourceTableDataPanel;
108:        import org.netbeans.modules.sql.framework.ui.output.dataview.TargetTableDataPanel;
109:        import org.netbeans.modules.sql.framework.ui.view.property.RuntimeInputProperties;
110:        import org.netbeans.modules.sql.framework.ui.view.property.RuntimeOutputProperties;
111:        import org.netbeans.modules.sql.framework.ui.view.property.SQLCollaborationProperties;
112:        import org.netbeans.modules.sql.framework.ui.view.property.SQLJoinProperties;
113:        import org.netbeans.modules.sql.framework.ui.view.validation.SQLValidationView;
114:        import org.openide.awt.StatusDisplayer;
115:        import org.openide.nodes.Node;
116:        import org.openide.windows.WindowManager;
117:
118:        /**
119:         * Main view of SQL Framework
120:         *
121:         * @author Wei Han
122:         * @version $Revision$
123:         */
124:        public abstract class BasicTopView extends JPanel implements 
125:                IGraphViewContainer {
126:
127:            private static transient final Logger mLogger = LogUtil
128:                    .getLogger(BasicTopView.class.getName());
129:            private static transient final Localizer mLoc = Localizer.get();
130:
131:            protected static abstract class ConditionValidator implements 
132:                    ActionListener {
133:
134:                static final class DataValidation extends ConditionValidator {
135:
136:                    private SourceTable mTable;
137:
138:                    public DataValidation(SQLBasicTableArea gNode,
139:                            SourceTable table, ConditionBuilderView view,
140:                            Dialog dlg, CollabSQLUIModel sqlModel) {
141:                        super (gNode, view, dlg, sqlModel);
142:                        mTable = table;
143:                    }
144:
145:                    protected void setCondition(SQLCondition cond) {
146:                        SQLCondition oldCondition = mTable
147:                                .getExtractionCondition();
148:                        if (cond != null) {
149:                            if (!cond.equals(oldCondition)) {
150:                                mTable.setDataValidationCondition(cond);
151:                                mSqlModel.setDirty(true);
152:                            }
153:                        }
154:                    }
155:                }
156:
157:                static final class ExtractionFilter extends ConditionValidator {
158:
159:                    private SourceTable mTable;
160:
161:                    public ExtractionFilter(SQLBasicTableArea gNode,
162:                            SourceTable table, ConditionBuilderView view,
163:                            Dialog dlg, CollabSQLUIModel sqlModel) {
164:                        super (gNode, view, dlg, sqlModel);
165:                        mTable = table;
166:                    }
167:
168:                    protected void setCondition(SQLCondition cond) {
169:                        SQLCondition oldCondition = mTable
170:                                .getExtractionCondition();
171:                        if (cond != null) {
172:                            if (!cond.equals(oldCondition)) {
173:                                mTable.setExtractionCondition(cond);
174:                                mSqlModel.setDirty(true);
175:                            }
176:                        }
177:                    }
178:                }
179:
180:                static final class TargetJoinConditioon extends
181:                        ConditionValidator {
182:
183:                    private TargetTable mTable;
184:
185:                    public TargetJoinConditioon(SQLBasicTableArea gNode,
186:                            TargetTable table, ConditionBuilderView view,
187:                            Dialog dlg, CollabSQLUIModel sqlModel) {
188:                        super (gNode, view, dlg, sqlModel);
189:                        mTable = table;
190:                    }
191:
192:                    protected void setCondition(SQLCondition cond) {
193:                        SQLCondition oldCondition = mTable.getJoinCondition();
194:                        if (cond != null) {
195:                            if (!cond.equals(oldCondition)) {
196:                                mTable.setJoinCondition(cond);
197:                                mSqlModel.setDirty(true);
198:                            }
199:                        }
200:                    }
201:                }
202:
203:                static final class TargetFilterCondition extends
204:                        ConditionValidator {
205:
206:                    private TargetTable mTable;
207:
208:                    public TargetFilterCondition(SQLBasicTableArea gNode,
209:                            TargetTable table, ConditionBuilderView view,
210:                            Dialog dlg, CollabSQLUIModel sqlModel) {
211:                        super (gNode, view, dlg, sqlModel);
212:                        mTable = table;
213:                    }
214:
215:                    protected void setCondition(SQLCondition cond) {
216:                        SQLCondition oldCondition = mTable.getFilterCondition();
217:                        if (cond != null) {
218:                            if (!cond.equals(oldCondition)) {
219:                                mTable.setFilterCondition(cond);
220:                                mSqlModel.setDirty(true);
221:                            }
222:                        }
223:                    }
224:                }
225:
226:                protected Dialog mDialog;
227:                protected SQLBasicTableArea mTableNode;
228:                protected ConditionBuilderView mView;
229:                protected CollabSQLUIModel mSqlModel;
230:
231:                protected ConditionValidator(SQLBasicTableArea gNode,
232:                        ConditionBuilderView view, Dialog dialog,
233:                        CollabSQLUIModel sqlModel) {
234:                    mTableNode = gNode;
235:                    mView = view;
236:                    mDialog = dialog;
237:                    mSqlModel = sqlModel;
238:                }
239:
240:                public void actionPerformed(ActionEvent e) {
241:                    if (NotifyDescriptor.OK_OPTION.equals(e.getSource())) {
242:                        if (!mView.isConditionValid()) {
243:                            String nbBundle1 = mLoc
244:                                    .t("PRSR001: Current condition is invalid.Are you sure you want to keep it and close this builder?");
245:                            NotifyDescriptor confirmDlg = new NotifyDescriptor.Confirmation(
246:                                    Localizer.parse(nbBundle1), mDialog
247:                                            .getTitle(),
248:                                    NotifyDescriptor.YES_NO_OPTION,
249:                                    NotifyDescriptor.WARNING_MESSAGE);
250:                            DialogDisplayer.getDefault().notify(confirmDlg);
251:                            if (confirmDlg.getValue() != NotifyDescriptor.YES_OPTION) {
252:                                return;
253:                            }
254:                        }
255:
256:                        setCondition((SQLCondition) mView.getPropertyValue());
257:                        if (mTableNode != null) {
258:                            mTableNode.setConditionIcons();
259:                        }
260:                    }
261:
262:                    mDialog.dispose();
263:                }
264:
265:                protected abstract void setCondition(SQLCondition cond);
266:            }
267:
268:            private static final String LOG_CATEGORY = BasicTopView.class
269:                    .getName();
270:            protected SQLCollaborationView collabView;
271:            protected CollabSQLUIModel sqlModel;
272:            private HashMap<String, DataOutputPanel> outputDataViewMap = new HashMap<String, DataOutputPanel>();
273:            private SQLValidationView refreshMetaView;
274:            private HashMap<String, DataOutputPanel> rejectionDataViewMap = new HashMap<String, DataOutputPanel>();
275:            private HashMap<String, SQLStatementPanel> sqlViewMap = new HashMap<String, SQLStatementPanel>();
276:
277:            /**
278:             * New instance
279:             *
280:             * @param model - CollabSQLUIModelImpl
281:             */
282:            public BasicTopView(CollabSQLUIModel model) {
283:                this .sqlModel = model;
284:                initGui();
285:            }
286:
287:            /**
288:             * Is editable
289:             *
290:             * @return boolean - true/false
291:             */
292:            public boolean canEdit() {
293:                return true;
294:            }
295:
296:            public void enableToolBarActions(boolean b) {
297:                List actions = this .getToolBarActions();
298:                Iterator it = actions.iterator();
299:                while (it.hasNext()) {
300:                    Action action = (Action) it.next();
301:                    if (action != null) {
302:                        action.setEnabled(b);
303:                    }
304:                }
305:            }
306:
307:            /**
308:             * Execute a command
309:             *
310:             * @param command - command
311:             * @param args - arguments
312:             */
313:            public Object[] execute(String command, Object[] args) {
314:                if (command.equals(ICommand.SHOW_SQL_CMD)) {
315:                    showSql((SQLObject) args[0]);
316:                } else if (command.equals(ICommand.SHOW_DATA_CMD)) {
317:                    showDataOutputView((SQLObject) args[0]);
318:                } else if (command.equals(ICommand.SHOW_REJECTION_DATA_CMD)) {
319:                    showRejectionDataOutputView((SQLObject) args[0]);
320:                } else if (command.equals(ICommand.SHOW_PROPERTY_CMD)) {
321:                    IGraphNode graphNode = (IGraphNode) args[0];
322:                    this .showProperties(graphNode);
323:                } else if (command.equals(ICommand.CONFIG_CMD)) {
324:                    // Integer tableType = (Integer) args[0];
325:                } else if (command.equals(ICommand.EDIT_JOINVIEW)) {
326:                    editJoinView((SQLJoinView) args[0]);
327:                } else if (command.equals(ICommand.DATA_VALIDATION)) {
328:                    SQLBasicTableArea graphNode = (SQLBasicTableArea) args[0];
329:                    doDataValidation(graphNode, (SourceTable) args[1]);
330:                } else if (command.equals(ICommand.DATA_EXTRACTION)) {
331:                    SQLBasicTableArea graphNode = (SQLBasicTableArea) args[0];
332:                    showDataExtraction(graphNode, (SourceTable) args[1]);
333:                } else if (command
334:                        .equals(ICommand.SHOW_TARGET_JOIN_CONDITION_CMD)) {
335:                    SQLBasicTableArea graphNode = (SQLBasicTableArea) args[0];
336:                    showTargetJoinCondition(graphNode, (TargetTable) args[1]);
337:                } else if (command
338:                        .equals(ICommand.SHOW_TARGET_FILTER_CONDITION_CMD)) {
339:                    SQLBasicTableArea graphNode = (SQLBasicTableArea) args[0];
340:                    showTargetFilterCondition(graphNode, (TargetTable) args[1]);
341:                }
342:
343:                return null;
344:            }
345:
346:            /**
347:             * Document this
348:             *
349:             * @param dataObj - data object
350:             * @return - IGraphNode
351:             */
352:            public IGraphNode findGraphNode(Object dataObj) {
353:                return this .collabView.findGraphNode(dataObj);
354:            }
355:
356:            /**
357:             * Return SQLCollaborationView
358:             *
359:             * @return SQLCollaborationView
360:             */
361:            public SQLCollaborationView getCollaborationView() {
362:                return this .collabView;
363:            }
364:
365:            /**
366:             * Return actions for popup menu of graph area
367:             *
368:             * @return a list of actions
369:             */
370:            public abstract List getGraphActions();
371:
372:            /**
373:             * Return SQLGraphView
374:             *
375:             * @return SQLGraphView
376:             */
377:            public IGraphView getGraphView() {
378:                return this .collabView.getGraphView();
379:            }
380:
381:            /**
382:             * Return the operator folder name
383:             *
384:             * @return operator folder name
385:             */
386:            public abstract String getOperatorFolder();
387:
388:            /**
389:             * Return actions for toolbar
390:             *
391:             * @return a list of actions
392:             */
393:            public abstract List getToolBarActions();
394:
395:            /**
396:             * get initial zoom factor
397:             *
398:             * @return initial zoom factor
399:             */
400:            public double getZoomFactor() {
401:                return this .collabView.getZoomFactor();
402:            }
403:
404:            public void setModifiable(boolean b) {
405:                this .collabView.getGraphView().setModifiable(b);
406:                enableToolBarActions(b);
407:            }
408:
409:            /**
410:             * set the zoom factor
411:             *
412:             * @param factor zoom factor
413:             */
414:            public void setZoomFactor(double factor) {
415:                this .collabView.setZoomFactor(factor);
416:            }
417:
418:            /**
419:             * Shows output view in bottom portion of a split pane.
420:             *
421:             * @param c - component
422:             */
423:            public void showSplitPaneView(Component c) {
424:                // add to output.
425:                ETLOutputWindowTopComponent topComp = ETLOutputWindowTopComponent
426:                        .findInstance();
427:                if (!topComp.isOpened()) {
428:                    topComp.open();
429:                }
430:                topComp.setVisible(true);
431:                topComp.addPanel(c);
432:                topComp.requestActive();
433:            }
434:
435:            public void setDirty(boolean dirty) {
436:                sqlModel.setDirty(dirty);
437:                SQLUIModel model = (SQLUIModel) getGraphView().getGraphModel();
438:                model.setDirty(dirty);
439:            }
440:
441:            protected SQLStatementPanel getOrCreateSQLStatementPanel(
442:                    SQLObject obj) {
443:                SQLStatementPanel c = sqlViewMap.get(obj.getId());
444:                if (c == null) {
445:                    c = new SQLStatementPanel(this , obj);
446:                    sqlViewMap.put(obj.getId(), c);
447:                } else {
448:                    c.updateSQLObject(obj);
449:                }
450:                return c;
451:            }
452:
453:            private String getTemplateName(SQLObject bean) {
454:                String template = null;
455:                Attribute attr = bean.getAttribute("ORGPROP_LOADTYPE");
456:                if (attr == null) {
457:                    try {
458:                        SQLObjectUtil.setOrgProperties((SQLDBTable) bean);
459:                        attr = bean.getAttribute("ORGPROP_LOADTYPE");
460:                    } catch (BaseException ex) {
461:                        StatusDisplayer.getDefault().setStatusText(
462:                                ex.getMessage());
463:                        if (bean.getObjectType() == SQLConstants.SOURCE_TABLE) {
464:                            template = "FFSourceTable";
465:                        } else if (bean.getObjectType() == SQLConstants.TARGET_TABLE) {
466:                            template = "FFTargetTable";
467:                        }
468:                        return template;
469:                    }
470:                }
471:
472:                if (bean.getObjectType() == SQLConstants.SOURCE_TABLE) {
473:                    if (((String) attr.getAttributeValue()).equals("RSS")) {
474:                        template = "RSSSourceTable";
475:                    } else if (((String) attr.getAttributeValue())
476:                            .equalsIgnoreCase("WEB")) {
477:                        template = "WebSourceTable";
478:                    } else if (((String) attr.getAttributeValue())
479:                            .equalsIgnoreCase("WEBROWSET")) {
480:                        template = "WebrowsetSourceTable";
481:                    } else if (((String) attr.getAttributeValue())
482:                            .equalsIgnoreCase("DELIMITED")
483:                            || ((String) attr.getAttributeValue())
484:                                    .equalsIgnoreCase("FIXEDWIDTH")) {
485:                        template = "FFSourceTable";
486:                    }
487:                } else if (bean.getObjectType() == SQLConstants.TARGET_TABLE) {
488:                    if (((String) attr.getAttributeValue()).equals("RSS")) {
489:                        template = "RSSTargetTable";
490:                    } else if (((String) attr.getAttributeValue())
491:                            .equalsIgnoreCase("WEB")) {
492:                        template = "WebTargetTable";
493:                    } else if (((String) attr.getAttributeValue())
494:                            .equalsIgnoreCase("WEBROWSET")) {
495:                        template = "WebrowsetTargetTable";
496:                    } else if (((String) attr.getAttributeValue())
497:                            .equalsIgnoreCase("DELIMITED")
498:                            || ((String) attr.getAttributeValue())
499:                                    .equalsIgnoreCase("FIXEDWIDTH")) {
500:                        template = "FFTargetTable";
501:                    }
502:                }
503:                return template;
504:            }
505:
506:            /**
507:             * show properties dialog
508:             */
509:            public void showProperties(Object selectedObj) {
510:                SQLObject bean = null;
511:                String template = "Collaboration";
512:                Object pBean = new SQLCollaborationProperties(sqlModel
513:                        .getSQLDefinition(), this );
514:
515:                if (selectedObj != null && (selectedObj instanceof  IGraphNode)) {
516:                    IGraphNode gNode = (IGraphNode) selectedObj;
517:                    bean = (SQLObject) gNode.getDataObject();
518:                    if (bean == null) {
519:                        return;
520:                    }
521:                    if (bean.getObjectType() == SQLConstants.SOURCE_TABLE) {
522:                        SourceTableProperties srcTableBaen = new SourceTableProperties(
523:                                this , (SQLBasicTableArea) gNode,
524:                                (SourceTable) bean);
525:                        if (((SourceTable) bean).getParent()
526:                                .getConnectionDefinition().getDBType().equals(
527:                                        DBMetaDataFactory.AXION)
528:                                || ((SourceTable) bean).getParent()
529:                                        .getConnectionDefinition().getDBType()
530:                                        .equalsIgnoreCase("Internal")) {
531:                            template = getTemplateName(bean);
532:                            pBean = new FFSourceTableProperties(srcTableBaen);
533:                        } else {
534:                            template = "SourceTable";
535:                            pBean = srcTableBaen;
536:                        }
537:                    } else if (bean.getObjectType() == SQLConstants.TARGET_TABLE) {
538:                        TargetTableProperties trgtTableBaen = new TargetTableProperties(
539:                                this , (SQLBasicTableArea) gNode,
540:                                (TargetTable) bean);
541:                        if (((TargetTable) bean).getParent()
542:                                .getConnectionDefinition().getDBType().equals(
543:                                        DBMetaDataFactory.AXION)
544:                                || ((TargetTable) bean).getParent()
545:                                        .getConnectionDefinition().getDBType()
546:                                        .equalsIgnoreCase("Internal")) {
547:                            template = getTemplateName(bean);
548:                            pBean = new FFTargetTableProperties(trgtTableBaen);
549:                        } else {
550:                            template = "TargetTable";
551:                            pBean = trgtTableBaen;
552:                        }
553:                    } else if (bean.getObjectType() == SQLConstants.RUNTIME_INPUT) {
554:                        pBean = new RuntimeInputProperties(
555:                                (RuntimeInputImpl) bean, sqlModel
556:                                        .getSQLDefinition(), this );
557:                        template = "RuntimeInput";
558:                    } else if (bean.getObjectType() == SQLConstants.RUNTIME_OUTPUT) {
559:                        pBean = new RuntimeOutputProperties(
560:                                (RuntimeOutputImpl) bean, sqlModel
561:                                        .getSQLDefinition(), this );
562:                        template = "RuntimeOutput";
563:                    } else if (bean.getObjectType() == SQLConstants.JOIN_VIEW) {
564:                        pBean = new SQLJoinProperties(((SQLJoinViewImpl) bean)
565:                                .getRootJoin(), this );
566:                        template = "Join";
567:                    }
568:                }
569:
570:                PropertyNode pNode = PropertyViewManager
571:                        .getPropertyViewManager()
572:                        .getPropertyNodeForTemplateName(template, null, pBean);
573:                final Object pb = pBean;
574:                pNode.addPropertyChangeSupport(new PropertyChangeListener() {
575:
576:                    public void propertyChange(PropertyChangeEvent evt) {
577:                        // if value is differnt then only set it
578:                        if (evt.getOldValue() != null
579:                                && !evt.getOldValue().equals(evt.getNewValue())) {
580:                            try {
581:                                TemplateFactory.invokeSetter(pb, evt
582:                                        .getPropertyName(), evt.getNewValue());
583:                                DataObjectProvider.getProvider()
584:                                        .getActiveDataObject()
585:                                        .setModified(true);
586:                            } catch (Exception ex) {
587:                                mLogger.errorNoloc(mLoc.t(
588:                                        "PRSR194: Failed to save changes {0}",
589:                                        LOG_CATEGORY), ex);
590:                            }
591:                        }
592:                    }
593:                });
594:                WindowManager.getDefault().getRegistry().getActivated()
595:                        .setActivatedNodes(new Node[] { pNode });
596:                //TODO: Need to update model for all the modification in the property sheet
597:            }
598:
599:            /**
600:             * Generates and displays associated SQL statement for the given SQLObject.
601:             *
602:             * @param obj SQLObject whose SQL statement is to be displayed
603:             */
604:            protected void showSql(SQLObject obj) {
605:                SQLStatementPanel c = getOrCreateSQLStatementPanel(obj);
606:                c.refreshSql();
607:                showSplitPaneView(c);
608:            }
609:
610:            public void showRefreshMetadataInfo(List valInfo) {
611:                refreshMetaView.clearView();
612:                if ((valInfo != null) && (valInfo.size() > 0)) {
613:                    refreshMetaView.setValidationInfos(valInfo);
614:                    showSplitPaneView(refreshMetaView);
615:                } else {
616:                    StatusDisplayer.getDefault().setStatusText(
617:                            "Collaboration Metadata is up-to-date.");
618:                }
619:            }
620:
621:            private void doDataValidation(SQLBasicTableArea gNode,
622:                    SourceTable table) {
623:                String nbBundle2 = mLoc.t("PRSR001: Data Validation Condition");
624:                ConditionBuilderView cView = ConditionBuilderUtil
625:                        .getValidationConditionBuilderView(table,
626:                                (IGraphViewContainer) this .getGraphView()
627:                                        .getGraphViewContainer());
628:                String title = Localizer.parse(nbBundle2);
629:
630:                // Create a Dialog that defers decision-making on whether to close the dialog to
631:                // an ActionListener.
632:                DialogDescriptor dd = new DialogDescriptor(cView, title, true,
633:                        NotifyDescriptor.OK_CANCEL_OPTION, null, null);
634:
635:                // Pushes closing logic to ActionListener impl
636:                dd.setClosingOptions(new Object[0]);
637:
638:                Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
639:                dlg.getAccessibleContext().setAccessibleDescription(
640:                        "This dialog does Condition Validation");
641:                ActionListener dlgListener = new ConditionValidator.DataValidation(
642:                        gNode, table, cView, dlg, sqlModel);
643:                dd.setButtonListener(dlgListener);
644:
645:                dlg.setModal(true);
646:                dlg.setVisible(true);
647:            }
648:
649:            private void editJoinView(SQLJoinView jView) {
650:                JoinMainDialog.showJoinDialog(sqlModel.getSQLDefinition()
651:                        .getJoinSources(), jView, this .getGraphView());
652:                if (JoinMainDialog.getClosingButtonState() == JoinMainDialog.OK_BUTTON) {
653:                    SQLJoinView modifiedJoinView = JoinMainDialog
654:                            .getSQLJoinView();
655:                    if (!jView.equals(modifiedJoinView)) {
656:                        sqlModel.setDirty(true);
657:                    }
658:                    List tableNodes = JoinMainDialog.getTableColumnNodes();
659:                    try {
660:                        JoinUtility.editJoinView(jView, modifiedJoinView,
661:                                modifiedJoinView.getSourceTables(), tableNodes,
662:                                this .getGraphView());
663:                    } catch (BaseException ex) {
664:
665:                        mLogger
666:                                .errorNoloc(
667:                                        mLoc
668:                                                .t(
669:                                                        "PRSR195: Caught Exception while commiting join view edits.{0}",
670:                                                        LOG_CATEGORY), ex);
671:                        NotifyDescriptor d = new NotifyDescriptor.Message(ex
672:                                .toString(), NotifyDescriptor.ERROR_MESSAGE);
673:                        DialogDisplayer.getDefault().notify(d);
674:                    }
675:                }
676:                updateActions();
677:            }
678:
679:            private void initGui() {
680:                BasicSQLViewFactory viewFactory = new BasicSQLViewFactory(
681:                        sqlModel, this , this .getGraphActions(), this 
682:                                .getToolBarActions());
683:                this .collabView = new SQLCollaborationView(viewFactory);
684:                // create output view
685:                refreshMetaView = new SQLValidationView(this .getGraphView());
686:                String nbBundle1 = mLoc.t("PRSR001: Refresh Metadata Log");
687:                refreshMetaView.setName(Localizer.parse(nbBundle1));
688:                setLayout(new BorderLayout());
689:                add(this .collabView, BorderLayout.CENTER);
690:            }
691:
692:            private void showDataExtraction(SQLBasicTableArea gNode,
693:                    SourceTable table) {
694:                ConditionBuilderView cView = ConditionBuilderUtil
695:                        .getConditionBuilderView(table,
696:                                (IGraphViewContainer) this .getGraphView()
697:                                        .getGraphViewContainer());
698:                String nbBundle2 = mLoc.t("PRSR001: Extraction Condition");
699:                String title = Localizer.parse(nbBundle2);
700:
701:                // Create a Dialog that defers decision-making on whether to close the dialog to
702:                // an ActionListener.
703:                DialogDescriptor dd = new DialogDescriptor(cView, title, true,
704:                        NotifyDescriptor.OK_CANCEL_OPTION, null, null);
705:
706:                // Pushes closing logic to ActionListener impl
707:                dd.setClosingOptions(new Object[0]);
708:
709:                Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
710:                dlg
711:                        .getAccessibleContext()
712:                        .setAccessibleDescription(
713:                                "This dialog filters data based on condition specified");
714:                ActionListener dlgListener = new ConditionValidator.ExtractionFilter(
715:                        gNode, table, cView, dlg, sqlModel);
716:                dd.setButtonListener(dlgListener);
717:
718:                dlg.setModal(true);
719:                dlg.setVisible(true);
720:                updateActions();
721:            }
722:
723:            /**
724:             * simply show the data of all the rows and column of the given table
725:             *
726:             * @param table - table
727:             */
728:            private void showDataOutputView(final SQLObject table) {
729:                SQLUIModel model = (SQLUIModel) getGraphView().getGraphModel();
730:                if (!(model instanceof  CollabSQLUIModel)) {
731:                    return;
732:                }
733:
734:                SQLDefinition def = ((CollabSQLUIModel) model)
735:                        .getSQLDefinition();
736:                DataOutputPanel dataView = outputDataViewMap.get(table.getId());
737:
738:                if (dataView == null) {
739:                    if (table.getObjectType() == SQLConstants.TARGET_TABLE) {
740:                        dataView = new TargetTableDataPanel(
741:                                (TargetTable) table, def);
742:                    } else if (table.getObjectType() == SQLConstants.SOURCE_TABLE) {
743:                        dataView = new SourceTableDataPanel(
744:                                (SourceTable) table, def);
745:                    } else if (table.getObjectType() == SQLConstants.JOIN_VIEW) {
746:                        dataView = new JoinViewDataPanel((SQLJoinView) table,
747:                                def);
748:                    } else if (table.getObjectType() == SQLConstants.JOIN) {
749:                        dataView = new JoinOperatorDataPanel(
750:                                (SQLJoinOperator) table, def);
751:                    }
752:
753:                    outputDataViewMap.put(table.getId(), dataView);
754:                }
755:
756:                dataView.generateResult(table);
757:                showSplitPaneView(dataView);
758:            }
759:
760:            /**
761:             * simply show the data of all the rows and column of the given table
762:             *
763:             * @param table - table
764:             */
765:            private void showRejectionDataOutputView(final SQLObject table) {
766:                SQLUIModel model = (SQLUIModel) getGraphView().getGraphModel();
767:                if (!(model instanceof  CollabSQLUIModel)) {
768:                    return;
769:                }
770:
771:                SQLDefinition def = ((CollabSQLUIModel) model)
772:                        .getSQLDefinition();
773:                DataOutputPanel view = rejectionDataViewMap.get(table.getId());
774:                if (view == null) {
775:                    view = new RejectedRowsDataPanel(table, def);
776:                    rejectionDataViewMap.put(table.getId(), view);
777:                }
778:
779:                view.generateResult(table);
780:                showSplitPaneView(view);
781:            }
782:
783:            private void showTargetJoinCondition(final SQLBasicTableArea gNode,
784:                    final TargetTable table) {
785:                ConditionBuilderView cView = ConditionBuilderUtil
786:                        .getJoinConditionBuilderView(table,
787:                                (IGraphViewContainer) this .getGraphView()
788:                                        .getGraphViewContainer());
789:                String nbBundle3 = mLoc.t("PRSR001: Target Join Condition");
790:                String title = Localizer.parse(nbBundle3);
791:
792:                // Create a Dialog that defers decision-making on whether to close the dialog to
793:                // an ActionListener.
794:                DialogDescriptor dd = new DialogDescriptor(cView, title, true,
795:                        NotifyDescriptor.OK_CANCEL_OPTION, null, null);
796:
797:                // Pushes closing logic to ActionListener impl
798:                dd.setClosingOptions(new Object[0]);
799:
800:                Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
801:                dlg.getAccessibleContext().setAccessibleDescription(
802:                        "This dialog helps user specify TargetJoinCondition");
803:                ActionListener dlgListener = new ConditionValidator.TargetJoinConditioon(
804:                        gNode, table, cView, dlg, sqlModel);
805:                dd.setButtonListener(dlgListener);
806:
807:                dlg.setModal(true);
808:                dlg.setVisible(true);
809:                updateActions();
810:            }
811:
812:            private void showTargetFilterCondition(
813:                    final SQLBasicTableArea gNode, final TargetTable table) {
814:                ConditionBuilderView cView = ConditionBuilderUtil
815:                        .getFilterConditionBuilderView(table,
816:                                (IGraphViewContainer) this .getGraphView()
817:                                        .getGraphViewContainer());
818:                String nbBundle4 = mLoc.t("PRSR001: Outer Filter Condition");
819:                String title = Localizer.parse(nbBundle4);
820:
821:                // Create a Dialog that defers decision-making on whether to close the dialog to
822:                // an ActionListener.
823:                DialogDescriptor dd = new DialogDescriptor(cView, title, true,
824:                        NotifyDescriptor.OK_CANCEL_OPTION, null, null);
825:
826:                // Pushes closing logic to ActionListener impl
827:                dd.setClosingOptions(new Object[0]);
828:
829:                Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
830:                dlg
831:                        .getAccessibleContext()
832:                        .setAccessibleDescription(
833:                                "This dialog lets user configure outer filter condition for target table");
834:                ActionListener dlgListener = new ConditionValidator.TargetFilterCondition(
835:                        gNode, table, cView, dlg, sqlModel);
836:                dd.setButtonListener(dlgListener);
837:
838:                dlg.setModal(true);
839:                dlg.setVisible(true);
840:                updateActions();
841:            }
842:
843:            private boolean isDirty() {
844:                return sqlModel.isDirty();
845:            }
846:
847:            private void updateActions() {
848:                if (isDirty()) {
849:                    //SQLUIModel model = (SQLUIModel) getGraphView().getGraphModel();
850:                    /*IToolBar toolBar = this.getToolBar();
851:                    if (toolBar == null) {
852:                    return;
853:                    }
854:                    Action undoAction = toolBar.getAction(UndoAction.class);
855:                    Action redoAction = toolBar.getAction(RedoAction.class);
856:                    UndoManager undoManager = model.getUndoManager();
857:                    if (undoManager != null && undoAction != null && redoAction != null) {
858:                    undoAction.setEnabled(undoManager.canUndo());
859:                    redoAction.setEnabled(undoManager.canRedo());
860:                    }*/
861:                    try {
862:                        ETLDataObject etlDataObject = DataObjectProvider
863:                                .getProvider().getActiveDataObject();
864:                        ETLEditorSupport editor = etlDataObject
865:                                .getETLEditorSupport();
866:                        editor.synchDocument();
867:                    } catch (Exception e) {
868:                        //ignore
869:                    }
870:                }
871:            }
872:        }
ww__w_.__j_a_v__a_2__s_.___c_om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.