Source Code Cross Referenced for DataPumper.java in  » Database-Client » SQL-Workbench » workbench » gui » tools » 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 » Database Client » SQL Workbench » workbench.gui.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * DataPumper.java
0003:         *
0004:         * This file is part of SQL Workbench/J, http://www.sql-workbench.net
0005:         *
0006:         * Copyright 2002-2008, Thomas Kellerer
0007:         * No part of this code maybe reused without the permission of the author
0008:         *
0009:         * To contact the author please send an email to: support@sql-workbench.net
0010:         *
0011:         */
0012:        package workbench.gui.tools;
0013:
0014:        import java.awt.BorderLayout;
0015:        import java.awt.EventQueue;
0016:        import java.awt.event.ActionListener;
0017:        import java.awt.event.WindowListener;
0018:        import java.beans.PropertyChangeListener;
0019:        import java.io.File;
0020:        import java.sql.SQLException;
0021:        import java.util.ArrayList;
0022:        import java.util.Collection;
0023:        import java.util.Collections;
0024:        import java.util.HashMap;
0025:        import java.util.Iterator;
0026:        import java.util.List;
0027:        import java.util.Map;
0028:        import javax.swing.JFrame;
0029:        import javax.swing.JPanel;
0030:        import javax.swing.WindowConstants;
0031:        import workbench.WbManager;
0032:        import workbench.db.ColumnIdentifier;
0033:        import workbench.db.ConnectionMgr;
0034:        import workbench.db.ConnectionProfile;
0035:        import workbench.db.datacopy.DataCopier;
0036:        import workbench.db.TableIdentifier;
0037:        import workbench.db.WbConnection;
0038:        import workbench.db.importer.DataImporter;
0039:        import workbench.db.importer.ProducerFactory;
0040:        import workbench.gui.actions.AutoCompletionAction;
0041:        import workbench.gui.components.RunningJobIndicator;
0042:        import workbench.interfaces.StatusBar;
0043:        import workbench.sql.wbcommands.CommandTester;
0044:        import workbench.sql.wbcommands.CommonArgs;
0045:        import workbench.util.ExceptionUtil;
0046:        import workbench.gui.MainWindow;
0047:        import workbench.gui.WbSwingUtilities;
0048:        import workbench.gui.components.DividerBorder;
0049:        import workbench.gui.components.EditWindow;
0050:        import workbench.gui.components.FlatButton;
0051:        import workbench.gui.components.WbButton;
0052:        import workbench.gui.components.WbSplitPane;
0053:        import workbench.gui.dialogs.dataimport.ImportFileDialog;
0054:        import workbench.gui.help.HelpManager;
0055:        import workbench.gui.profiles.ProfileSelectionDialog;
0056:        import workbench.gui.sql.EditorPanel;
0057:        import workbench.interfaces.ToolWindow;
0058:        import workbench.log.LogMgr;
0059:        import workbench.resource.ResourceMgr;
0060:        import workbench.resource.Settings;
0061:        import workbench.sql.wbcommands.WbCopy;
0062:        import workbench.storage.RowActionMonitor;
0063:        import workbench.util.SqlUtil;
0064:        import workbench.util.StringUtil;
0065:        import workbench.util.WbThread;
0066:
0067:        /**
0068:         * A GUI frontend to the {@link workbench.db.datacopy.DataCopier} 
0069:         * and {@link workbench.db.importer.DataImporter} tools.
0070:         * 
0071:         * @author  support@sql-workbench.net
0072:         */
0073:        public class DataPumper extends JPanel implements  ActionListener,
0074:                WindowListener, PropertyChangeListener, RowActionMonitor,
0075:                ToolWindow, StatusBar {
0076:            private File sourceFile;
0077:            private ProducerFactory fileImporter;
0078:            private DataCopier copier;
0079:
0080:            private ConnectionProfile sourceProfile;
0081:            private ConnectionProfile targetProfile;
0082:            protected WbConnection sourceConnection;
0083:            protected WbConnection targetConnection;
0084:
0085:            protected AutoCompletionAction completionAction;
0086:
0087:            private JFrame window;
0088:
0089:            private ColumnMapper columnMapper;
0090:            private final String copyMsg = ResourceMgr
0091:                    .getString("MsgCopyingRow");
0092:            protected boolean copyRunning = false;
0093:            private EditorPanel sqlEditor;
0094:            private boolean supportsBatch = false;
0095:
0096:            // used in the Jemmy Unit Test to wait for the connection thread
0097:            boolean isConnecting = false;
0098:
0099:            public DataPumper(ConnectionProfile source, ConnectionProfile target) {
0100:                this .sourceProfile = source;
0101:                this .targetProfile = target;
0102:                initComponents();
0103:
0104:                this .selectSourceButton.addActionListener(this );
0105:                this .selectTargetButton.addActionListener(this );
0106:                this .openFileButton.addActionListener(this );
0107:                this .closeButton.addActionListener(this );
0108:                this .updateDisplay();
0109:                this .startButton.addActionListener(this );
0110:                this .cancelButton.addActionListener(this );
0111:                this .showLogButton.addActionListener(this );
0112:                this .helpButton.addActionListener(this );
0113:                this .columnMapper = new ColumnMapper();
0114:                this .mapperPanel.setLayout(new BorderLayout());
0115:                this .mapperPanel.add(this .columnMapper, BorderLayout.CENTER);
0116:
0117:                this .updateOptionPanel.setBorder(new DividerBorder(
0118:                        DividerBorder.LEFT));
0119:                this .checkQueryButton.addActionListener(this );
0120:                this .showWbCommand.addActionListener(this );
0121:                this .useQueryCbx.addActionListener(this );
0122:                this .sqlEditor = EditorPanel.createSqlEditor();
0123:                this .sqlEditor.showFormatSql();
0124:                this .completionAction = new AutoCompletionAction(
0125:                        this .sqlEditor, this );
0126:                this .wherePanel.add(this .sqlEditor);
0127:                this .showWbCommand.setEnabled(false);
0128:                this .batchSize.setEnabled(false);
0129:
0130:                this .sourceTable.setTableDropDownName("sourceTable");
0131:                this .targetTable.setTableDropDownName("targetTable");
0132:            }
0133:
0134:            public void saveSettings() {
0135:                Settings s = Settings.getInstance();
0136:                if (this .sourceProfile != null) {
0137:                    s.setLastConnection(
0138:                            "workbench.datapumper.source.lastprofile",
0139:                            this .sourceProfile);
0140:                }
0141:                if (this .targetProfile != null) {
0142:                    s.setLastConnection(
0143:                            "workbench.datapumper.target.lastprofile",
0144:                            this .targetProfile);
0145:                }
0146:                s.setProperty("workbench.datapumper.divider", jSplitPane1
0147:                        .getDividerLocation());
0148:                s.setProperty("workbench.datapumper.target.deletetable",
0149:                        Boolean.toString(this .deleteTargetCbx.isSelected()));
0150:                s.setProperty("workbench.datapumper.continue", Boolean
0151:                        .toString(this .continueOnErrorCbx.isSelected()));
0152:                s.setProperty("workbench.datapumper.commitevery",
0153:                        this .commitEvery.getText());
0154:                s.setProperty("workbench.datapumper.usequery", Boolean
0155:                        .toString(this .useQueryCbx.isSelected()));
0156:                s.setProperty("workbench.datapumper.droptable", Boolean
0157:                        .toString(this .dropTargetCbx.isSelected()));
0158:                s.setProperty("workbench.datapumper.updatemode",
0159:                        (String) this .modeComboBox.getSelectedItem());
0160:                String where = this .sqlEditor.getText();
0161:                if (where != null && where.length() > 0) {
0162:                    s.setProperty("workbench.datapumper.where", where);
0163:                } else {
0164:                    s.setProperty("workbench.datapumper.where", "");
0165:                }
0166:                s.storeWindowSize(this .window, "workbench.datapumper.window");
0167:                s.storeWindowPosition(this .window,
0168:                        "workbench.datapumper.window");
0169:                s.setProperty("workbench.datapumper.batchsize", getBatchSize());
0170:            }
0171:
0172:            public void activate() {
0173:                this .window.setVisible(true);
0174:                this .window.toFront();
0175:            }
0176:
0177:            public WbConnection getConnection() {
0178:                return null;
0179:            }
0180:
0181:            public void restoreSettings() {
0182:                Settings s = Settings.getInstance();
0183:                boolean delete = s.getBoolProperty(
0184:                        "workbench.datapumper.target.deletetable", false);
0185:                boolean cont = s.getBoolProperty(
0186:                        "workbench.datapumper.continue", false);
0187:                boolean drop = s.getBoolProperty(
0188:                        "workbench.datapumper.droptable", false);
0189:                this .deleteTargetCbx.setSelected(delete);
0190:                this .continueOnErrorCbx.setSelected(cont);
0191:                this .dropTargetCbx.setSelected(drop);
0192:                if (!s.restoreWindowSize(this .window,
0193:                        "workbench.datapumper.window")) {
0194:                    this .window.setSize(800, 600);
0195:                }
0196:
0197:                int commit = s.getIntProperty(
0198:                        "workbench.datapumper.commitevery", 0);
0199:                if (commit > 0) {
0200:                    this .commitEvery.setText(Integer.toString(commit));
0201:                }
0202:                String where = s
0203:                        .getProperty("workbench.datapumper.where", null);
0204:                if (where != null && where.length() > 0) {
0205:                    this .sqlEditor.setText(where);
0206:                }
0207:                int loc = s.getIntProperty("workbench.datapumper.divider", -1);
0208:                if (loc == -1) {
0209:                    loc = this .jSplitPane1.getHeight() / 2;
0210:                    if (loc < 10)
0211:                        loc = 100;
0212:                }
0213:                this .jSplitPane1.setDividerLocation(loc);
0214:                boolean useQuery = s.getBoolProperty(
0215:                        "workbench.datapumper.usequery", false);
0216:                this .useQueryCbx.setSelected(useQuery);
0217:
0218:                String mode = s.getProperty("workbench.datapumper.updatemode",
0219:                        "insert");
0220:                this .modeComboBox.setSelectedItem(mode);
0221:
0222:                // initialize the depending controls for the usage of a SQL query
0223:                this .checkType();
0224:                int size = s.getIntProperty("workbench.datapumper.batchsize",
0225:                        -1);
0226:                if (size > 0) {
0227:                    this .batchSize.setText(Integer.toString(size));
0228:                }
0229:            }
0230:
0231:            private void selectInputFile() {
0232:                ImportFileDialog dialog = new ImportFileDialog(this );
0233:                boolean ok = dialog.selectInput(ResourceMgr
0234:                        .getString("TxtWindowTitleSelectImportFile"));
0235:                if (!ok)
0236:                    return;
0237:                if (this .sourceProfile != null) {
0238:                    this .disconnectSource();
0239:                }
0240:                this .sourceFile = dialog.getSelectedFile();
0241:                this .sourceTable.reset();
0242:                this .sourceTable.setEnabled(false);
0243:
0244:                this .useQueryCbx.setSelected(false);
0245:                this .useQueryCbx.setEnabled(false);
0246:                this .sqlEditor.setEnabled(false);
0247:                this .useQueryCbx.setVisible(false);
0248:                this .useQueryCbx.setVisible(false);
0249:                this .sqlEditor.setVisible(false);
0250:
0251:                this .fileImporter = new ProducerFactory(this .sourceFile);
0252:                this .fileImporter.setTextOptions(dialog.getTextOptions());
0253:                this .fileImporter.setGeneralOptions(dialog.getGeneralOptions());
0254:                this .fileImporter.setXmlOptions(dialog.getXmlOptions());
0255:                this .fileImporter.setType(dialog.getImportType());
0256:
0257:                this .checkType();
0258:
0259:                this .updateSourceDisplay();
0260:                if (this .targetProfile != null) {
0261:                    initColumnMapper();
0262:                }
0263:            }
0264:
0265:            private void updateTargetDisplay() {
0266:                String label = ResourceMgr.getString("LblDPTargetProfile");
0267:                if (this .targetProfile != null) {
0268:                    this .targetProfileLabel.setText(label + ": "
0269:                            + this .targetProfile.getName());
0270:                } else {
0271:                    this .targetProfileLabel.setText(label + ": "
0272:                            + ResourceMgr.getString("LblPleaseSelect"));
0273:                }
0274:                this .updateWindowTitle();
0275:            }
0276:
0277:            private void updateSourceDisplay() {
0278:                String label = ResourceMgr.getString("LblDPSourceProfile");
0279:                if (this .sourceProfile != null) {
0280:                    this .sourceProfileLabel.setText(label + ": "
0281:                            + this .sourceProfile.getName());
0282:                } else if (this .sourceFile != null) {
0283:                    this .sourceProfileLabel.setText(ResourceMgr
0284:                            .getString("LblDPSourceFile")
0285:                            + ": " + sourceFile.getAbsolutePath());
0286:                } else {
0287:                    this .sourceProfileLabel.setText(label + ": "
0288:                            + ResourceMgr.getString("LblPleaseSelect"));
0289:                }
0290:                this .updateWindowTitle();
0291:            }
0292:
0293:            private void updateDisplay() {
0294:                this .updateSourceDisplay();
0295:                this .updateTargetDisplay();
0296:                this .updateWindowTitle();
0297:            }
0298:
0299:            protected void updateWindowTitle() {
0300:                if (this .targetProfile != null
0301:                        && (this .sourceProfile != null || this .sourceFile != null)
0302:                        && this .window != null) {
0303:                    String title = ResourceMgr
0304:                            .getString("TxtWindowTitleDataPumper");
0305:                    String sourceName = "";
0306:                    if (this .sourceProfile != null)
0307:                        sourceName = this .sourceProfile.getName();
0308:                    else if (this .sourceFile != null)
0309:                        sourceName = this .sourceFile.getName();
0310:                    title = title + " [" + sourceName + " -> "
0311:                            + this .targetProfile.getName() + "]";
0312:                    if (this .copier != null && this .copyRunning) {
0313:                        title = RunningJobIndicator.TITLE_PREFIX + title;
0314:                    }
0315:                    this .window.setTitle(title);
0316:                }
0317:            }
0318:
0319:            protected void checkConnections() {
0320:                this .connectSource(this .sourceProfile);
0321:                this .connectTarget(this .targetProfile);
0322:            }
0323:
0324:            private void connectSource(final ConnectionProfile profile) {
0325:                if (profile == null)
0326:                    return;
0327:
0328:                Thread t = new WbThread("DataPumper source connection") {
0329:                    public void run() {
0330:                        doConnectSource(profile);
0331:                    }
0332:                };
0333:                t.start();
0334:            }
0335:
0336:            private void doConnectSource(ConnectionProfile profile) {
0337:                this .disconnectSource();
0338:
0339:                this .sourceProfile = profile;
0340:                this .isConnecting = true;
0341:
0342:                String label = ResourceMgr.getString("MsgConnectingTo") + " "
0343:                        + this .sourceProfile.getName() + " ...";
0344:                this .sourceProfileLabel.setIcon(ResourceMgr.getPicture("wait"));
0345:                this .sourceProfileLabel.setText(label);
0346:
0347:                try {
0348:                    this .sourceConnection = ConnectionMgr.getInstance()
0349:                            .getConnection(this .sourceProfile, "Dp-Source");
0350:                    this .sourceConnection.getMetadata().disableOutput();
0351:                } catch (Exception e) {
0352:                    LogMgr.logError("DataPumper.doConnectSource()",
0353:                            "Error when connecting to profile: "
0354:                                    + (sourceProfile == null ? "n/a"
0355:                                            : this .sourceProfile.getName()), e);
0356:                    String msg = ResourceMgr.getString("ErrConnectionError")
0357:                            + "\n" + e.getMessage();
0358:                    this .sourceProfile = null;
0359:                    WbSwingUtilities.showErrorMessage(this , msg);
0360:                } finally {
0361:                    this .sourceProfileLabel.setIcon(null);
0362:                    this .updateSourceDisplay();
0363:                }
0364:
0365:                this .sourceFile = null;
0366:                this .fileImporter = null;
0367:                this .checkType();
0368:
0369:                if (this .useQueryCbx.isSelected()) {
0370:                    initColumnMapper();
0371:                }
0372:
0373:                if (this .sourceConnection != null) {
0374:                    this .sourceTable.setChangeListener(this , "source-table");
0375:
0376:                    Thread t = new WbThread("Retrieve source tables") {
0377:                        public void run() {
0378:                            sourceTable.setConnection(sourceConnection);
0379:                            completionAction.setConnection(sourceConnection);
0380:                            isConnecting = false;
0381:                        }
0382:                    };
0383:                    t.start();
0384:                } else {
0385:                    isConnecting = false;
0386:                }
0387:            }
0388:
0389:            private void connectTarget(final ConnectionProfile profile) {
0390:                if (profile == null)
0391:                    return;
0392:
0393:                Thread t = new WbThread("DataPumper target connection") {
0394:                    public void run() {
0395:                        doConnectTarget(profile);
0396:                    }
0397:                };
0398:                t.start();
0399:            }
0400:
0401:            private void doConnectTarget(ConnectionProfile profile) {
0402:                this .isConnecting = true;
0403:
0404:                this .disconnectTarget();
0405:                this .targetProfile = profile;
0406:
0407:                String label = ResourceMgr.getString("MsgConnectingTo") + " "
0408:                        + this .targetProfile.getName() + " ...";
0409:                this .targetProfileLabel.setText(label);
0410:                this .targetProfileLabel.setIcon(ResourceMgr.getPicture("wait"));
0411:
0412:                try {
0413:                    this .targetConnection = ConnectionMgr.getInstance()
0414:                            .getConnection(this .targetProfile, "Dp-Target");
0415:                    this .targetConnection.getMetadata().disableOutput();
0416:                } catch (Exception e) {
0417:                    LogMgr.logError("DataPumper.doConnectSource()",
0418:                            "Error when connecting to profile: "
0419:                                    + this .targetProfile.getName(), e);
0420:                    String msg = ResourceMgr.getString("ErrConnectionError")
0421:                            + "\n" + e.getMessage();
0422:                    this .targetProfile = null;
0423:                    WbSwingUtilities.showErrorMessage(this , msg);
0424:                } finally {
0425:                    this .targetProfileLabel.setIcon(null);
0426:                    this .updateTargetDisplay();
0427:                }
0428:
0429:                if (this .targetConnection != null) {
0430:                    this .targetTable.setChangeListener(this , "target-table");
0431:                    this .supportsBatch = this .targetConnection.getMetadata()
0432:                            .supportsBatchUpdates();
0433:                    this .checkUseBatch();
0434:                    checkType();
0435:
0436:                    Thread t = new WbThread("Retrieve target tables") {
0437:                        public void run() {
0438:                            targetTable.setConnection(targetConnection);
0439:                            isConnecting = false;
0440:                        }
0441:                    };
0442:                    t.start();
0443:                } else {
0444:                    isConnecting = false;
0445:                }
0446:            }
0447:
0448:            /** This method is called from within the constructor to
0449:             * initialize the form.
0450:             * WARNING: Do NOT modify this code. The content of this method is
0451:             * always regenerated by the Form Editor.
0452:             */
0453:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
0454:            private void initComponents() {
0455:                java.awt.GridBagConstraints gridBagConstraints;
0456:
0457:                sourceProfilePanel = new javax.swing.JPanel();
0458:                sourceProfileLabel = new javax.swing.JLabel();
0459:                selectSourceButton = new FlatButton();
0460:                openFileButton = new FlatButton();
0461:                targetProfilePanel = new javax.swing.JPanel();
0462:                targetProfileLabel = new javax.swing.JLabel();
0463:                selectTargetButton = new FlatButton();
0464:                sourceTable = new workbench.gui.tools.TableSelectorPanel();
0465:                targetTable = new workbench.gui.tools.TableSelectorPanel();
0466:                targetHeader = new javax.swing.JLabel();
0467:                sourceHeader = new javax.swing.JLabel();
0468:                jSplitPane1 = new WbSplitPane();
0469:                mapperPanel = new javax.swing.JPanel();
0470:                optionsPanel = new javax.swing.JPanel();
0471:                jPanel2 = new javax.swing.JPanel();
0472:                sqlPanel = new javax.swing.JPanel();
0473:                wherePanel = new javax.swing.JPanel();
0474:                sqlEditorLabel = new javax.swing.JLabel();
0475:                useQueryCbx = new javax.swing.JCheckBox();
0476:                checkQueryButton = new FlatButton();
0477:                updateOptionPanel = new javax.swing.JPanel();
0478:                commitLabel = new javax.swing.JLabel();
0479:                commitEvery = new javax.swing.JTextField();
0480:                continueOnErrorCbx = new javax.swing.JCheckBox();
0481:                deleteTargetCbx = new javax.swing.JCheckBox();
0482:                dropTargetCbx = new javax.swing.JCheckBox();
0483:                modeComboBox = new javax.swing.JComboBox();
0484:                modeLabel = new javax.swing.JLabel();
0485:                jPanel1 = new javax.swing.JPanel();
0486:                jLabel1 = new javax.swing.JLabel();
0487:                batchSizeLabel = new javax.swing.JLabel();
0488:                batchSize = new javax.swing.JTextField();
0489:                statusLabel = new javax.swing.JLabel();
0490:                buttonPanel = new javax.swing.JPanel();
0491:                jPanel3 = new javax.swing.JPanel();
0492:                startButton = new WbButton();
0493:                cancelButton = new javax.swing.JButton();
0494:                jPanel4 = new javax.swing.JPanel();
0495:                showLogButton = new javax.swing.JButton();
0496:                showWbCommand = new javax.swing.JButton();
0497:                jPanel5 = new javax.swing.JPanel();
0498:                helpButton = new javax.swing.JButton();
0499:                closeButton = new javax.swing.JButton();
0500:
0501:                setLayout(new java.awt.GridBagLayout());
0502:
0503:                sourceProfilePanel.setLayout(new java.awt.GridBagLayout());
0504:
0505:                sourceProfileLabel.setBorder(javax.swing.BorderFactory
0506:                        .createCompoundBorder(javax.swing.BorderFactory
0507:                                .createEtchedBorder(),
0508:                                javax.swing.BorderFactory.createEmptyBorder(0,
0509:                                        2, 0, 0)));
0510:                sourceProfileLabel.setMaximumSize(new java.awt.Dimension(32768,
0511:                        24));
0512:                sourceProfileLabel
0513:                        .setMinimumSize(new java.awt.Dimension(25, 24));
0514:                sourceProfileLabel.setPreferredSize(new java.awt.Dimension(50,
0515:                        24));
0516:                gridBagConstraints = new java.awt.GridBagConstraints();
0517:                gridBagConstraints.gridx = 0;
0518:                gridBagConstraints.gridy = 1;
0519:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0520:                gridBagConstraints.weightx = 1.0;
0521:                sourceProfilePanel.add(sourceProfileLabel, gridBagConstraints);
0522:
0523:                selectSourceButton.setText("...");
0524:                selectSourceButton
0525:                        .setMaximumSize(new java.awt.Dimension(22, 22));
0526:                selectSourceButton
0527:                        .setMinimumSize(new java.awt.Dimension(22, 22));
0528:                selectSourceButton.setName("selectSource"); // NOI18N
0529:                selectSourceButton.setPreferredSize(new java.awt.Dimension(22,
0530:                        22));
0531:                gridBagConstraints = new java.awt.GridBagConstraints();
0532:                gridBagConstraints.gridx = 1;
0533:                gridBagConstraints.gridy = 1;
0534:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0535:                gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 0);
0536:                sourceProfilePanel.add(selectSourceButton, gridBagConstraints);
0537:
0538:                openFileButton.setIcon(ResourceMgr.getImage("Open"));
0539:                openFileButton.setToolTipText(ResourceMgr
0540:                        .getString("d_DataPumperOpenFile"));
0541:                openFileButton.setIconTextGap(0);
0542:                openFileButton.setMaximumSize(new java.awt.Dimension(22, 22));
0543:                openFileButton.setMinimumSize(new java.awt.Dimension(22, 22));
0544:                openFileButton.setPreferredSize(new java.awt.Dimension(22, 22));
0545:                gridBagConstraints = new java.awt.GridBagConstraints();
0546:                gridBagConstraints.gridx = 2;
0547:                gridBagConstraints.gridy = 1;
0548:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0549:                gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 0);
0550:                sourceProfilePanel.add(openFileButton, gridBagConstraints);
0551:
0552:                gridBagConstraints = new java.awt.GridBagConstraints();
0553:                gridBagConstraints.gridx = 0;
0554:                gridBagConstraints.gridy = 1;
0555:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0556:                gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
0557:                gridBagConstraints.weightx = 0.5;
0558:                gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2);
0559:                add(sourceProfilePanel, gridBagConstraints);
0560:
0561:                targetProfilePanel.setLayout(new java.awt.GridBagLayout());
0562:
0563:                targetProfileLabel
0564:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
0565:                targetProfileLabel.setBorder(javax.swing.BorderFactory
0566:                        .createCompoundBorder(javax.swing.BorderFactory
0567:                                .createEtchedBorder(),
0568:                                javax.swing.BorderFactory.createEmptyBorder(0,
0569:                                        2, 0, 0)));
0570:                targetProfileLabel.setMaximumSize(new java.awt.Dimension(32768,
0571:                        24));
0572:                targetProfileLabel
0573:                        .setMinimumSize(new java.awt.Dimension(25, 24));
0574:                targetProfileLabel.setPreferredSize(new java.awt.Dimension(0,
0575:                        24));
0576:                gridBagConstraints = new java.awt.GridBagConstraints();
0577:                gridBagConstraints.gridx = 0;
0578:                gridBagConstraints.gridy = 1;
0579:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0580:                gridBagConstraints.weightx = 1.0;
0581:                targetProfilePanel.add(targetProfileLabel, gridBagConstraints);
0582:
0583:                selectTargetButton.setText("...");
0584:                selectTargetButton
0585:                        .setMaximumSize(new java.awt.Dimension(22, 22));
0586:                selectTargetButton
0587:                        .setMinimumSize(new java.awt.Dimension(22, 22));
0588:                selectTargetButton.setName("selectTarget"); // NOI18N
0589:                selectTargetButton.setPreferredSize(new java.awt.Dimension(22,
0590:                        22));
0591:                gridBagConstraints = new java.awt.GridBagConstraints();
0592:                gridBagConstraints.gridx = 1;
0593:                gridBagConstraints.gridy = 1;
0594:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0595:                gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 0);
0596:                targetProfilePanel.add(selectTargetButton, gridBagConstraints);
0597:
0598:                gridBagConstraints = new java.awt.GridBagConstraints();
0599:                gridBagConstraints.gridx = 1;
0600:                gridBagConstraints.gridy = 1;
0601:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0602:                gridBagConstraints.weightx = 0.5;
0603:                gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2);
0604:                add(targetProfilePanel, gridBagConstraints);
0605:
0606:                sourceTable.setMaximumSize(new java.awt.Dimension(2147483647,
0607:                        65));
0608:                sourceTable.setMinimumSize(new java.awt.Dimension(25, 50));
0609:                sourceTable.setPreferredSize(new java.awt.Dimension(25, 50));
0610:                gridBagConstraints = new java.awt.GridBagConstraints();
0611:                gridBagConstraints.gridx = 0;
0612:                gridBagConstraints.gridy = 3;
0613:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0614:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0615:                gridBagConstraints.insets = new java.awt.Insets(5, 2, 6, 2);
0616:                add(sourceTable, gridBagConstraints);
0617:
0618:                targetTable.setToolTipText("");
0619:                targetTable.setMaximumSize(new java.awt.Dimension(2147483647,
0620:                        65));
0621:                targetTable.setMinimumSize(new java.awt.Dimension(25, 50));
0622:                targetTable.setPreferredSize(new java.awt.Dimension(25, 50));
0623:                gridBagConstraints = new java.awt.GridBagConstraints();
0624:                gridBagConstraints.gridx = 1;
0625:                gridBagConstraints.gridy = 3;
0626:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0627:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0628:                gridBagConstraints.insets = new java.awt.Insets(5, 4, 6, 2);
0629:                add(targetTable, gridBagConstraints);
0630:
0631:                targetHeader.setBackground(new java.awt.Color(255, 255, 255));
0632:                targetHeader
0633:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
0634:                targetHeader.setText("<html><b>"
0635:                        + ResourceMgr.getString("LblTargetConnection")
0636:                        + "</b></html>");
0637:                targetHeader.setMaximumSize(new java.awt.Dimension(23768, 22));
0638:                targetHeader.setMinimumSize(new java.awt.Dimension(25, 22));
0639:                targetHeader.setOpaque(true);
0640:                targetHeader.setPreferredSize(new java.awt.Dimension(25, 22));
0641:                gridBagConstraints = new java.awt.GridBagConstraints();
0642:                gridBagConstraints.gridx = 1;
0643:                gridBagConstraints.gridy = 0;
0644:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0645:                gridBagConstraints.weightx = 0.5;
0646:                gridBagConstraints.insets = new java.awt.Insets(4, 2, 4, 2);
0647:                add(targetHeader, gridBagConstraints);
0648:
0649:                sourceHeader.setBackground(new java.awt.Color(255, 255, 255));
0650:                sourceHeader
0651:                        .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
0652:                sourceHeader.setText("<html><b>"
0653:                        + ResourceMgr.getString("LblSourceConnection")
0654:                        + "</b></html>");
0655:                sourceHeader.setMaximumSize(new java.awt.Dimension(32768, 22));
0656:                sourceHeader.setMinimumSize(new java.awt.Dimension(25, 22));
0657:                sourceHeader.setOpaque(true);
0658:                sourceHeader.setPreferredSize(new java.awt.Dimension(50, 22));
0659:                gridBagConstraints = new java.awt.GridBagConstraints();
0660:                gridBagConstraints.gridx = 0;
0661:                gridBagConstraints.gridy = 0;
0662:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0663:                gridBagConstraints.weightx = 0.5;
0664:                gridBagConstraints.insets = new java.awt.Insets(4, 2, 4, 2);
0665:                add(sourceHeader, gridBagConstraints);
0666:
0667:                jSplitPane1.setDividerLocation(100);
0668:                jSplitPane1
0669:                        .setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
0670:                jSplitPane1.setTopComponent(mapperPanel);
0671:
0672:                optionsPanel.setLayout(new java.awt.GridBagLayout());
0673:
0674:                jPanel2.setLayout(new java.awt.GridBagLayout());
0675:
0676:                sqlPanel.setLayout(new java.awt.GridBagLayout());
0677:
0678:                wherePanel.setLayout(new java.awt.BorderLayout());
0679:
0680:                sqlEditorLabel.setText(ResourceMgr
0681:                        .getString("LblDPAdditionalWhere"));
0682:                wherePanel.add(sqlEditorLabel, java.awt.BorderLayout.NORTH);
0683:
0684:                gridBagConstraints = new java.awt.GridBagConstraints();
0685:                gridBagConstraints.gridx = 0;
0686:                gridBagConstraints.gridy = 0;
0687:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0688:                gridBagConstraints.gridheight = 7;
0689:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0690:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0691:                gridBagConstraints.weightx = 1.0;
0692:                gridBagConstraints.weighty = 1.0;
0693:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 4, 1);
0694:                sqlPanel.add(wherePanel, gridBagConstraints);
0695:
0696:                useQueryCbx.setText(ResourceMgr.getString("LblDPUseSQLSource"));
0697:                useQueryCbx.setToolTipText(ResourceMgr
0698:                        .getString("LblDPUseSQLSource"));
0699:                useQueryCbx
0700:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
0701:                useQueryCbx
0702:                        .setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
0703:                gridBagConstraints = new java.awt.GridBagConstraints();
0704:                gridBagConstraints.gridx = 1;
0705:                gridBagConstraints.gridy = 7;
0706:                gridBagConstraints.gridwidth = 2;
0707:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0708:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0709:                gridBagConstraints.weightx = 0.8;
0710:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 0, 2);
0711:                sqlPanel.add(useQueryCbx, gridBagConstraints);
0712:
0713:                checkQueryButton.setText(ResourceMgr
0714:                        .getString("LblDPCheckQuery"));
0715:                checkQueryButton.setToolTipText(ResourceMgr
0716:                        .getDescription("LblDPCheckQuery"));
0717:                checkQueryButton.setEnabled(false);
0718:                checkQueryButton.setMargin(new java.awt.Insets(2, 5, 2, 5));
0719:                checkQueryButton
0720:                        .setMaximumSize(new java.awt.Dimension(200, 24));
0721:                checkQueryButton
0722:                        .setMinimumSize(new java.awt.Dimension(120, 24));
0723:                checkQueryButton.setPreferredSize(new java.awt.Dimension(130,
0724:                        24));
0725:                gridBagConstraints = new java.awt.GridBagConstraints();
0726:                gridBagConstraints.gridx = 0;
0727:                gridBagConstraints.gridy = 7;
0728:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0729:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0730:                gridBagConstraints.weightx = 0.2;
0731:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0);
0732:                sqlPanel.add(checkQueryButton, gridBagConstraints);
0733:
0734:                gridBagConstraints = new java.awt.GridBagConstraints();
0735:                gridBagConstraints.gridx = 0;
0736:                gridBagConstraints.gridy = 0;
0737:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0738:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0739:                gridBagConstraints.weightx = 0.3;
0740:                gridBagConstraints.weighty = 1.0;
0741:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
0742:                jPanel2.add(sqlPanel, gridBagConstraints);
0743:
0744:                updateOptionPanel.setLayout(new java.awt.GridBagLayout());
0745:
0746:                commitLabel
0747:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
0748:                commitLabel.setText(ResourceMgr.getString("LblDPCommitEvery"));
0749:                commitLabel.setToolTipText(ResourceMgr
0750:                        .getDescription("LblDPCommitEvery"));
0751:                gridBagConstraints = new java.awt.GridBagConstraints();
0752:                gridBagConstraints.gridx = 0;
0753:                gridBagConstraints.gridy = 4;
0754:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0755:                gridBagConstraints.insets = new java.awt.Insets(2, 8, 0, 0);
0756:                updateOptionPanel.add(commitLabel, gridBagConstraints);
0757:
0758:                commitEvery.setColumns(5);
0759:                commitEvery.setText("\n");
0760:                gridBagConstraints = new java.awt.GridBagConstraints();
0761:                gridBagConstraints.gridx = 1;
0762:                gridBagConstraints.gridy = 4;
0763:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0764:                gridBagConstraints.weightx = 1.0;
0765:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
0766:                updateOptionPanel.add(commitEvery, gridBagConstraints);
0767:
0768:                continueOnErrorCbx.setText(ResourceMgr
0769:                        .getString("MsgDPContinueOnError"));
0770:                continueOnErrorCbx.setToolTipText(ResourceMgr
0771:                        .getDescription("MsgDPContinueOnError"));
0772:                continueOnErrorCbx
0773:                        .setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
0774:                gridBagConstraints = new java.awt.GridBagConstraints();
0775:                gridBagConstraints.gridx = 0;
0776:                gridBagConstraints.gridy = 2;
0777:                gridBagConstraints.gridwidth = 2;
0778:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0779:                gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
0780:                updateOptionPanel.add(continueOnErrorCbx, gridBagConstraints);
0781:
0782:                deleteTargetCbx.setText(ResourceMgr
0783:                        .getString("LblDeleteTargetTable"));
0784:                deleteTargetCbx.setToolTipText(ResourceMgr
0785:                        .getDescription("LblDeleteTargetTable"));
0786:                deleteTargetCbx
0787:                        .setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
0788:                deleteTargetCbx.setName("deleteTargetCbx"); // NOI18N
0789:                gridBagConstraints = new java.awt.GridBagConstraints();
0790:                gridBagConstraints.gridx = 0;
0791:                gridBagConstraints.gridy = 1;
0792:                gridBagConstraints.gridwidth = 2;
0793:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0794:                gridBagConstraints.insets = new java.awt.Insets(6, 5, 0, 0);
0795:                updateOptionPanel.add(deleteTargetCbx, gridBagConstraints);
0796:
0797:                dropTargetCbx.setText(ResourceMgr.getString("LblDPDropTable"));
0798:                dropTargetCbx.setToolTipText(ResourceMgr
0799:                        .getDescription("LblDPDropTable"));
0800:                dropTargetCbx.setEnabled(false);
0801:                dropTargetCbx
0802:                        .setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
0803:                gridBagConstraints = new java.awt.GridBagConstraints();
0804:                gridBagConstraints.gridx = 0;
0805:                gridBagConstraints.gridy = 3;
0806:                gridBagConstraints.gridwidth = 2;
0807:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0808:                gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
0809:                updateOptionPanel.add(dropTargetCbx, gridBagConstraints);
0810:
0811:                modeComboBox.setModel(new javax.swing.DefaultComboBoxModel(
0812:                        new String[] { "insert", "update", "insert,update",
0813:                                "update,insert" }));
0814:                modeComboBox.setName("modeSelector"); // NOI18N
0815:                modeComboBox
0816:                        .addActionListener(new java.awt.event.ActionListener() {
0817:                            public void actionPerformed(
0818:                                    java.awt.event.ActionEvent evt) {
0819:                                modeComboBoxActionPerformed(evt);
0820:                            }
0821:                        });
0822:                gridBagConstraints = new java.awt.GridBagConstraints();
0823:                gridBagConstraints.gridx = 1;
0824:                gridBagConstraints.gridy = 6;
0825:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0826:                gridBagConstraints.weightx = 0.1;
0827:                gridBagConstraints.insets = new java.awt.Insets(3, 4, 0, 0);
0828:                updateOptionPanel.add(modeComboBox, gridBagConstraints);
0829:
0830:                modeLabel.setText(ResourceMgr.getString("LblDPMode"));
0831:                gridBagConstraints = new java.awt.GridBagConstraints();
0832:                gridBagConstraints.gridx = 0;
0833:                gridBagConstraints.gridy = 6;
0834:                gridBagConstraints.gridwidth = 2;
0835:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0836:                gridBagConstraints.insets = new java.awt.Insets(2, 8, 0, 0);
0837:                updateOptionPanel.add(modeLabel, gridBagConstraints);
0838:                gridBagConstraints = new java.awt.GridBagConstraints();
0839:                gridBagConstraints.gridx = 0;
0840:                gridBagConstraints.gridy = 8;
0841:                gridBagConstraints.weighty = 1.0;
0842:                updateOptionPanel.add(jPanel1, gridBagConstraints);
0843:
0844:                jLabel1.setText(ResourceMgr.getString("LblDPUpdateOptions"));
0845:                gridBagConstraints = new java.awt.GridBagConstraints();
0846:                gridBagConstraints.gridwidth = 2;
0847:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0848:                gridBagConstraints.insets = new java.awt.Insets(0, 7, 0, 5);
0849:                updateOptionPanel.add(jLabel1, gridBagConstraints);
0850:
0851:                batchSizeLabel
0852:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
0853:                batchSizeLabel.setText(ResourceMgr.getString("LblBatchSize"));
0854:                batchSizeLabel.setToolTipText(ResourceMgr
0855:                        .getDescription("LblBatchSize"));
0856:                gridBagConstraints = new java.awt.GridBagConstraints();
0857:                gridBagConstraints.gridx = 0;
0858:                gridBagConstraints.gridy = 5;
0859:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0860:                gridBagConstraints.insets = new java.awt.Insets(2, 8, 0, 0);
0861:                updateOptionPanel.add(batchSizeLabel, gridBagConstraints);
0862:
0863:                batchSize.setColumns(5);
0864:                batchSize.setText("\n");
0865:                gridBagConstraints = new java.awt.GridBagConstraints();
0866:                gridBagConstraints.gridx = 1;
0867:                gridBagConstraints.gridy = 5;
0868:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0869:                gridBagConstraints.weightx = 1.0;
0870:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
0871:                updateOptionPanel.add(batchSize, gridBagConstraints);
0872:
0873:                gridBagConstraints = new java.awt.GridBagConstraints();
0874:                gridBagConstraints.gridx = 1;
0875:                gridBagConstraints.gridy = 0;
0876:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0877:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0878:                gridBagConstraints.weightx = 0.5;
0879:                gridBagConstraints.weighty = 1.0;
0880:                gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
0881:                jPanel2.add(updateOptionPanel, gridBagConstraints);
0882:
0883:                gridBagConstraints = new java.awt.GridBagConstraints();
0884:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0885:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0886:                gridBagConstraints.weightx = 1.0;
0887:                gridBagConstraints.weighty = 1.0;
0888:                optionsPanel.add(jPanel2, gridBagConstraints);
0889:
0890:                jSplitPane1.setRightComponent(optionsPanel);
0891:
0892:                gridBagConstraints = new java.awt.GridBagConstraints();
0893:                gridBagConstraints.gridx = 0;
0894:                gridBagConstraints.gridy = 4;
0895:                gridBagConstraints.gridwidth = 2;
0896:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0897:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
0898:                gridBagConstraints.weighty = 1.0;
0899:                gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2);
0900:                add(jSplitPane1, gridBagConstraints);
0901:
0902:                statusLabel.setBorder(javax.swing.BorderFactory
0903:                        .createCompoundBorder(javax.swing.BorderFactory
0904:                                .createEtchedBorder(),
0905:                                javax.swing.BorderFactory.createEmptyBorder(0,
0906:                                        2, 0, 0)));
0907:                statusLabel.setMaximumSize(new java.awt.Dimension(32768, 24));
0908:                statusLabel.setMinimumSize(new java.awt.Dimension(4, 24));
0909:                statusLabel.setPreferredSize(new java.awt.Dimension(4, 24));
0910:                gridBagConstraints = new java.awt.GridBagConstraints();
0911:                gridBagConstraints.gridx = 0;
0912:                gridBagConstraints.gridy = 5;
0913:                gridBagConstraints.gridwidth = 2;
0914:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0915:                gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
0916:                gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2);
0917:                add(statusLabel, gridBagConstraints);
0918:
0919:                buttonPanel.setLayout(new java.awt.GridBagLayout());
0920:
0921:                jPanel3.setLayout(new java.awt.GridBagLayout());
0922:
0923:                startButton
0924:                        .setText(ResourceMgr.getString("LblStartDataPumper"));
0925:                startButton.setEnabled(false);
0926:                startButton.setName("startButton"); // NOI18N
0927:                gridBagConstraints = new java.awt.GridBagConstraints();
0928:                gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 0);
0929:                jPanel3.add(startButton, gridBagConstraints);
0930:
0931:                cancelButton.setText(ResourceMgr.getString("LblCancelCopy"));
0932:                cancelButton.setEnabled(false);
0933:                gridBagConstraints = new java.awt.GridBagConstraints();
0934:                gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
0935:                jPanel3.add(cancelButton, gridBagConstraints);
0936:
0937:                gridBagConstraints = new java.awt.GridBagConstraints();
0938:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0939:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0940:                buttonPanel.add(jPanel3, gridBagConstraints);
0941:
0942:                jPanel4.setLayout(new java.awt.GridBagLayout());
0943:
0944:                showLogButton.setText(ResourceMgr
0945:                        .getString("LblShowDataPumperLog"));
0946:                showLogButton.setEnabled(false);
0947:                jPanel4.add(showLogButton, new java.awt.GridBagConstraints());
0948:
0949:                showWbCommand.setText(ResourceMgr.getString("LblShowScript"));
0950:                showWbCommand.setToolTipText(ResourceMgr
0951:                        .getDescription("LblShowScript"));
0952:                gridBagConstraints = new java.awt.GridBagConstraints();
0953:                gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
0954:                jPanel4.add(showWbCommand, gridBagConstraints);
0955:
0956:                gridBagConstraints = new java.awt.GridBagConstraints();
0957:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0958:                gridBagConstraints.weightx = 0.4;
0959:                buttonPanel.add(jPanel4, gridBagConstraints);
0960:
0961:                jPanel5.setLayout(new java.awt.GridBagLayout());
0962:
0963:                helpButton.setText(ResourceMgr.getString("LblHelp"));
0964:                helpButton.setToolTipText("");
0965:                gridBagConstraints = new java.awt.GridBagConstraints();
0966:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0967:                jPanel5.add(helpButton, gridBagConstraints);
0968:
0969:                closeButton.setText(ResourceMgr.getString("LblClose"));
0970:                closeButton.setName("closeButton"); // NOI18N
0971:                gridBagConstraints = new java.awt.GridBagConstraints();
0972:                gridBagConstraints.gridx = 1;
0973:                gridBagConstraints.gridy = 0;
0974:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0975:                gridBagConstraints.insets = new java.awt.Insets(0, 11, 0, 2);
0976:                jPanel5.add(closeButton, gridBagConstraints);
0977:
0978:                gridBagConstraints = new java.awt.GridBagConstraints();
0979:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
0980:                gridBagConstraints.weightx = 0.2;
0981:                buttonPanel.add(jPanel5, gridBagConstraints);
0982:
0983:                gridBagConstraints = new java.awt.GridBagConstraints();
0984:                gridBagConstraints.gridx = 0;
0985:                gridBagConstraints.gridy = 6;
0986:                gridBagConstraints.gridwidth = 2;
0987:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0988:                gridBagConstraints.weightx = 1.0;
0989:                gridBagConstraints.insets = new java.awt.Insets(9, 0, 8, 0);
0990:                add(buttonPanel, gridBagConstraints);
0991:            }// </editor-fold>//GEN-END:initComponents
0992:
0993:            private void modeComboBoxActionPerformed(
0994:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modeComboBoxActionPerformed
0995:                String mode = (String) modeComboBox.getSelectedItem();
0996:                if (mode == null)
0997:                    return;
0998:                int modevalue = DataImporter.getModeValue(mode);
0999:                if (DataImporter.isDeleteTableAllowed(modevalue)) {
1000:                    this .deleteTargetCbx.setEnabled(true);
1001:                } else {
1002:                    this .deleteTargetCbx.setSelected(false);
1003:                    this .deleteTargetCbx.setEnabled(false);
1004:                }
1005:                checkUseBatch();
1006:            }//GEN-LAST:event_modeComboBoxActionPerformed
1007:
1008:            // Variables declaration - do not modify//GEN-BEGIN:variables
1009:            protected javax.swing.JTextField batchSize;
1010:            protected javax.swing.JLabel batchSizeLabel;
1011:            protected javax.swing.JPanel buttonPanel;
1012:            protected javax.swing.JButton cancelButton;
1013:            protected javax.swing.JButton checkQueryButton;
1014:            protected javax.swing.JButton closeButton;
1015:            protected javax.swing.JTextField commitEvery;
1016:            protected javax.swing.JLabel commitLabel;
1017:            protected javax.swing.JCheckBox continueOnErrorCbx;
1018:            protected javax.swing.JCheckBox deleteTargetCbx;
1019:            protected javax.swing.JCheckBox dropTargetCbx;
1020:            protected javax.swing.JButton helpButton;
1021:            protected javax.swing.JLabel jLabel1;
1022:            protected javax.swing.JPanel jPanel1;
1023:            protected javax.swing.JPanel jPanel2;
1024:            protected javax.swing.JPanel jPanel3;
1025:            protected javax.swing.JPanel jPanel4;
1026:            protected javax.swing.JPanel jPanel5;
1027:            protected javax.swing.JSplitPane jSplitPane1;
1028:            protected javax.swing.JPanel mapperPanel;
1029:            protected javax.swing.JComboBox modeComboBox;
1030:            protected javax.swing.JLabel modeLabel;
1031:            protected javax.swing.JButton openFileButton;
1032:            protected javax.swing.JPanel optionsPanel;
1033:            protected javax.swing.JButton selectSourceButton;
1034:            protected javax.swing.JButton selectTargetButton;
1035:            protected javax.swing.JButton showLogButton;
1036:            protected javax.swing.JButton showWbCommand;
1037:            protected javax.swing.JLabel sourceHeader;
1038:            protected javax.swing.JLabel sourceProfileLabel;
1039:            protected javax.swing.JPanel sourceProfilePanel;
1040:            protected workbench.gui.tools.TableSelectorPanel sourceTable;
1041:            protected javax.swing.JLabel sqlEditorLabel;
1042:            protected javax.swing.JPanel sqlPanel;
1043:            protected javax.swing.JButton startButton;
1044:            protected javax.swing.JLabel statusLabel;
1045:            protected javax.swing.JLabel targetHeader;
1046:            protected javax.swing.JLabel targetProfileLabel;
1047:            protected javax.swing.JPanel targetProfilePanel;
1048:            protected workbench.gui.tools.TableSelectorPanel targetTable;
1049:            protected javax.swing.JPanel updateOptionPanel;
1050:            protected javax.swing.JCheckBox useQueryCbx;
1051:            protected javax.swing.JPanel wherePanel;
1052:
1053:            // End of variables declaration//GEN-END:variables
1054:
1055:            public void showWindow(MainWindow aParent) {
1056:                //		this.mainWindow = aParent;
1057:                this .window = new JFrame(ResourceMgr
1058:                        .getString("TxtWindowTitleDataPumper")) {
1059:                    public void setVisible(boolean visible) {
1060:                        if (!visible)
1061:                            saveSettings();
1062:                        super .setVisible(visible);
1063:                    }
1064:                };
1065:
1066:                this .window
1067:                        .setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
1068:                this .window.setIconImage(ResourceMgr.getImage("DataPumper")
1069:                        .getImage());
1070:                this .window.getContentPane().add(this );
1071:                this .restoreSettings();
1072:                this .window.addWindowListener(this );
1073:                WbManager.getInstance().registerToolWindow(this );
1074:
1075:                if (aParent == null) {
1076:                    if (!Settings.getInstance().restoreWindowPosition(
1077:                            this .window, "workbench.datapumper.window")) {
1078:                        WbSwingUtilities.center(this .window, null);
1079:                    }
1080:                } else {
1081:                    WbSwingUtilities.center(this .window, aParent);
1082:                }
1083:
1084:                this .window.setVisible(true);
1085:                //adjustColumnWidth();
1086:                EventQueue.invokeLater(new Runnable() {
1087:                    public void run() {
1088:                        checkConnections();
1089:                    }
1090:                });
1091:            }
1092:
1093:            private void disconnectTarget() {
1094:                if (this .targetConnection == null)
1095:                    return;
1096:
1097:                try {
1098:                    String label = ResourceMgr.getString("MsgDisconnecting");
1099:                    this .targetProfileLabel.setText(label);
1100:                    this .targetProfileLabel.setIcon(ResourceMgr
1101:                            .getPicture("wait"));
1102:
1103:                    this .targetTable.removeChangeListener();
1104:                    this .targetConnection.disconnect();
1105:                    this .targetTable.setConnection(null);
1106:                } catch (Exception e) {
1107:                    LogMgr.logError("DataPumper.disconnectTarget()",
1108:                            "Error disconnecting target connection", e);
1109:                } finally {
1110:                    this .targetConnection = null;
1111:                    this .targetProfile = null;
1112:                    this .updateTargetDisplay();
1113:                    this .targetProfileLabel.setIcon(null);
1114:                }
1115:            }
1116:
1117:            private void disconnectSource() {
1118:                if (this .sourceConnection == null)
1119:                    return;
1120:
1121:                try {
1122:                    String label = ResourceMgr.getString("MsgDisconnecting");
1123:                    this .sourceProfileLabel.setText(label);
1124:                    this .sourceProfileLabel.setIcon(ResourceMgr
1125:                            .getPicture("wait"));
1126:
1127:                    this .sourceTable.removeChangeListener();
1128:                    this .sourceConnection.disconnect();
1129:                    this .sourceTable.setConnection(null);
1130:                    this .completionAction.setConnection(null);
1131:                } catch (Exception e) {
1132:                    LogMgr.logError("DataPumper.disconnectSource()",
1133:                            "Error disconnecting source connection", e);
1134:                } finally {
1135:                    this .sourceConnection = null;
1136:                    this .sourceProfile = null;
1137:                    this .updateSourceDisplay();
1138:                    this .sourceProfileLabel.setIcon(null);
1139:                }
1140:            }
1141:
1142:            private void selectTargetConnection() {
1143:                ConnectionProfile profile = this 
1144:                        .selectConnection("workbench.datapumper.target.lastprofile");
1145:                this .connectTarget(profile);
1146:            }
1147:
1148:            private void selectSourceConnection() {
1149:                ConnectionProfile profile = this 
1150:                        .selectConnection("workbench.datapumper.source.lastprofile");
1151:                this .connectSource(profile);
1152:            }
1153:
1154:            private ConnectionProfile selectConnection(String lastProfileKey) {
1155:                ConnectionProfile prof = null;
1156:                try {
1157:                    WbSwingUtilities.showWaitCursor(this .window);
1158:                    ProfileSelectionDialog dialog = new ProfileSelectionDialog(
1159:                            this .window, true, lastProfileKey);
1160:                    WbSwingUtilities.center(dialog, this .window);
1161:                    WbSwingUtilities.showDefaultCursor(this .window);
1162:                    dialog.setVisible(true);
1163:                    prof = dialog.getSelectedProfile();
1164:                    boolean cancelled = dialog.isCancelled();
1165:                    if (!cancelled) {
1166:                        prof = dialog.getSelectedProfile();
1167:                        if (prof != null) {
1168:                            Settings.getInstance().setProperty(lastProfileKey,
1169:                                    prof.getName());
1170:                        } else {
1171:                            LogMgr.logError("DataPumper.selectConnection()",
1172:                                    "NULL Profile selected!", null);
1173:                        }
1174:                    }
1175:                    dialog.setVisible(false);
1176:                    dialog.dispose();
1177:                } catch (Throwable th) {
1178:                    LogMgr.logError("DataPumper.selectConnection()",
1179:                            "Error during connect", th);
1180:                    prof = null;
1181:                }
1182:                return prof;
1183:            }
1184:
1185:            private void checkUseBatch() {
1186:                if (this .supportsBatch) {
1187:                    String mode = (String) this .modeComboBox.getSelectedItem();
1188:                    if ("insert".equals(mode) || "update".equals(mode)) {
1189:                        this .batchSize.setEnabled(this .supportsBatch);
1190:                        return;
1191:                    }
1192:                }
1193:                this .batchSize.setEnabled(false);
1194:                this .batchSize.setText("");
1195:            }
1196:
1197:            private void showHelp() {
1198:                HelpManager.showDataPumperHelp();
1199:            }
1200:
1201:            public void actionPerformed(java.awt.event.ActionEvent e) {
1202:                if (e.getSource() == this .closeButton) {
1203:                    this .closeWindow();
1204:                } else if (e.getSource() == this .helpButton) {
1205:                    this .showHelp();
1206:                } else if (e.getSource() == this .cancelButton) {
1207:                    this .cancelCopy();
1208:                } else if (e.getSource() == this .selectTargetButton) {
1209:                    this .selectTargetConnection();
1210:                } else if (e.getSource() == this .openFileButton) {
1211:                    this .selectInputFile();
1212:                } else if (e.getSource() == this .selectSourceButton) {
1213:                    this .selectSourceConnection();
1214:                } else if (e.getSource() == this .showWbCommand) {
1215:                    this .showCopyCommand();
1216:                } else if (e.getSource() == this .startButton) {
1217:                    if (this .copyRunning) {
1218:                        this .cancelCopy();
1219:                    } else if (this .columnMapper != null) {
1220:                        this .startCopy();
1221:                    }
1222:                } else if (e.getSource() == this .useQueryCbx) {
1223:                    this .resetColumnMapper();
1224:                    this .checkType();
1225:                } else if (e.getSource() == this .checkQueryButton) {
1226:                    this .initColumnMapper();
1227:                } else if (e.getSource() == this .showLogButton) {
1228:                    this .showLog();
1229:                }
1230:            }
1231:
1232:            /**
1233:             *	Check the controls depending on the state of the useQuery CheckBox
1234:             */
1235:            private void checkType() {
1236:                boolean useQuery = this .useQueryCbx.isSelected();
1237:                boolean allowSource = (!useQuery && this .fileImporter == null);
1238:
1239:                this .sourceTable.setEnabled(allowSource);
1240:
1241:                boolean isCopy = (this .fileImporter == null);
1242:                this .sqlEditor.setEnabled(isCopy);
1243:                this .checkQueryButton.setEnabled(isCopy && useQuery);
1244:                this .targetTable.allowNewTable(isCopy);
1245:
1246:                this .useQueryCbx.setVisible(isCopy);
1247:                this .useQueryCbx.setEnabled(isCopy);
1248:                this .sqlEditor.setVisible(isCopy);
1249:                this .checkQueryButton.setVisible(isCopy);
1250:                this .sqlEditorLabel.setVisible(isCopy);
1251:
1252:                if (useQuery) {
1253:                    this .sqlEditorLabel.setText(ResourceMgr
1254:                            .getString("LblDPQueryText"));
1255:                } else {
1256:                    this .sqlEditorLabel.setText(ResourceMgr
1257:                            .getString("LblDPAdditionalWhere"));
1258:                }
1259:                if (!useQuery) {
1260:                    if (this .isSelectQuery()) {
1261:                        String msg = ResourceMgr.getString("MsgDPRemoveQuery");
1262:                        if (WbSwingUtilities.getYesNo(this , msg)) {
1263:                            this .sqlEditor.setText("");
1264:                        }
1265:                    }
1266:                }
1267:            }
1268:
1269:            private boolean isSelectQuery() {
1270:                String sql = this .sqlEditor.getText();
1271:                if (sql != null && sql.trim().length() > 0) {
1272:                    sql = SqlUtil.makeCleanSql(sql, false).toLowerCase();
1273:                    return sql.startsWith("select");
1274:                }
1275:                return false;
1276:            }
1277:
1278:            public void windowActivated(java.awt.event.WindowEvent e) {
1279:            }
1280:
1281:            public void windowClosed(java.awt.event.WindowEvent e) {
1282:            }
1283:
1284:            public void windowClosing(java.awt.event.WindowEvent e) {
1285:                if (this .copyRunning) {
1286:                    this .cancelCopy();
1287:                }
1288:                this .closeWindow();
1289:            }
1290:
1291:            public void closeWindow() {
1292:                this .done();
1293:                if (this .window != null) {
1294:                    this .window.removeWindowListener(this );
1295:                    this .window.dispose();
1296:                }
1297:            }
1298:
1299:            public void disconnect() {
1300:                this .disconnectSource();
1301:                this .disconnectTarget();
1302:            }
1303:
1304:            public void done() {
1305:                this .saveSettings();
1306:
1307:                this .sourceProfile = null;
1308:                this .targetProfile = null;
1309:                this .columnMapper.resetData();
1310:                this .columnMapper = null;
1311:
1312:                Thread t = new WbThread("DataPumper disconnect thread") {
1313:                    public void run() {
1314:                        disconnect();
1315:                        unregister();
1316:                    }
1317:                };
1318:                t.start();
1319:            }
1320:
1321:            protected void unregister() {
1322:                WbManager.getInstance().unregisterToolWindow(this );
1323:            }
1324:
1325:            public void windowDeactivated(java.awt.event.WindowEvent e) {
1326:            }
1327:
1328:            public void windowDeiconified(java.awt.event.WindowEvent e) {
1329:            }
1330:
1331:            public void windowIconified(java.awt.event.WindowEvent e) {
1332:            }
1333:
1334:            public void windowOpened(java.awt.event.WindowEvent e) {
1335:            }
1336:
1337:            /**
1338:             *	We have registered with both table selectors to be informed
1339:             *	when the user changes the selection. After each change (and
1340:             *	we don't actually care where it came from) the tables are
1341:             *	checked, and if both are present, we'll initialize the
1342:             *	ColumnMapper
1343:             */
1344:            public void propertyChange(java.beans.PropertyChangeEvent evt) {
1345:                TableIdentifier theTarget = this .targetTable.getSelectedTable();
1346:                TableIdentifier source = this .sourceTable.getSelectedTable();
1347:
1348:                if (evt.getSource() == this .sourceTable && source != null) {
1349:                    if (theTarget != null && theTarget.isNewTable()) {
1350:                        this .targetTable.resetNewTableItem();
1351:                        theTarget = null;
1352:                    }
1353:                    if (theTarget == null) {
1354:                        this .targetTable.findAndSelectTable(source
1355:                                .getTableName());
1356:                    }
1357:                } else if (evt.getSource() == this .targetTable
1358:                        && theTarget != null && source == null) {
1359:                    this .sourceTable.findAndSelectTable(theTarget
1360:                            .getTableName());
1361:                }
1362:
1363:                if (theTarget != null && theTarget.isNewTable()) {
1364:                    String name = theTarget.getTableName();
1365:                    if (name == null) {
1366:                        String def = null;
1367:                        if (source != null) {
1368:                            def = source.getTableName();
1369:                        }
1370:                        name = WbSwingUtilities.getUserInput(this , ResourceMgr
1371:                                .getString("TxtEnterNewTableName"), def);
1372:                        if (name != null) {
1373:                            theTarget.setTable(name);
1374:                            this .targetTable.repaint();
1375:                        }
1376:                    }
1377:                }
1378:
1379:                if (this .hasSource() && theTarget != null) {
1380:                    EventQueue.invokeLater(new Runnable() {
1381:                        public void run() {
1382:                            initColumnMapper();
1383:                        }
1384:                    });
1385:                } else {
1386:                    this .startButton.setEnabled(false);
1387:                    this .showWbCommand.setEnabled(false);
1388:                    this .columnMapper.resetData();
1389:                    this .dropTargetCbx.setEnabled(false);
1390:                }
1391:            }
1392:
1393:            public boolean hasSource() {
1394:                if (this .useQueryCbx.isSelected()) {
1395:                    return (this .sqlEditor.getText().length() > 0);
1396:                } else if (this .fileImporter != null) {
1397:                    return true;
1398:                } else {
1399:                    return (this .sourceTable.getSelectedTable() != null);
1400:                }
1401:            }
1402:
1403:            private List<ColumnIdentifier> getResultSetColumns() {
1404:                if (this .sourceConnection == null)
1405:                    return null;
1406:                String sql = this .sqlEditor.getText();
1407:
1408:                List<ColumnIdentifier> result = null;
1409:
1410:                try {
1411:                    result = SqlUtil.getResultSetColumns(sql,
1412:                            this .sourceConnection);
1413:                } catch (SQLException e) {
1414:                    LogMgr
1415:                            .logError(
1416:                                    "DataPumper",
1417:                                    "Error when retrieving ResultSet definition for source SQL",
1418:                                    e);
1419:                    WbSwingUtilities.showErrorMessage(this , e.getMessage());
1420:                }
1421:                return result;
1422:            }
1423:
1424:            private void resetColumnMapper() {
1425:                this .columnMapper.resetData();
1426:            }
1427:
1428:            private List<ColumnIdentifier> getKeyColumns() {
1429:                ColumnMapper.MappingDefinition colMapping = this .columnMapper
1430:                        .getMapping();
1431:                if (colMapping == null)
1432:                    return Collections.emptyList();
1433:                int count = colMapping.targetColumns.length;
1434:                List<ColumnIdentifier> keys = new ArrayList<ColumnIdentifier>();
1435:
1436:                for (int i = 0; i < count; i++) {
1437:                    if (colMapping.targetColumns[i].isPkColumn()) {
1438:                        keys.add(colMapping.targetColumns[i]);
1439:                    }
1440:                }
1441:                return keys;
1442:            }
1443:
1444:            private void showImportCommand() {
1445:                if (this .fileImporter == null || this .targetProfile == null)
1446:                    return;
1447:                String sql = null;
1448:                try {
1449:                    this .initImporter();
1450:                    sql = this .fileImporter.getWbCommand();
1451:                } catch (Exception e) {
1452:                    LogMgr.logError("DataPumper.showImportCommand()",
1453:                            "Error creating SQL command", e);
1454:                    sql = ExceptionUtil.getDisplay(e);
1455:                }
1456:                EditWindow w = new EditWindow(this .window, ResourceMgr
1457:                        .getString("MsgWindowTitleDPScript"), sql,
1458:                        "workbench.datapumper.scriptwindow", true);
1459:                w.setVisible(true);
1460:                w.dispose();
1461:            }
1462:
1463:            private void showCopyCommand() {
1464:                if (this .fileImporter != null) {
1465:                    this .showImportCommand();
1466:                    return;
1467:                }
1468:                if (this .sourceProfile == null || this .targetProfile == null)
1469:                    return;
1470:                if (!this .hasSource())
1471:                    return;
1472:
1473:                CommandTester t = new CommandTester();
1474:
1475:                StringBuilder result = new StringBuilder(150);
1476:                result.append(t.formatVerb(WbCopy.VERB) + " -"
1477:                        + WbCopy.PARAM_SOURCEPROFILE + "=");
1478:                String indent = "\n      ";
1479:
1480:                String s = this .sourceProfile.getName();
1481:                if (s.indexOf(' ') > -1)
1482:                    result.append('\'');
1483:                result.append(s);
1484:                if (s.indexOf(' ') > -1)
1485:                    result.append('\'');
1486:
1487:                result.append(indent);
1488:                result.append("-" + WbCopy.PARAM_SOURCEPROFILE_GROUP + "=");
1489:                s = this .sourceProfile.getGroup();
1490:                if (s.indexOf(' ') > -1)
1491:                    result.append('\'');
1492:                result.append(s);
1493:                if (s.indexOf(' ') > -1)
1494:                    result.append('\'');
1495:
1496:                s = this .targetProfile.getName();
1497:                result.append(indent);
1498:                result.append("-" + WbCopy.PARAM_TARGETPROFILE + "=");
1499:                if (s.indexOf(' ') > -1)
1500:                    result.append('\'');
1501:                result.append(s);
1502:                if (s.indexOf(' ') > -1)
1503:                    result.append('\'');
1504:
1505:                result.append(indent);
1506:                result.append("-" + WbCopy.PARAM_TARGETPROFILE_GROUP + "=");
1507:                s = this .targetProfile.getGroup();
1508:                if (s.indexOf(' ') > -1)
1509:                    result.append('\'');
1510:                result.append(s);
1511:                if (s.indexOf(' ') > -1)
1512:                    result.append('\'');
1513:
1514:                TableIdentifier id = this .targetTable.getSelectedTable();
1515:                if (targetProfile == null)
1516:                    return;
1517:
1518:                if (id.isNewTable())
1519:                    s = id.getTableName();
1520:                else
1521:                    s = id.getTableExpression();
1522:                result.append(indent);
1523:                result.append("-" + WbCopy.PARAM_TARGETTABLE + "=");
1524:                result.append(s);
1525:
1526:                if (id.isNewTable()) {
1527:                    result.append(indent);
1528:                    result.append("-" + WbCopy.PARAM_CREATETARGET + "=true");
1529:                    if (this .dropTargetCbx.isSelected()) {
1530:                        result.append(indent);
1531:                        result.append("-" + WbCopy.PARAM_DROPTARGET + "=true");
1532:                    }
1533:                }
1534:
1535:                ColumnMapper.MappingDefinition colMapping = this .columnMapper
1536:                        .getMapping();
1537:                if (colMapping == null)
1538:                    return;
1539:                int count = colMapping.targetColumns.length;
1540:
1541:                if (this .useQueryCbx.isSelected()) {
1542:                    String sql = this .sqlEditor.getText();
1543:                    result.append(indent);
1544:                    result.append("-" + WbCopy.PARAM_SOURCEQUERY + "=\"");
1545:                    result.append(sql);
1546:                    result.append('"');
1547:
1548:                    result.append(indent);
1549:                    result.append("-" + WbCopy.PARAM_COLUMNS + "=\"");
1550:                    for (int i = 0; i < count; i++) {
1551:                        if (i > 0)
1552:                            result.append(", ");
1553:                        result.append(colMapping.targetColumns[i]
1554:                                .getColumnName());
1555:                    }
1556:                    result.append('"');
1557:                } else {
1558:                    id = this .sourceTable.getSelectedTable();
1559:                    if (id == null)
1560:                        return;
1561:                    s = id.getTableExpression();
1562:                    result.append(indent);
1563:                    result.append("-" + WbCopy.PARAM_SOURCETABLE + "=");
1564:                    if (s.indexOf(' ') > -1)
1565:                        result.append('"');
1566:                    result.append(s);
1567:                    if (s.indexOf(' ') > -1)
1568:                        result.append('"');
1569:
1570:                    s = sqlEditor.getText();
1571:                    if (s != null && s.trim().length() > 0) {
1572:                        result.append(indent);
1573:                        result.append("-" + WbCopy.PARAM_SOURCEWHERE + "=\"");
1574:                        result.append(s);
1575:                        result.append('"');
1576:                    }
1577:
1578:                    result.append(indent);
1579:                    result.append("-" + WbCopy.PARAM_COLUMNS + "=\"");
1580:                    for (int i = 0; i < count; i++) {
1581:                        if (i > 0)
1582:                            result.append(", ");
1583:                        result.append(colMapping.sourceColumns[i]
1584:                                .getColumnName());
1585:                        result.append('/');
1586:                        ColumnIdentifier col = colMapping.targetColumns[i];
1587:                        result.append(col.getColumnName());
1588:                    }
1589:                    result.append('"');
1590:                }
1591:
1592:                String mode = (String) this .modeComboBox.getSelectedItem();
1593:                if (!"insert".equals(mode)) {
1594:                    result.append(indent);
1595:                    result
1596:                            .append("-" + CommonArgs.ARG_IMPORT_MODE + "="
1597:                                    + mode);
1598:                    Collection<ColumnIdentifier> keys = this .getKeyColumns();
1599:                    if (keys.size() > 0) {
1600:                        Iterator<ColumnIdentifier> itr = keys.iterator();
1601:                        result.append("\n      -" + WbCopy.PARAM_KEYS + "=");
1602:                        while (itr.hasNext()) {
1603:                            ColumnIdentifier col = itr.next();
1604:                            result.append(col.getColumnName());
1605:                            if (itr.hasNext())
1606:                                result.append(',');
1607:                        }
1608:                    }
1609:                }
1610:
1611:                result.append(indent);
1612:                result.append("-" + WbCopy.PARAM_DELETETARGET + "=");
1613:                result.append(Boolean.toString(this .deleteTargetCbx
1614:                        .isSelected()));
1615:
1616:                result.append(indent);
1617:                result.append("-" + CommonArgs.ARG_CONTINUE + "=");
1618:                result.append(Boolean.toString(this .continueOnErrorCbx
1619:                        .isSelected()));
1620:
1621:                int size = getBatchSize();
1622:                if (size > 0) {
1623:                    result.append(indent);
1624:                    result.append("-" + CommonArgs.ARG_BATCHSIZE + "="
1625:                            + batchSize);
1626:                }
1627:
1628:                if (size <= 0) {
1629:                    int commit = StringUtil.getIntValue(this .commitEvery
1630:                            .getText(), -1);
1631:                    if (commit > 0) {
1632:                        result.append(indent);
1633:                        result.append("-" + CommonArgs.ARG_COMMIT + "=");
1634:                        result.append(commit);
1635:                    }
1636:                }
1637:
1638:                result.append("\n;");
1639:
1640:                EditWindow w = new EditWindow(this .window, ResourceMgr
1641:                        .getString("MsgWindowTitleDPScript"),
1642:                        result.toString(), "workbench.datapumper.scriptwindow",
1643:                        true);
1644:                w.setVisible(true);
1645:                w.dispose();
1646:            }
1647:
1648:            protected int getBatchSize() {
1649:                int size = -1;
1650:                if (this .batchSize.isEnabled()) {
1651:                    size = StringUtil.getIntValue(batchSize.getText(), -1);
1652:                }
1653:                return size;
1654:            }
1655:
1656:            protected void initColumnMapper() {
1657:                if ((this .sourceConnection == null && this .fileImporter == null)
1658:                        || this .targetConnection == null || !this .hasSource()) {
1659:                    this .startButton.setEnabled(false);
1660:                    this .showWbCommand.setEnabled(false);
1661:                    return;
1662:                }
1663:
1664:                TableIdentifier target = this .targetTable.getSelectedTable();
1665:                if (target == null) {
1666:                    this .startButton.setEnabled(false);
1667:                    this .showWbCommand.setEnabled(false);
1668:                    return;
1669:                }
1670:
1671:                boolean useQuery = this .useQueryCbx.isSelected();
1672:                try {
1673:                    List<ColumnIdentifier> sourceCols = null;
1674:                    if (useQuery) {
1675:                        sourceCols = this .getResultSetColumns();
1676:                    } else if (this .fileImporter != null) {
1677:                        sourceCols = this .fileImporter.getFileColumns();
1678:                    } else {
1679:                        TableIdentifier source = this .sourceTable
1680:                                .getSelectedTable();
1681:                        sourceCols = this .sourceConnection.getMetadata()
1682:                                .getTableColumns(source);
1683:                    }
1684:
1685:                    boolean newTable = target.isNewTable();
1686:                    this .columnMapper.setAllowTargetEditing(newTable);
1687:                    this .dropTargetCbx.setEnabled(newTable);
1688:                    if (newTable) {
1689:                        this .columnMapper.defineColumns(sourceCols, sourceCols,
1690:                                false);
1691:                    } else {
1692:                        List<ColumnIdentifier> targetCols = this .targetConnection
1693:                                .getMetadata().getTableColumns(target);
1694:                        boolean syncDataTypes = (this .fileImporter != null);
1695:                        this .columnMapper.defineColumns(sourceCols, targetCols,
1696:                                syncDataTypes);
1697:                    }
1698:
1699:                    this .columnMapper.setAllowSourceEditing(!useQuery
1700:                            && !newTable);
1701:                    this .startButton.setEnabled(true);
1702:                    this .showWbCommand.setEnabled(true);
1703:                } catch (Exception e) {
1704:                    LogMgr.logError("DataPumper.initColumnMapper()",
1705:                            "Error when intializing column mapper", e);
1706:                }
1707:            }
1708:
1709:            private void cancelCopy() {
1710:                this .statusLabel.setText(ResourceMgr
1711:                        .getString("MsgCancellingCopy"));
1712:                this .statusLabel.repaint();
1713:                cancelButton.setEnabled(false);
1714:                WbThread t = new WbThread("DataPumper cancel") {
1715:                    public void run() {
1716:                        doCancel();
1717:                    }
1718:                };
1719:                t.start();
1720:            }
1721:
1722:            protected void doCancel() {
1723:                if (copier != null)
1724:                    copier.cancel();
1725:                EventQueue.invokeLater(new Runnable() {
1726:                    public void run() {
1727:                        cancelButton.setEnabled(false);
1728:                        startButton.setEnabled(true);
1729:                        copyRunning = false;
1730:                        updateWindowTitle();
1731:                        statusLabel.setText(ResourceMgr
1732:                                .getString("MsgCopyCancelled"));
1733:                        statusLabel.repaint();
1734:                    }
1735:                });
1736:            }
1737:
1738:            private void initImporter() throws Exception {
1739:                this .fileImporter.setConnection(this .targetConnection);
1740:                List<ColumnIdentifier> cols = columnMapper
1741:                        .getMappingForImport();
1742:                this .fileImporter.setTargetTable(this .targetTable
1743:                        .getSelectedTable());
1744:                this .fileImporter.setImportColumns(cols);
1745:                this .fileImporter.setBatchSize(this .getBatchSize());
1746:            }
1747:
1748:            private void startCopy() {
1749:                if (this .targetConnection == null
1750:                        || (this .sourceConnection == null && this .fileImporter == null))
1751:                    return;
1752:
1753:                if (this .columnMapper == null)
1754:                    return;
1755:
1756:                TableIdentifier ttable = this .targetTable.getSelectedTable();
1757:
1758:                ColumnMapper.MappingDefinition colMapping = this .columnMapper
1759:                        .getMapping();
1760:
1761:                if (!this .createCopier())
1762:                    return;
1763:
1764:                try {
1765:                    this .copyRunning = true;
1766:
1767:                    if (this .fileImporter != null) {
1768:                        this .initImporter();
1769:                        this .copier.setProducer(
1770:                                this .fileImporter.getProducer(),
1771:                                this .targetConnection, this .targetTable
1772:                                        .getSelectedTable());
1773:                        int interval = DataImporter
1774:                                .estimateReportIntervalFromFileSize(this .fileImporter
1775:                                        .getSourceFile());
1776:                        this .copier.setReportInterval(interval);
1777:                    } else if (this .useQueryCbx.isSelected()) {
1778:                        this .copier.copyFromQuery(this .sourceConnection,
1779:                                this .targetConnection,
1780:                                this .sqlEditor.getText(), ttable,
1781:                                colMapping.targetColumns, ttable.isNewTable(),
1782:                                dropTargetCbx.isSelected());
1783:                    } else {
1784:                        boolean ignoreSelect = false;
1785:                        String where = null;
1786:                        TableIdentifier stable = this .sourceTable
1787:                                .getSelectedTable();
1788:                        if (this .isSelectQuery()) {
1789:                            WbSwingUtilities.showErrorMessageKey(this ,
1790:                                    "MsgDPIgnoreSelect");
1791:                            ignoreSelect = true;
1792:                        }
1793:                        if (!ignoreSelect)
1794:                            where = this .sqlEditor.getText();
1795:
1796:                        boolean createTable = ttable.isNewTable();
1797:                        boolean dropTable = this .dropTargetCbx.isSelected();
1798:                        Map<String, String> mapping = new HashMap<String, String>();
1799:                        int count = colMapping.sourceColumns.length;
1800:                        for (int i = 0; i < count; i++) {
1801:                            mapping
1802:                                    .put(colMapping.sourceColumns[i]
1803:                                            .getColumnName(),
1804:                                            colMapping.targetColumns[i]
1805:                                                    .getColumnName());
1806:                        }
1807:                        this .copier.copyFromTable(this .sourceConnection,
1808:                                this .targetConnection, stable, ttable, mapping,
1809:                                where, createTable, dropTable);
1810:                    }
1811:
1812:                    this .copier.startBackgroundCopy();
1813:                    this .showLogButton.setEnabled(false);
1814:                    this .startButton.setEnabled(false);
1815:                    this .cancelButton.setEnabled(true);
1816:
1817:                    this .updateWindowTitle();
1818:                } catch (Exception e) {
1819:                    this .copyRunning = false;
1820:                    this .showLogButton.setEnabled(true);
1821:                    this .startButton.setEnabled(true);
1822:                    this .cancelButton.setEnabled(false);
1823:                    LogMgr.logError("DataPumper.startCopy()",
1824:                            "Could not execute copy process", e);
1825:                    this .statusLabel.setText(ResourceMgr
1826:                            .getString("MsgCopyFinishedWithErrors"));
1827:                }
1828:            }
1829:
1830:            public boolean isRunning() {
1831:                return this .copyRunning;
1832:            }
1833:
1834:            private boolean createCopier() {
1835:                ColumnMapper.MappingDefinition colMapping = this .columnMapper
1836:                        .getMapping();
1837:                if (colMapping == null)
1838:                    return false;
1839:
1840:                this .copier = new DataCopier();
1841:                this .copier.setDeleteTarget(this .deleteTargetCbx.isSelected());
1842:                this .copier.setContinueOnError(this .continueOnErrorCbx
1843:                        .isSelected());
1844:                String mode = (String) this .modeComboBox.getSelectedItem();
1845:                List<ColumnIdentifier> keys = this .getKeyColumns();
1846:
1847:                this .copier.setKeyColumns(keys);
1848:
1849:                if (mode.indexOf("update") > -1 && keys.size() == 0) {
1850:                    WbSwingUtilities.showErrorMessageKey(this ,
1851:                            "ErrDPNoKeyColumns");
1852:                    return false;
1853:                }
1854:
1855:                if (keys.size() == colMapping.targetColumns.length
1856:                        && mode.indexOf("update") > -1) {
1857:                    WbSwingUtilities.showErrorMessageKey(this ,
1858:                            "ErrDPUpdateOnlyKeyColumns");
1859:                    return false;
1860:                }
1861:
1862:                this .copier.setMode(mode);
1863:                int bSize = getBatchSize();
1864:                int commit = StringUtil.getIntValue(this .commitEvery.getText(),
1865:                        -1);
1866:                if (bSize <= 0)
1867:                    this .copier.setCommitEvery(commit);
1868:
1869:                if (bSize > 0) {
1870:                    this .copier.setUseBatch(true);
1871:                    this .copier.setBatchSize(bSize);
1872:                    if (commit > 0)
1873:                        this .copier.setCommitBatch(true);
1874:                }
1875:
1876:                this .copier.setRowActionMonitor(this );
1877:                this .copier.setReportInterval(10);
1878:                return true;
1879:            }
1880:
1881:            public void setCurrentObject(String object, long currentRow,
1882:                    long total) {
1883:                updateMonitor(currentRow);
1884:            }
1885:
1886:            public void setCurrentRow(long currentRow, long totalRows) {
1887:                updateMonitor(currentRow);
1888:            }
1889:
1890:            private void updateMonitor(final long currentRow) {
1891:                EventQueue.invokeLater(new Runnable() {
1892:                    public void run() {
1893:                        if (currentRow == 1)
1894:                            updateWindowTitle();
1895:                        statusLabel.setText(copyMsg + " " + currentRow);
1896:                        statusLabel.repaint();
1897:                    }
1898:                });
1899:            }
1900:
1901:            public void saveCurrentType(String type) {
1902:            }
1903:
1904:            public void restoreType(String type) {
1905:            }
1906:
1907:            public int getMonitorType() {
1908:                return RowActionMonitor.MONITOR_PLAIN;
1909:            }
1910:
1911:            public void setMonitorType(int aType) {
1912:            }
1913:
1914:            public void jobFinished() {
1915:                this .copyRunning = false;
1916:                if (this .copier.isSuccess()) {
1917:
1918:                    String msg = this .copier.getRowsInsertedMessage();
1919:                    String msg2 = this .copier.getRowsUpdatedMessage();
1920:                    StringBuilder copied = new StringBuilder(50);
1921:                    if (msg != null) {
1922:                        copied.append(msg);
1923:                        if (msg2 != null)
1924:                            copied.append(", " + msg2);
1925:                    } else if (msg2 != null && msg2.length() > 0) {
1926:                        copied.append(msg2);
1927:                    } else {
1928:                        long rows = this .copier.getAffectedRows();
1929:                        copied.append(rows);
1930:                        copied.append(' ');
1931:                        copied.append(ResourceMgr.getString("MsgCopyNumRows"));
1932:                    }
1933:
1934:                    if (copied.length() > 0) {
1935:                        copied.insert(0, " - ");
1936:                    }
1937:
1938:                    if (this .copier.hasWarnings()) {
1939:                        this .statusLabel.setText(ResourceMgr
1940:                                .getString("MsgCopyFinishedWithWarning")
1941:                                + copied);
1942:                    } else {
1943:                        this .statusLabel.setText(ResourceMgr
1944:                                .getString("MsgCopyFinishedWithSuccess")
1945:                                + copied);
1946:                    }
1947:                } else {
1948:                    this .statusLabel.setText(ResourceMgr
1949:                            .getString("MsgCopyFinishedWithErrors"));
1950:                }
1951:
1952:                this .startButton.setEnabled(true);
1953:                this .cancelButton.setEnabled(false);
1954:
1955:                if (this .copier.hasWarnings() || !this .copier.isSuccess()) {
1956:                    this .showLogButton.setEnabled(true);
1957:                }
1958:
1959:                this .updateWindowTitle();
1960:
1961:                if (!this .copier.isSuccess()) {
1962:                    EventQueue.invokeLater(new Runnable() {
1963:                        public void run() {
1964:                            showLog();
1965:                        }
1966:                    });
1967:                }
1968:            }
1969:
1970:            protected void showLog() {
1971:                if (this .copier == null) {
1972:                    return;
1973:                }
1974:
1975:                CharSequence log = null;
1976:                try {
1977:                    log = this .copier.getAllMessages();
1978:                } catch (Exception e) {
1979:                    LogMgr.logError("DataPumper.showLog()",
1980:                            "Error when retrieving log information", e);
1981:                    log = ExceptionUtil.getDisplay(e);
1982:                }
1983:
1984:                EditWindow w = new EditWindow(this .window, ResourceMgr
1985:                        .getString("MsgWindowTitleDPLog"), (log == null ? ""
1986:                        : log.toString()), "workbench.datapumper.logwindow");
1987:
1988:                w.setVisible(true); // EditWindow is modal
1989:                w.dispose();
1990:            }
1991:
1992:            /*
1993:             * Implementation of the StatusBar interface
1994:             */
1995:            public void setStatusMessage(String message) {
1996:                this .statusLabel.setText(message);
1997:            }
1998:
1999:            public void clearStatusMessage() {
2000:                this .statusLabel.setText("");
2001:            }
2002:
2003:            public String getText() {
2004:                return this.statusLabel.getText();
2005:            }
2006:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.