⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 importexportpanel_3.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * ImportExportPanel_3.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.Component;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.util.Vector;import javax.swing.DefaultCellEditor;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JFileChooser;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.ListSelectionModel;import javax.swing.table.AbstractTableModel;import javax.swing.table.TableCellRenderer;import javax.swing.table.TableColumn;import javax.swing.table.TableColumnModel;import org.executequery.GUIUtilities;import org.executequery.components.FileChooserDialog;import org.executequery.gui.DefaultTable;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * * @author   Takis Diakoumis * @version  $Revision: 1.5 $ * @date     $Date: 2006/08/11 12:36:06 $ */public class ImportExportPanel_3 extends JPanel {        /** The table to display table names and file paths */    private JTable table;        /** The table model */    private TableTransferModel tableModel;        /** The last file path selected */    private String lastPath;        /** The controlling object for this process */    private ImportExportProcess parent;        /** <p>Creates a new instance with the specified     *  process as the parent.     *     *  @param the parent controlling the process     */    public ImportExportPanel_3(ImportExportProcess parent) {        super(new GridBagLayout());        this.parent = parent;                try {            jbInit();        } catch(Exception e) {            e.printStackTrace();        }            }        /** <p>Initialises the state of this instance and     *  lays out components on the panel. */    private void jbInit() throws Exception {        JLabel label = new JLabel("Select respective data files for " +                                  "the tables to be processed.");                // build the table and add to a scroll pane        table = new DefaultTable();        table.setRowHeight(23);        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        table.setColumnSelectionAllowed(false);        table.getTableHeader().setReorderingAllowed(false);                JScrollPane scroller = new JScrollPane(table);        scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);                tableModel = new TableTransferModel();        buildTable();                TableColumnModel tcm = table.getColumnModel();        TableColumn col = tcm.getColumn(0);        col.setPreferredWidth(140);                col = tcm.getColumn(1);        col.setPreferredWidth(255);                col = tcm.getColumn(2);        col.setCellRenderer(new BrowseButtonRenderer());        col.setCellEditor(new BrowseButtonEditor(new JCheckBox()));        col.setPreferredWidth(80);                GridBagConstraints gbc = new GridBagConstraints();        gbc.insets = new Insets(5,5,5,5);        gbc.anchor = GridBagConstraints.NORTHWEST;        add(label, gbc);        gbc.fill = GridBagConstraints.BOTH;        gbc.gridy = 1;        gbc.insets.top = 0;        gbc.weightx = 1.0;        gbc.weighty = 1.0;        add(scroller, gbc);                setPreferredSize(parent.getChildDimension());    }        /** <p>Generates and displays the table/data file <code>JTable</code>*/    public void buildTable() {        int type = parent.getTableTransferType();        boolean hasData = tableModel.hasData();        Vector v = null;                switch (type) {                        case ImportExportProcess.SINGLE_TABLE:                                String tableName = parent.getTableName();                                if (hasData && tableModel.getRowCount() > 1)                    hasData = false;                                if (!hasData || !tableName.equals(tableModel.getDataVector().                elementAt(0).toString())) {                    v = new Vector(1);                    v.add(new DataTransferObject(tableName));                }                                else                    v = tableModel.getDataVector();                                break;                            case ImportExportProcess.MULTIPLE_TABLE:                String[] tables = parent.getSelectedTables();                                v = new Vector(tables.length);                                int multipleFile = parent.getMutlipleTableTransferType();                                if (multipleFile == ImportExportProcess.SINGLE_FILE)                    v.add(new DataTransferObject("ALL TABLES"));                                else {                                        for (int i = 0; i < tables.length; i++) {                        v.add(new DataTransferObject(tables[i]));                    }                }                                if (hasData) {                    Vector v_current = tableModel.getDataVector();                    int v_currentSize =  v_current.size();                                        String newTable = null;                    Object obj = null;                                        for (int i = 0, j = v.size(); i < j; i++) {                        newTable = v.elementAt(i).toString();                                                for (int k = 0; k < v_currentSize; k++) {                            obj = v_current.elementAt(k);                                                        if (newTable.equals(obj.toString())) {                                v.setElementAt(obj, i);                                break;                            }                                                    }                                            }                                    }                                break;                        }                tableModel.setColumnDataVector(v);        table.setModel(tableModel);        table.revalidate();            }        /** <p>Returns a <code>Vector</code> of <code>     *  DataTransferObject</code> objects containing     *  all relevant data for the process.     *     *  @return a <code>Vector</code> of     *          <code>DataTransferObject</code> objects     */    public Vector getDataFileVector() {        return tableModel.getDataVector();    }        /** <p>Validates that all tables selected have     *  an associated data file selected.     *     *  @return whether transfer files are present     */    public boolean transferObjectsComplete() {                if (table.isEditing()) {            table.getCellEditor(table.getEditingRow(), 1).stopCellEditing();        }        Vector v = tableModel.getDataVector();        int v_size = v.size();        int type = parent.getTransferType();                for (int i = 0; i < v_size; i++) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -