Source Code Cross Referenced for SQLSourceTableArea.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » sql » framework » ui » view » graph » 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.graph 
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.graph;
042:
043:        import com.sun.sql.framework.exception.BaseException;
044:        import com.sun.sql.framework.exception.DBSQLException;
045:        import java.awt.Color;
046:        import java.awt.Dimension;
047:        import java.awt.Point;
048:        import java.awt.event.ActionEvent;
049:        import java.awt.event.ActionListener;
050:        import java.net.URL;
051:        import java.util.Iterator;
052:        import java.util.List;
053:
054:        import javax.swing.Icon;
055:        import javax.swing.ImageIcon;
056:        import javax.swing.JMenuItem;
057:        import javax.swing.ListSelectionModel;
058:
059:        import org.netbeans.modules.etl.ui.DataObjectProvider;
060:        import org.netbeans.modules.etl.ui.ETLDataObject;
061:        import org.netbeans.modules.etl.ui.ETLEditorSupport;
062:        import org.netbeans.modules.sql.framework.model.SQLCondition;
063:        import org.netbeans.modules.sql.framework.model.SQLDBColumn;
064:        import org.netbeans.modules.sql.framework.model.SQLDBTable;
065:        import org.netbeans.modules.sql.framework.model.SQLObject;
066:        import org.netbeans.modules.sql.framework.model.SourceTable;
067:        import org.netbeans.modules.sql.framework.model.TargetTable;
068:        import org.netbeans.modules.sql.framework.model.utils.SQLObjectUtil;
069:        import org.netbeans.modules.sql.framework.ui.graph.ICommand;
070:        import org.netbeans.modules.sql.framework.ui.graph.IGraphController;
071:        import org.netbeans.modules.sql.framework.ui.graph.IGraphNode;
072:        import org.netbeans.modules.sql.framework.ui.graph.IGraphPort;
073:        import org.netbeans.modules.sql.framework.ui.graph.IGraphView;
074:        import org.netbeans.modules.sql.framework.ui.graph.impl.GradientBrush;
075:        import org.netbeans.modules.sql.framework.ui.model.CollabSQLUIModel;
076:        import org.netbeans.modules.sql.framework.ui.view.TableSelectionPanel;
077:        import org.openide.DialogDescriptor;
078:        import org.openide.DialogDisplayer;
079:        import org.openide.NotifyDescriptor;
080:        import org.openide.util.Exceptions;
081:
082:        import com.nwoods.jgo.JGoBrush;
083:        import com.nwoods.jgo.JGoView;
084:        import java.awt.event.InputEvent;
085:        import javax.swing.JOptionPane;
086:        import javax.swing.KeyStroke;
087:        import net.java.hulp.i18n.Logger;
088:        import org.netbeans.modules.etl.logger.Localizer;
089:        import org.netbeans.modules.etl.logger.LogUtil;
090:        import org.netbeans.modules.etl.ui.view.ETLCollaborationTopPanel;
091:        import org.netbeans.modules.sql.framework.model.DBMetaDataFactory;
092:        import org.netbeans.modules.sql.framework.model.SQLDBModel;
093:        import org.netbeans.modules.sql.framework.model.SQLJoinView;
094:        import org.netbeans.modules.sql.framework.model.impl.SQLDBModelImpl;
095:        import org.netbeans.modules.sql.framework.model.visitors.SQLDBSynchronizationVisitor;
096:        import org.netbeans.modules.sql.framework.ui.view.BasicTopView;
097:        import org.netbeans.modules.sql.framework.ui.view.join.JoinViewGraphNode;
098:        import org.openide.awt.StatusDisplayer;
099:        import org.openide.windows.WindowManager;
100:
101:        /**
102:         * @author Ritesh Adval
103:         * @author Jonathan Giron
104:         */
105:        public class SQLSourceTableArea extends SQLBasicTableArea {
106:
107:            private static URL sourceTableImgUrl = SQLSourceTableArea.class
108:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/SourceTable.png");
109:            private static URL showDataUrl = SQLSourceTableArea.class
110:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/SourceTable.png");
111:            private static URL showSqlUrl = SQLSourceTableArea.class
112:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/Show_Sql.png");
113:            private static URL autoMapImgUrl = SQLSourceTableArea.class
114:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/AutoMapToTarget.png");
115:            private static URL defineValidationImgUrl = SQLSourceTableArea.class
116:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/validateMenu.png");
117:            private static URL dataFilterImgUrl = SQLSourceTableArea.class
118:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/filter16.gif");
119:            private static URL propertiesUrl = SQLSourceTableArea.class
120:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/properties.png");
121:            private static URL synchroniseImgUrl = SQLSourceTableArea.class
122:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/refresh.png");
123:            private static URL remountImgUrl = SQLSourceTableArea.class
124:                    .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/redo.png");
125:            private static final Color DEFAULT_BG_COLOR = new Color(204, 213,
126:                    241);
127:            private static final Color DEFAULT_BG_COLOR_DARK = new Color(165,
128:                    193, 249); // new Color(249, 224, 127);
129:            private static final JGoBrush DEFAULT_TITLE_BRUSH = new GradientBrush(
130:                    DEFAULT_BG_COLOR_DARK, DEFAULT_BG_COLOR);
131:            private JMenuItem showSqlItem;
132:            private JMenuItem showDataItem;
133:            private JMenuItem propertiesItem;
134:            private JMenuItem autoMapItem;
135:            private JMenuItem dataValidationMapItem;
136:            private JMenuItem dataFilterMapItem;
137:            private JMenuItem synchroniseItem;
138:            private JMenuItem remountItem;
139:            private transient ETLCollaborationTopPanel designView;
140:            private static transient final Logger mLogger = LogUtil
141:                    .getLogger(SQLSourceTableArea.class.getName());
142:            private static transient final Localizer mLoc = Localizer.get();
143:
144:            /**
145:             * Creates a new instance of SQLSourceTableArea
146:             */
147:            public SQLSourceTableArea() {
148:                super ();
149:            }
150:
151:            /**
152:             * Creates a new instance of SQLSourceTableArea
153:             *
154:             * @param table the table to render
155:             */
156:            public SQLSourceTableArea(SourceTable table) {
157:                super (table);
158:            }
159:
160:            /**
161:             *
162:             */
163:            protected void initializePopUpMenu() {
164:                try {
165:                    ActionListener aListener = new TableActionListener();
166:                    // Show SQL
167:                    String nbBundle1 = mLoc.t("PRSR001: Show SQL");
168:                    String lblShowSql = Localizer.parse(nbBundle1);
169:                    showSqlItem = new JMenuItem(lblShowSql, new ImageIcon(
170:                            showSqlUrl));
171:                    showSqlItem.setAccelerator(KeyStroke.getKeyStroke('S',
172:                            InputEvent.CTRL_MASK));
173:                    showSqlItem.addActionListener(aListener);
174:                    popUpMenu.add(showSqlItem);
175:
176:                    // Show data
177:                    String nbBundle2 = mLoc.t("PRSR001: Show Data");
178:                    String lblShowData = Localizer.parse(nbBundle2);
179:                    showDataItem = new JMenuItem(lblShowData, new ImageIcon(
180:                            showDataUrl));
181:                    showDataItem.setAccelerator(KeyStroke.getKeyStroke('D',
182:                            InputEvent.CTRL_MASK));
183:                    showDataItem.addActionListener(aListener);
184:                    popUpMenu.add(showDataItem);
185:
186:                    addSelectVisibleColumnsPopUpMenu(aListener);
187:                    synchroniseItem = new JMenuItem("Refresh Metadata",
188:                            new ImageIcon(synchroniseImgUrl));
189:                    synchroniseItem.setAccelerator(KeyStroke.getKeyStroke('R',
190:                            InputEvent.CTRL_MASK));
191:                    synchroniseItem.addActionListener(aListener);
192:                    popUpMenu.add(synchroniseItem);
193:
194:                    String nbBundle3 = mLoc.t("PRSR001: Remount");
195:                    String lblRemount = Localizer.parse(nbBundle3);
196:                    remountItem = new JMenuItem(lblRemount, new ImageIcon(
197:                            remountImgUrl));
198:                    remountItem.setAccelerator(KeyStroke.getKeyStroke('M',
199:                            InputEvent.CTRL_MASK));
200:                    remountItem.addActionListener(aListener);
201:                    SQLObject tbl = (SQLObject) SQLSourceTableArea.this 
202:                            .getDataObject();
203:                    SQLDBModelImpl impl = (SQLDBModelImpl) tbl
204:                            .getParentObject();
205:                    if (impl.getETLDBConnectionDefinition().getDBType().equals(
206:                            DBMetaDataFactory.AXION)
207:                            || impl.getETLDBConnectionDefinition().getDBType()
208:                                    .equalsIgnoreCase("Internal")) {
209:                        popUpMenu.add(remountItem);
210:                    }
211:
212:                    // Define data filtering action
213:                    String nbBundle4 = mLoc
214:                            .t("PRSR001: Extraction Condition...");
215:                    popUpMenu.addSeparator();
216:                    dataFilterMapItem = new JMenuItem(Localizer
217:                            .parse(nbBundle4), new ImageIcon(dataFilterImgUrl));
218:                    dataFilterMapItem.setAccelerator(KeyStroke.getKeyStroke(
219:                            'F', InputEvent.CTRL_MASK));
220:                    dataFilterMapItem.addActionListener(aListener);
221:                    popUpMenu.add(dataFilterMapItem);
222:
223:                    // Define data validation action
224:                    String nbBundle5 = mLoc.t("PRSR001: Data Validation...");
225:                    dataValidationMapItem = new JMenuItem(Localizer
226:                            .parse(nbBundle5), new ImageIcon(
227:                            defineValidationImgUrl));
228:                    dataValidationMapItem.setAccelerator(KeyStroke
229:                            .getKeyStroke('V', InputEvent.CTRL_MASK));
230:                    dataValidationMapItem.addActionListener(aListener);
231:                    popUpMenu.add(dataValidationMapItem);
232:
233:                    // Remove
234:                    popUpMenu.addSeparator();
235:                    addRemovePopUpMenu(aListener);
236:
237:                    // Show properties
238:                    popUpMenu.addSeparator();
239:                    String nbBundle6 = mLoc.t("PRSR001: Properties");
240:                    String lblProps = Localizer.parse(nbBundle6);
241:                    propertiesItem = new JMenuItem(lblProps, new ImageIcon(
242:                            propertiesUrl));
243:                    propertiesItem.setAccelerator(KeyStroke.getKeyStroke('P',
244:                            InputEvent.CTRL_MASK));
245:                    propertiesItem.addActionListener(aListener);
246:                    popUpMenu.add(propertiesItem);
247:
248:                    // Auto map action
249:                    String nbBundle7 = mLoc.t("PRSR001: Auto Map");
250:                    autoMapItem = new JMenuItem(Localizer.parse(nbBundle7),
251:                            new ImageIcon(autoMapImgUrl));
252:                    autoMapItem.setAccelerator(KeyStroke.getKeyStroke('A',
253:                            InputEvent.CTRL_MASK));
254:                    autoMapItem.addActionListener(aListener);
255:
256:                    popUpMenu.addSeparator();
257:                    popUpMenu.add(autoMapItem);
258:                } catch (BaseException ex) {
259:                    Exceptions.printStackTrace(ex);
260:                }
261:
262:            }
263:
264:            Icon createIcon() {
265:                return new ImageIcon(sourceTableImgUrl);
266:            }
267:
268:            private class TableActionListener implements  ActionListener {
269:
270:                /**
271:                 * Invoked when an action occurs.
272:                 *
273:                 * @param e ActionEvent to handle
274:                 */
275:                public void actionPerformed(ActionEvent e) {
276:                    Object source = e.getSource();
277:                    if (source == propertiesItem) {
278:                        Properties_ActionPerformed(e);
279:                    } else if (source == showSqlItem) {
280:                        ShowSql_ActionPerformed(e);
281:                    } else if (source == remountItem) {
282:                        Remount_ActionPerformed(e);
283:                    } else if (source == showDataItem) {
284:                        ShowData_ActionPerformed(e);
285:                    } else if (source == autoMapItem) {
286:                        performAutoMap(e);
287:                    } else if (source == dataValidationMapItem) {
288:                        DataValidation_ActionPerformed(e);
289:                    } else if (source == synchroniseItem) {
290:                        synchroniseItem_ActionPerformed(e);
291:                    } else if (source == dataFilterMapItem) {
292:                        showDataFilter_ActionPerformed(e);
293:                    } else {
294:                        handleCommonActions(e);
295:                    }
296:                }
297:            }
298:
299:            private void Properties_ActionPerformed(ActionEvent e) {
300:                if (!WindowManager.getDefault().findTopComponent("properties")
301:                        .isShowing()) {
302:                    WindowManager.getDefault().findTopComponent("properties")
303:                            .open();
304:                }
305:            }
306:
307:            private void Remount_ActionPerformed(ActionEvent e) {
308:                try {
309:                    SQLDBTable table = (SQLDBTable) SQLSourceTableArea.this 
310:                            .getDataObject();
311:                    SQLObjectUtil.dropTable(table, (SQLDBModel) table
312:                            .getParent());
313:                    SQLObjectUtil.createTable(table, (SQLDBModel) table
314:                            .getParent());
315:                    SQLObjectUtil.setOrgProperties(table);
316:                } catch (Exception ex) {
317:                    Exceptions.printStackTrace(ex);
318:                    StatusDisplayer.getDefault().setStatusText(
319:                            "Unable to remount :" + ex.getMessage());
320:                }
321:            }
322:
323:            private void ShowSql_ActionPerformed(ActionEvent e) {
324:                SQLObject sqlObject = (SQLObject) SQLSourceTableArea.this 
325:                        .getDataObject();
326:                Object[] args = new Object[] { sqlObject };
327:                this .getGraphView().execute(ICommand.SHOW_SQL_CMD, args);
328:            }
329:
330:            private void ShowData_ActionPerformed(ActionEvent e) {
331:                SQLObject tbl = (SQLObject) SQLSourceTableArea.this 
332:                        .getDataObject();
333:                this .getGraphView().execute(ICommand.SHOW_DATA_CMD,
334:                        new Object[] { tbl });
335:            }
336:
337:            private void showDataFilter_ActionPerformed(ActionEvent e) {
338:                SQLObject sqlObject = (SQLObject) SQLSourceTableArea.this 
339:                        .getDataObject();
340:                Object[] args = new Object[] { SQLSourceTableArea.this ,
341:                        sqlObject };
342:                this .getGraphView().execute(ICommand.DATA_EXTRACTION, args);
343:            }
344:
345:            private void synchroniseItem_ActionPerformed(ActionEvent e) {
346:                IGraphView gView = this .getGraphView();
347:                CollabSQLUIModel sqlModel = (CollabSQLUIModel) gView
348:                        .getGraphModel();
349:
350:                String nbBundle8 = mLoc
351:                        .t("PRSR001: If columns are deleted or renamed you may lose existing mappings.");
352:                String dlgMsg = Localizer.parse(nbBundle8);
353:                String nbBundle9 = mLoc.t("PRSR001: Refresh Metadata");
354:                String dlgTitle = Localizer.parse(nbBundle9);
355:                int response = JOptionPane.showConfirmDialog(WindowManager
356:                        .getDefault().getMainWindow(), dlgMsg, dlgTitle,
357:                        JOptionPane.OK_CANCEL_OPTION,
358:                        JOptionPane.WARNING_MESSAGE);
359:
360:                if (JOptionPane.OK_OPTION == response) {
361:                    try {
362:                        SQLDBTable tbl = (SQLDBTable) SQLSourceTableArea.this 
363:                                .getDataObject();
364:                        SQLDBSynchronizationVisitor visitView = new SQLDBSynchronizationVisitor();
365:
366:                        SQLTableArea tableArea1 = (SQLTableArea) this 
367:                                .getTableArea();
368:                        MetaTableModel model = (MetaTableModel) tableArea1
369:                                .getModel();
370:                        visitView.mergeCollabTableWithDatabaseTable(tbl, model);
371:                        if (!visitView.infoList.isEmpty()) {
372:                            tableArea1.layoutChildren();
373:                            SQLJoinView jView = sqlModel
374:                                    .getJoinView((SourceTable) tbl);
375:                            if (jView != null) {
376:                                JoinViewGraphNode jViewGraph = (JoinViewGraphNode) gView
377:                                        .findGraphNode(jView);
378:                                jViewGraph.layoutChildren();
379:                                jViewGraph.setHeight(jViewGraph
380:                                        .getMaximumHeight());
381:                            }
382:                            // Mark collab as needing to be persisted.
383:                            sqlModel.setDirty(true);
384:                        }
385:                        BasicTopView gvMgr = (BasicTopView) gView
386:                                .getGraphViewContainer();
387:                        gvMgr.showRefreshMetadataInfo(visitView.infoList);
388:                    } catch (DBSQLException ex) {
389:                        Exceptions.printStackTrace(ex);
390:                    } catch (Exception ex) {
391:                        Exceptions.printStackTrace(ex);
392:                    }
393:                }
394:            }
395:
396:            private void performAutoMap(ActionEvent e) {
397:                IGraphView gView = this .getGraphView();
398:                CollabSQLUIModel sqlModel = (CollabSQLUIModel) gView
399:                        .getGraphModel();
400:
401:                if (sqlModel != null) {
402:                    List tTables = sqlModel.getSQLDefinition()
403:                            .getTargetTables();
404:                    //if there is only one target table
405:                    if (tTables.size() == 1) {
406:                        createLinksToTarget((TargetTable) tTables.get(0));
407:                        return;
408:                    }
409:
410:                    TargetTable tt = SQLObjectUtil.getMappedTargetTable(
411:                            (SQLObject) this .getDataObject(), tTables);
412:                    if (tt != null) {
413:                        createLinksToTarget(tt);
414:                        return;
415:                    }
416:
417:                    //otherwise we have multiple target tables so need to ask user to select a
418:                    // target
419:                    //table
420:                    TableSelectionPanel tableSelectionPanel = new TableSelectionPanel(
421:                            tTables);
422:                    tableSelectionPanel
423:                            .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
424:                    tableSelectionPanel
425:                            .setPreferredSize(new Dimension(200, 160));
426:
427:                    DialogDescriptor dd = new DialogDescriptor(
428:                            tableSelectionPanel,
429:                            "Select Target Table to Auto Map", true,
430:                            NotifyDescriptor.OK_CANCEL_OPTION, null, null);
431:
432:                    if (DialogDisplayer.getDefault().notify(dd) == NotifyDescriptor.OK_OPTION) {
433:                        List selectedTables = tableSelectionPanel
434:                                .getSelectedTables();
435:                        if (selectedTables.size() == 1) {
436:                            createLinksToTarget((TargetTable) selectedTables
437:                                    .get(0));
438:                        }
439:                    }
440:                }
441:                updateActions();
442:            }
443:
444:            private void createLinksToTarget(TargetTable tTable) {
445:                IGraphView gView = this .getGraphView();
446:                if (!(gView instanceof  SQLGraphView)) {
447:                    return;
448:                }
449:
450:                IGraphController graphController = gView.getGraphController();
451:
452:                IGraphNode targetNode = gView.findGraphNode(tTable);
453:                if (targetNode == null) {
454:                    return;
455:                }
456:
457:                SQLDBTable sTable = (SQLDBTable) this .getDataObject();
458:                Iterator it = sTable.getColumnList().iterator();
459:
460:                while (it.hasNext()) {
461:                    SQLDBColumn column = (SQLDBColumn) it.next();
462:                    SQLDBColumn tColumn = getColumnIgnoreCase(tTable, column
463:                            .getName());
464:                    if (tColumn != null
465:                            && tColumn.getJdbcType() == column.getJdbcType()) {
466:
467:                        IGraphPort from = this .getOutputGraphPort(column
468:                                .getName());
469:                        IGraphPort to = targetNode.getInputGraphPort(tColumn
470:                                .getName());
471:                        if (from != null && to != null) {
472:                            graphController.handleLinkAdded(from, to);
473:                        }
474:                    }
475:                }
476:                updateActions();
477:            }
478:
479:            private SQLDBColumn getColumnIgnoreCase(TargetTable tt,
480:                    String columnName) {
481:                Iterator it = tt.getColumnList().iterator();
482:
483:                while (it.hasNext()) {
484:                    SQLDBColumn column = (SQLDBColumn) it.next();
485:                    if (column.getName().equalsIgnoreCase(columnName)) {
486:                        return column;
487:                    }
488:                }
489:
490:                return null;
491:            }
492:
493:            private void DataValidation_ActionPerformed(ActionEvent e) {
494:                SQLObject sqlObject = (SQLObject) SQLSourceTableArea.this 
495:                        .getDataObject();
496:                Object[] args = new Object[] { SQLSourceTableArea.this ,
497:                        sqlObject };
498:                this .getGraphView().execute(ICommand.DATA_VALIDATION, args);
499:            }
500:
501:            public boolean doMouseClick(int modifiers, Point dc, Point vc,
502:                    JGoView view1) {
503:                IGraphView gView = this .getGraphView();
504:                CollabSQLUIModel sqlModel = (CollabSQLUIModel) gView
505:                        .getGraphModel();
506:                if (sqlModel != null) {
507:                    List tTables = sqlModel.getSQLDefinition()
508:                            .getTargetTables();
509:                    //if there are no target tables then we need not show automap menu item
510:                    if (tTables.size() == 0) {
511:                        this .autoMapItem.setEnabled(false);
512:                        return super .doMouseClick(modifiers, dc, vc, view1);
513:                    }
514:
515:                    this .autoMapItem.setEnabled(true);
516:
517:                    //if there is only one target table then we do not need to show a dialog to
518:                    // the user
519:                    //to select a target table
520:                    if (tTables.size() == 1) {
521:                        this .autoMapItem.setText("Auto Map");
522:                        return super .doMouseClick(modifiers, dc, vc, view1);
523:                    }
524:
525:                    TargetTable tt = SQLObjectUtil.getMappedTargetTable(
526:                            (SQLObject) this .getDataObject(), tTables);
527:                    //if this source table is already mapped to an existing target table
528:                    //then auto map should map to that target table and also we do not need to
529:                    // show dialog to the user
530:                    if (tt != null) {
531:                        this .autoMapItem.setText("Auto Map");
532:                        return super .doMouseClick(modifiers, dc, vc, view1);
533:                    }
534:
535:                    //otherwise there are multiple target tables so we need to show a dialog
536:                    //to the user
537:                    this .autoMapItem.setText("Auto Map...");
538:                    return super .doMouseClick(modifiers, dc, vc, view1);
539:                }
540:
541:                return super .doMouseClick(modifiers, dc, vc, view1);
542:            }
543:
544:            /**
545:             * Sets the data object
546:             *
547:             * @param obj - then object to be represented by this node
548:             */
549:            public void setDataObject(Object obj) {
550:                super .setDataObject(obj);
551:                setConditionIcons();
552:            }
553:
554:            /**
555:             * Sets Data extraction and Validation icons.
556:             *
557:             * @see org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea#setConditionIcons()
558:             */
559:            public void setConditionIcons() {
560:                SQLCondition extractionCondition = null;
561:                SQLCondition validationCondition = null;
562:
563:                SourceTable tbl = (SourceTable) this .getDataObject();
564:                if (tbl != null) {
565:                    extractionCondition = tbl.getExtractionCondition();
566:                    validationCondition = tbl.getDataValidationCondition();
567:
568:                    setTableConditionIcons(extractionCondition,
569:                            validationCondition);
570:                }
571:            }
572:
573:            /**
574:             * @see org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea#getDefaultTitleBrush()
575:             */
576:            protected JGoBrush getDefaultTitleBrush() {
577:                return DEFAULT_TITLE_BRUSH;
578:            }
579:
580:            /**
581:             * @return
582:             * @see org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea#getDefaultBackgroundColor()
583:             */
584:            protected Color getDefaultBackgroundColor() {
585:                return DEFAULT_BG_COLOR;
586:            }
587:
588:            private void updateActions() {
589:                try {
590:                    this .getView().updateUI();
591:                    ETLDataObject etlDataObject = DataObjectProvider
592:                            .getProvider().getActiveDataObject();
593:                    ETLEditorSupport editor = etlDataObject
594:                            .getETLEditorSupport();
595:                    editor.synchDocument();
596:                } catch (Exception ex) {
597:                    //ignore
598:                }
599:            }
600:        }
w__w__w_.___j_ava2_s___.c___o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.