📄 importexportdelimitedpanel.java
字号:
/* * ImportExportDelimitedPanel.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */package org.executequery.gui.importexport;import java.awt.Dimension;import java.util.Vector;import javax.swing.JDialog;import javax.swing.JPanel;import org.executequery.ActiveComponent;import org.executequery.GUIUtilities;import org.underworldlabs.swing.actions.ActionBuilder;import org.underworldlabs.swing.wizard.DefaultWizardProcessModel;import org.underworldlabs.swing.wizard.WizardProcessPanel;import org.executequery.databasemediators.DatabaseConnection;import org.executequery.databasemediators.MetaDataValues;import org.executequery.gui.*;import org.executequery.gui.browser.ColumnData;import org.executequery.util.Log;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the * release of version 3.0.0beta1 has meant a * resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * Import export to delimited file parent object. * * @author Takis Diakoumis * @version $Revision: 1.8 $ * @date $Date: 2006/09/13 15:15:09 $ */public class ImportExportDelimitedPanel extends WizardProcessPanel implements ImportExportProcess, ActiveComponent { /** The type of transfer - import/export */ private int transferType; /** The dimension of each child panel */ private Dimension childDim; /** The object to retrieve table details */ private MetaDataValues metaData; /** The worker that will run the process */ private ImportExportWorker worker; /** The first panel displayed */ private ImportExportDelimitedPanel_1 firstPanel; /** The second panel displayed */ private ImportExportPanel_2 secondPanel; /** The third panel displayed */ private ImportExportPanel_3 thirdPanel; /** The fourth panel displayed */ private ImportExportDelimitedPanel_4 fourthPanel; /** The progress panel to track the process */ private ImportExportProgressPanel progressPanel; /** Whether the process has been cancelled */ private boolean processCancelled; /** Whether the process was a success */ private boolean processing; /** the parent container */ private ActionContainer parent; /** the selection model */ private TransferDelimitedWizardModel model; /** * Creates a new instance of the process with the specified parent * container and process type. * * @param the process type - import/export */ public ImportExportDelimitedPanel(ActionContainer parent, int transferType) { this(parent, transferType, null, null, null); } /** * Creates a new instance of the process with the specified parent * container and process type. * * @param the process type - import/export */ public ImportExportDelimitedPanel(ActionContainer parent, int transferType, DatabaseConnection databaseConnection, String schemaName, String tableName) { this.transferType = transferType; model = new TransferDelimitedWizardModel(); setModel(model); this.parent = parent; try { jbInit(); } catch(Exception e) { e.printStackTrace(); } if (databaseConnection != null) { firstPanel.setDatabaseConnection(databaseConnection); next(); if (schemaName != null) { secondPanel.setSelectedSchema(schemaName); if (tableName != null) { secondPanel.setSelectedTable(tableName); secondPanel.selectAllAvailable(); } } } } /** <p>Initialises the state of this instance and * lays out components on the panel. */ private void jbInit() throws Exception { processCancelled = false; metaData = new MetaDataValues(true); childDim = new Dimension(525, 340); // set the help action setHelpAction(ActionBuilder.get("help-command"), "import-export"); firstPanel = new ImportExportDelimitedPanel_1(this); model.addPanel(firstPanel); prepare(); } /** * Returns the transfer format - XML, CSV etc. */ public int getTransferFormat() { return DELIMITED; } /** * Releases database resources before closing. */ public void cleanup() { metaData.closeConnection(); } public String getSchemaName() { return secondPanel.getSelectedSchema(); } /** <p>Retrieves the selected tables for this process. * * @return the selected table names */ public String[] getSelectedTables() { return secondPanel.getSelectedTables(); } /** <p>Retrieves the table name for this process in the * case of a single table import/export. * * @return the table name */ public String getTableName() { return secondPanel.getSelectedTables()[0]; } /** <p>Retrieves the column names for this process. * * @return the column names */ public Vector<ColumnData> getSelectedColumns() { return secondPanel.getSelectedColumns(); } /** <p>Retrieves the selected rollback size for * the transfer. * * @return the rollback size */ public int getRollbackSize() { return fourthPanel.getRollbackSize(); } public boolean includeColumnNames() { return fourthPanel.includeColumnNames(); } /** <p>Retrieves the action on an error occuring * during the import/export process. * * @return the action on error -<br>either: * <code>ImportExportProcess.LOG_AND_CONTINUE</code> or * <code>ImportExportProcess.STOP_TRANSFER</code> */ public int getOnError() { return fourthPanel.getOnError(); } /** * Retrieves the selected type of delimiter within * the file to be used with this process. * * @return the selected delimiter */ public char getDelimiter() { return fourthPanel.getDelimiter(); } /** <p>Retrieves the date format for date fields * contained within the data file/database table. * * @return the date format (ie. ddMMyyy) */ public String getDateFormat() { String format = fourthPanel.getDateFormat(); if (format == null || format.length() == 0) { return null; } else { return format; } } /** * Returns whether to parse date values. * * @return true | false */ public boolean parseDateValues() { return fourthPanel.parseDateValues(); } /** * Indicates whether the process (import only) should * be run as a batch process. * * @return whether to run as a batch process */ public boolean runAsBatchProcess() { return fourthPanel.runAsBatchProcess(); } public boolean trimWhitespace() { return fourthPanel.trimWhitespace(); } /** <p>Begins an import process. */ public void doImport() { Log.info("Beginning data import process"); processCancelled = false; setNextButtonEnabled(false); setBackButtonEnabled(false); setCancelButtonEnabled(false); worker = new ImportDelimitedWorker(this, progressPanel);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -