TableBcpInDialogOfMSSQL

    技术2024-07-11  76

    public class TableBcpInDialogOfMSSQL extends AbstractProcessDialog{

        /**     *      */    private static final long serialVersionUID = 1L;

        private DebugPrn dMsg = new DebugPrn(TableBcpInDialogOfMSSQL.class.getName());    //private static Logger dMsg = Logger.getLogger(DBResourceDialog.class.getName());

        private I18n I18N = null;    private String STR_ESCAPE_RELEASED = "ESCAPE_RELEASED";    private KeyStroke ESCAPE_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);    private KeyStroke ENTER_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);

        private DatabaseInfo dbInfo = null;

        private JTextField jvalueTextArea = new JTextField("");

        private JCheckBox jcIsTruncateFirst = new JCheckBox();

        /**用户(ora) 或者 数据库名 的列表*/    // private ZJList jcmbDBName = new ZJList();    private ZXComboBox jcmbDBName = new ZXComboBox();

        /**显示DB信息的JTable控件列名*/    private Vector vecColumnStrDBInfo = null;    /**显示table信息的JTable控件列名*/    private Vector vecColumnStrTableInfo = null;

        private NonEditableTableModel jtbModelTableInfo = null;

        // 各种 监控器 和 动作事件 处理类    private KeyAdapter keyAdpJcmbEnter = null;    private KeyAdapter keyAdpEscape = null;    private ActionListener actionLsrJbutOk = null;    private ActionListener actionLsrJbutEXECUTE = null;    private ActionListener actionLsrJbutUpdateDBMSOwnerSystemTables = null;

        private ActionListener actionLsrCommon = null;

        private ActionListener actionFile = null;

        private ActionListener itemLsrJcmbDBName = null;    private Action actionEscape = null;    private JFrame jfmMain = null;    private AbstractProcessJFrame main = null;

        private JTable jtblTableInfo = null;

        private String dbName = null;    private String path = null;    private String tableName = null;    private AbstractProcessDialog thisDialog = null;

        //private final static ImageIcon ICON_DBSVR_RESVIEW_DESC = UIToolKit    //       .getIcon("uep-dev-d-dbres-browse");

        /**     * 构造函数     * @param frame     * @param title     * @param modal     * @param inDbInfo     */    public TableBcpInDialogOfMSSQL(AbstractProcessJFrame main, String title, DatabaseInfo inDBInfo)    {        super(main, title, true);        thisDialog = this;        I18N = STMConsts.getI18N();        jfmMain = main;        this.main = main;        this.dbInfo = inDBInfo;        boolean bOk = false;        this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

            try        {            defineActions();            bOk = initialize();

            }        catch(Exception ignore)        {            dMsg.error("", ignore);            return;        }        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

            if(bOk)        {            ToolBox.setDlgCenterDisplayLocation(this);            setVisible(true);        }

        }

        /**     *     *各种事件处理函数     */    private void defineActions()    {        // Enter键 处理        keyAdpJcmbEnter = new KeyAdapter()        {

                public void keyPressed(KeyEvent e)            {                if(e.getSource() instanceof JComboBox)                {                    if(!(((JComboBox) (e.getSource())).isPopupVisible()))                    {                        if(e.getKeyCode() == KeyEvent.VK_ENTER)                        {                            importTable();                        }                    }                }            }        };        //        keyAdpEscape = new KeyAdapter()        {

                public void keyPressed(KeyEvent e)            {                if(e.getKeyCode() == KeyEvent.VK_ESCAPE)                {                    close();                }            }        };        //        actionEscape = new AbstractAction()        {

                /**             *              */            private static final long serialVersionUID = 1L;

                public void actionPerformed(ActionEvent e)            {                close();            }        };        //        itemLsrJcmbDBName = new ActionListener()        {

                public void actionPerformed(ActionEvent e)            {                jcmbDBName_itemStateChanged(e);            }        };

            //        actionLsrJbutOk = new ActionListener()        {

                public void actionPerformed(ActionEvent e)            {                jbutOk_actionPerformed(e);            }        };

            //        actionLsrJbutEXECUTE = new ActionListener()        {

                public void actionPerformed(ActionEvent e)            {                jbutEXECUTE_actionPerformed(e);            }        };

            //        actionLsrJbutUpdateDBMSOwnerSystemTables = new ActionListener()        {

                public void actionPerformed(ActionEvent e)            {                jbutUpdateDBMSOwnerSystemTables_actionPerformed(e);            }        };

            actionLsrCommon = new ActionListener()        {

                public void actionPerformed(ActionEvent ae)            {                //调度事件                jbRefreshClicked(ae);            }        };

            actionFile = new ActionListener()        {

                public void actionPerformed(ActionEvent ae)            {                //调度事件                selectPath(jvalueTextArea);            }        };    }

        /**     * 更新     * @param ae ActionEvent     */    private void jbRefreshClicked(ActionEvent ae)    {

            actionLsrJbutUpdateDBMSOwnerSystemTables.actionPerformed(ae);

        }

        /**     * 消息回调方法     * @param msg String 系统表信息更新完成     */    public void addProcessMsg(String msg)    {        SwingUtilities.invokeLater(new UpdateHandler(this));    }

        /**     * 初使化操作     *     */    private boolean initialize()    {        this.setSize(new Dimension(780, 500));        UIToolKit.setMinimumSize(this, 780, 500);        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);        this.registerEscapeAction(this.getRootPane(), actionEscape);        this.setupColumnStrVector();

            //-------------数据表信息-----------        jtbModelTableInfo = new NonEditableTableModel(new Vector(), this.vecColumnStrTableInfo);

            if(addAllDBNamesToJcmbDBName() == false)        {            return false;        }

            jcmbDBName.addActionListener(null);        jcmbDBName.addActionListener(itemLsrJcmbDBName);        jcmbDBName.setEditable(false);        jcmbDBName.setSelectedIndex(0);        jcmbDBName.addKeyListener(keyAdpJcmbEnter);

            //加载当前库所有表行数信息        jtblTableInfo = TableHelper.createSortableTable(jtbModelTableInfo);        jtblTableInfo.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);        jtblTableInfo.addKeyListener(keyAdpEscape);        setCellRender(jtblTableInfo);        jtblTableInfo.setDefaultRenderer(String.class, new CellRender());        jtblTableInfo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        JScrollPane jscrPaneTableInfo = new JScrollPane();        jscrPaneTableInfo.getViewport().add(jtblTableInfo);        if(loadTableInfoofCurrUser() == false)        {            return false;        }        JPanel panelTableInfo = new JPanel();        panelTableInfo.setLayout(new BorderLayout(6, 6));

            JPanel jscrDBNamesInfo = new JPanel();        jscrDBNamesInfo.setLayout(new BorderLayout(6, 6));

            JPanel p1 = new JPanel();        p1.setLayout(new GridBagLayout());        p1.setPreferredSize(new Dimension(160, 30));

            p1.add(new JLabel(STMConsts.getI18N().getLabelValue("info_dataclear_database")),                new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

            p1.add(jcmbDBName,                new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,                        GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));        jscrDBNamesInfo.add(p1, BorderLayout.WEST);

            JPanel p2 = new JPanel();        p2.setLayout(new BorderLayout(6, 6));        p2.setPreferredSize(new Dimension(400, 30));

            JButton fileButton = new JButton(STMConsts.getI18N().getLabelValue("info_imp_filebutton"));        fileButton.setMnemonic('F');        fileButton.addActionListener(actionFile);

            JPanel p3 = new JPanel();        p3.setLayout(new BorderLayout(6, 6));        p3.setPreferredSize(new Dimension(200, 30));

            p3.add(fileButton, BorderLayout.CENTER);

            p2.add(jvalueTextArea, BorderLayout.CENTER);        p2.add(p3, BorderLayout.EAST);

            jscrDBNamesInfo.add(p2, BorderLayout.CENTER);

            panelTableInfo.add(jscrDBNamesInfo, BorderLayout.NORTH);        jscrPaneTableInfo.setBorder(BorderFactory.createTitledBorder(""));        panelTableInfo.add(jscrPaneTableInfo, BorderLayout.CENTER);        JPanel jpTabRoot = new JPanel();        jpTabRoot.setLayout(new GridBagLayout());        jpTabRoot.add(panelTableInfo, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,                GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 6, 6, 6), 0, 0));

            //进程信息panelProcessInfo------------------------

            //----this.getContentPane()        JButton jbutRefresh = new JButton(I18N.getLabelValue("I18N_REFRESH_R"));        jbutRefresh.setMnemonic('R');        jbutRefresh.addActionListener(actionLsrCommon);

            JButton jbutClose = new JButton(I18N.getLabelValue("I18N_CANCEL"));        jbutClose.setMnemonic('C');

            jbutClose.addActionListener(actionLsrJbutOk);

            JButton jbutEXECUTE = new JButton(I18N.getLabelValue("info_imp_button"));        jbutEXECUTE.setMnemonic('E');        jbutEXECUTE.registerKeyboardAction(actionLsrJbutEXECUTE, ENTER_STROKE,                JComponent.WHEN_IN_FOCUSED_WINDOW);        jbutEXECUTE.addActionListener(actionLsrJbutEXECUTE);

            JPanel jpButtonPanel = new JPanel();        jpButtonPanel.setLayout(new GridBagLayout());        jcIsTruncateFirst.setText(I18N.getLabelValue("info_imp_checkbox_truncate"));        jpButtonPanel.add(jcIsTruncateFirst, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.NORTHWEST, GridBagConstraints.WEST, new Insets(0, 0, 0, 295),                10, 0));        jpButtonPanel.add(jbutEXECUTE, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.NORTHWEST, GridBagConstraints.EAST, new Insets(0, 0, 0, 3), 10,                0));        jpButtonPanel.add(jbutRefresh, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,                GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 3), 0, 0));

            jpButtonPanel.add(jbutClose,                new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,                        GridBagConstraints.NONE, new Insets(0, 3, 0, 0), 0, 0));        this.getContentPane().setLayout(new GridBagLayout());

            /*         JPanel jpDesc = UIToolKit.createDialogDescPanel(I18N         .getLabelValue("DIALOG_DESC_DBRES_VIEW_TITLE"), I18N         .getLabelValue("DIALOG_DESC_DBRES_VIEW_DESC"), ICON_DBSVR_RESVIEW_DESC);         this.getContentPane().add(         jpDesc,         new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,         GridBagConstraints.HORIZONTAL, new Insets(0, 0, 3, 0), 0, 0));         */        this.getContentPane().add(                jpTabRoot,                new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,                        GridBagConstraints.BOTH, new Insets(3, 12, 6, 12), 385, 242));        this.getContentPane().add(                jpButtonPanel,                new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,                        GridBagConstraints.NONE, new Insets(6, 0, 12, 12), 0, 0));        jbutClose.requestFocus();        return true;    }

        /**     * 加载当前库的所有表的信息     * @return boolean 失败返回false     */    private boolean loadTableInfoofCurrUser()    {        String dbName = (String) jcmbDBName.getSelectedItem();        Vector vecTableInfo2D = null;        try        {            vecTableInfo2D = DBAction.getAllTableInfoOfOwner(this.jfmMain, dbName, this.dbInfo);            for(int i = 0; i < vecTableInfo2D.size(); i++)            {                Vector vecRowData = (Vector) vecTableInfo2D.get(i);                Vector vecParsed = parseData(vecRowData);                vecTableInfo2D.setElementAt(vecParsed, i);            }            jtbModelTableInfo.setDataVector(vecTableInfo2D, this.vecColumnStrTableInfo);            int iWidth = this.dbInfo.getDBType() == DatabaseInfo.DBTYPE_ORACLE ? 220 : 150;            for(int iIndex = 0; iIndex < vecColumnStrTableInfo.size(); iIndex++)            {                jtblTableInfo.getColumnModel().getColumn(iIndex).setPreferredWidth(iWidth);            }        }        catch(FIException fiEx)        {            ZJShowMsgPane.showDetailMessage(this, fiEx);            return false;        }        return true;    }

        /**     *     *设置显示DB和Table信息的JTable列名称     */    private void setupColumnStrVector()    {        vecColumnStrDBInfo = new Vector();        vecColumnStrTableInfo = new Vector();

            int iDBType = this.dbInfo.getDBType();        switch(iDBType)        {            case DatabaseInfo.DBTYPE_ORACLE:                //显示DB信息的JTable控件列名                this.vecColumnStrDBInfo.add(I18N.getLabelValue("dbSpaceName"));                this.vecColumnStrDBInfo.add(I18N.getLabelValue("assignSize") + "(KB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("usedSize") + "(KB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("leftSize") + "(KB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("leftPercent") + "(%)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("autoextensible"));                this.vecColumnStrDBInfo.add(I18N.getLabelValue("datafile"));                //显示table信息的JTable控件列名                this.vecColumnStrTableInfo.add(I18N.getLabelValue("tabName"));                this.vecColumnStrTableInfo.add(I18N.getLabelValue("inDbSpace"));                this.vecColumnStrTableInfo.add(I18N.getLabelValue("recNum"));

                    break;            case DatabaseInfo.DBTYPE_MSSQL:                //显示DB信息的JTable控件列名                this.vecColumnStrDBInfo.add(I18N.getLabelValue("dbName"));                this.vecColumnStrDBInfo.add(I18N.getLabelValue("dbSize") + "(MB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("UnassignSize") + "(MB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("reserveSize") + "(KB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("dataSize") + "(KB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("indexSize") + "(KB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("unusedSize") + "(KB)");                this.vecColumnStrDBInfo.add(I18N.getLabelValue("I18N_MDF_FREE_PERCENT") + "(%)");                //显示table信息的JTable控件列名                this.vecColumnStrTableInfo.add(I18N.getLabelValue("tabName"));                this.vecColumnStrTableInfo.add(I18N.getLabelValue("recNum"));                this.vecColumnStrTableInfo.add(I18N.getLabelValue("reserveSize") + "(KB)");                this.vecColumnStrTableInfo.add(I18N.getLabelValue("dataSize") + "(KB)");                this.vecColumnStrTableInfo.add(I18N.getLabelValue("indexSize") + "(KB)");                this.vecColumnStrTableInfo.add(I18N.getLabelValue("unusedSize") + "(KB)");                //显示 process info 的JTable控件列名

                    break;

                default:                dMsg.error("Wrong database got! iDBType=" + iDBType);                break;        }    }

        /**     * 将数据库/用户名 添加到 jcmbDBName 中     */    private boolean addAllDBNamesToJcmbDBName()    {        String[] dbName = new String[3];        if(this.dbInfo.getDBType() == DatabaseInfo.DBTYPE_ORACLE)        {            dbName[0] = DatabaseInfo.EMS_ORACLE_UEP;            dbName[1] = DatabaseInfo.EMS_ORACLE_UEPPM;            dbName[2] = DatabaseInfo.EMS_ORACLE_CAFFM;

            }        else        {            dbName[0] = DatabaseInfo.EMS_MSSQL_UEP;            dbName[1] = DatabaseInfo.EMS_MSSQL_UEPPM;            dbName[2] = DatabaseInfo.EMS_MSSQL_CAFFM;

            }        String[] arrStrDBNames = null;        try        {            arrStrDBNames = DBAction.getDBSOwners(this.jfmMain, this.dbInfo);            if(arrStrDBNames != null)            {                for(int i = 0; i < arrStrDBNames.length; i++)                {                    for(int j = 0; j < dbName.length; j++)                    {                        if(dbName[j].equalsIgnoreCase(arrStrDBNames[i]))                        {                            jcmbDBName.addItem((arrStrDBNames[i]));                        }                    }                }                jcmbDBName.setSelectedIndex(0);            }        }        catch(FIException fiEx)        {            ZJShowMsgPane.showDetailMessage(this, fiEx);            return false;        }        return true;    }

        /**     *     * @param itemEvent     */    private void jcmbDBName_itemStateChanged(ActionEvent itemEvent)    {        String dbName = (String) jcmbDBName.getSelectedItem();        Vector vecTableInfo2D = null;        this.setCursor(new Cursor(Cursor.WAIT_CURSOR));        try        {            vecTableInfo2D = DBAction.getAllTableInfoOfOwner(this.jfmMain, dbName, this.dbInfo);            jtbModelTableInfo.removeAllRow();            for(int i = 0; i < vecTableInfo2D.size(); i++)            {                Vector vecRawData = (Vector) vecTableInfo2D.get(i);                Vector vecParsed = parseData(vecRawData);                jtbModelTableInfo.addRow(vecParsed);            }        }        catch(FIException fiEx)        {            jtbModelTableInfo.setDataVector(vecTableInfo2D, this.vecColumnStrTableInfo);            ZJShowMsgPane.showDetailMessage(this, fiEx);        }        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));    }

        /**     *     * @param vec     * @return     */    private Vector parseData(Vector vec)    {        Vector vecFolat = new Vector();        int iVecSize = vec.size();        float fvalue = (float) 0.0;        int iDBType = this.dbInfo.getDBType();        for(int i = 0; i < iVecSize; i++)        {            String tempstr = vec.get(i).toString();            // TODO 单号610000056089            if(i == 0)            {                vecFolat.addElement(tempstr);                continue;            }            tempstr = tempstr.trim();            String oldtemp = tempstr;            int iUnit = tempstr.indexOf("MB");            if(iUnit == -1)            {                iUnit = tempstr.indexOf("KB");            }            if(iUnit == -1)            {                iUnit = tempstr.indexOf("%");            }            if(iUnit == -1)            {                try                {                    //格式化显示剩余空间数据,都显示两位小数                    switch(iDBType)                    {                        case DatabaseInfo.DBTYPE_MSSQL:                            if(i == iVecSize - 1)                            {                                DecimalFormat df1 = new DecimalFormat("0.00");                                vecFolat.addElement(df1.format(Float.valueOf(tempstr)));                            }                            else                            {                                vecFolat.addElement(Float.valueOf(tempstr));                            }                            break;                        case DatabaseInfo.DBTYPE_ORACLE:                            if(i == 4)                            {                                DecimalFormat df1 = new DecimalFormat("0.00");                                vecFolat.addElement(df1.format(Float.valueOf(tempstr)));                            }                            else                            {                                vecFolat.addElement(Float.valueOf(tempstr));                            }                            break;                    }                    continue;                }                catch(NumberFormatException ex)                {                    vecFolat.addElement(tempstr);                    continue;                }            }            try            {                tempstr = tempstr.substring(0, iUnit);                fvalue = Float.parseFloat(tempstr);                vecFolat.addElement(new Float(fvalue));            }            catch(NumberFormatException ex)            {                vecFolat.addElement(oldtemp);                continue;            }        }        return vecFolat;    }

        /**     *     * @param e     * @JTIUP     */    private void jbutUpdateDBMSOwnerSystemTables_actionPerformed(ActionEvent e)    {

            //        int iOption = ZJShowMsgPane.showConfirmDialog(STMClientView.getSTMMainFrame(),        //                I18N.getLabelValue("I18N_UPDATE_STAT_TIP"),        //                I18N.getLabelValue("dialogQuestion"),        //                ZJShowMsgPane.OK_CANCEL_OPTION,        //                ZJShowMsgPane.QUESTION_MESSAGE);        //       if(iOption != ZJShowMsgPane.OK_OPTION) {        //        return;        //       }        // begin updating...        String strOwner = (String) jcmbDBName.getSelectedItem();        this.setCursor(new Cursor(Cursor.WAIT_CURSOR));        try        {            this.dbInfo.setOwner(strOwner);            DBAction.updateDBMSSystemTables(this, this.dbInfo, strOwner);        }        catch(FIException fiEx)        {            ZJShowMsgPane.showDetailMessage(this, fiEx);        }        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));        ZJShowMsgPane.showMessageDialog(this, I18N.getLabelValue("I18N_UPDATING_TIP"),                ZJShowMsgPane.INFORMATION_MESSAGE);    }

        /**     * 关闭操作     * 也就是唯一按钮ok按钮的action响应方法     * @param e     * @JTIUP     */    private void jbutOk_actionPerformed(ActionEvent e)    {        this.close();    }

        /**     * 关闭操作     * 也就是唯一按钮ok按钮的action响应方法     * @param e     * @JTIUP     */    private void jbutEXECUTE_actionPerformed(ActionEvent e)    {        dMsg.error("按下导入按钮");        importTable();        //this.close();    }

        /**     * 注册escape按键事件到指定组件 当指定组件在当前窗口时,action动作会注册到escape按键响应上     *     * @param component     * @param action     */    private void registerEscapeAction(JComponent component, Action action)    {        component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ESCAPE_STROKE,                STR_ESCAPE_RELEASED);        component.getActionMap().put(STR_ESCAPE_RELEASED, action);    }

        /**     * 撤销指定组件的escape事件     * 将escape响应从指定组件上撤销     * @param component     */    private void unregisterEscapeAction(JComponent component)    {        component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(ESCAPE_STROKE);        component.getActionMap().remove(STR_ESCAPE_RELEASED);    }

        private void importTable()    {

            try        {            if(jtblTableInfo.getSelectedRow() == -1)            {                throw new STMRuntimeException(STMConsts.getI18N().getLabelValue(                        "info_dataclear_chooseTable"));            }

                this.path = jvalueTextArea.getText().trim();

                if(path.equals(""))            {                throw new STMRuntimeException(STMConsts.getI18N().getLabelValue(                        "info_imp_inputfile"));            }

                File file = new File(path);            if(file.exists() && file.isFile())            {

                }            else            {                throw new STMRuntimeException(STMConsts.getI18N().getLabelValue(                        "info_imp_inputfile_ag"));            }            this.dbName = (String) jcmbDBName.getSelectedItem();            this.tableName = (String) jtblTableInfo.getModel().getValueAt(                    jtblTableInfo.getSelectedRow(), 0);

                //checkData(dbName,tableName);            close();//            MainFrame.waitThread = new WaitThread(main, STMConsts.getI18N().getLabelValue(//                    "info_imp_waitng"), STMConsts.getI18N().getLabelValue("info_imp_waitng"));//            MainFrame.waitThread.start();            main.paintStatus(STMConsts.getI18N().getLabelValue("info_imp_waitng"));            main.guiChange(false);            new Thread()            {

                    public void run()                {                    try                    {                        if(jcIsTruncateFirst.isSelected())                        {                            String sql = "truncate table " + dbName + ".dbo." + tableName;                            DBAction.executeUpdateSql(jfmMain, dbInfo, dbName, sql);                        }

                            String fileName = path;

                            String[] tableNames = new String[1];                        String[] fileNames = new String[1];                        tableNames[0] = tableName;                        fileNames[0] = fileName;                        DBAction.runTableBcpProcessor(main, dbInfo, dbName, tableNames, path,                                fileNames, 0);                    }

                        catch(FIException e)                    {                        //MainFrame.closeWaitDialog();                        main.clearStatus();                        main.guiChange(true);                        ZJShowMsgPane.showMessageDialog(thisDialog, e.toString(), STMConsts                                .getI18N().getLabelValue("ZJShowMsgPane_QuestionMessage"),                                ZJShowMsgPane.WARNING_MESSAGE);                    }                }            }.start();

            }        catch(STMRuntimeException e)        {            ZJShowMsgPane.showMessageDialog(this, e.toString(), STMConsts.getI18N().getLabelValue(                    "ZJShowMsgPane_QuestionMessage"), ZJShowMsgPane.WARNING_MESSAGE);

            }

        }

        private void selectPath(JTextField path)    {        JFileChooser chooser = new JFileChooser();        chooser.setCurrentDirectory(new File("./"));        chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

            chooser.setFileFilter(new FileFilterBase("txt"));

            int returnVal = chooser.showOpenDialog(this);

            if(returnVal == JFileChooser.APPROVE_OPTION)        {            path.setText(chooser.getSelectedFile().getPath());        }    }

        /**     * 退出对话框     */    private void close()    {        unregisterEscapeAction(this.getRootPane());

            dispose();    }

        private void setCellRender(JTable table)    {        int size = table.getColumnCount();        for(int i = 0; i < size; i++)        {            Class cla = table.getColumnClass(i);            table.setDefaultRenderer(cla, new CellRender());        }    }

        /**     * <p>Title: </p>     *     * <p>Description: </p>     *     * <p>Copyright: Copyright (c) 2007</p>     *     * <p>Company: 中兴通讯股分有限公司</p>     * @author wanghong     * @version 3.0     */    private class CellRender extends DefaultTableCellRenderer    {

            /**         *          */        private static final long serialVersionUID = 1L;

            CellRender()        {        }

            /**         * Returns the component used for drawing the cell.         *         * @param table the <code>JTable</code> that is asking the renderer to draw; can be <code>null</code>         * @param value the value of the cell to be rendered. It is up to the specific renderer to interpret and draw         *   the value. For example, if <code>value</code> is the string "true", it could be rendered as a string or it         *   could be rendered as a check box that is checked. <code>null</code> is a valid value         * @param isSelected true if the cell is to be rendered with the selection highlighted; otherwise false         * @param hasFocus if true, render cell appropriately. For example, put a special border on the cell, if the         *   cell can be edited, render in the color used to indicate editing         * @param row the row index of the cell being drawn. When drawing the header, the value of <code>row</code> is -1         * @param column the column index of the cell being drawn         * @return Component         * @todo Implement this javax.swing.table.TableCellRenderer method         */        public Component getTableCellRendererComponent(JTable table, Object value,                boolean isSelected, boolean hasFocus, int row, int column)        {            Object disPlay = value;            if(value instanceof Float)            {                //去掉小数点                if(value.toString().endsWith(".0"))                {                    disPlay = String.valueOf(((Float) value).longValue());                }            }            return super.getTableCellRendererComponent(table, disPlay, isSelected, hasFocus, row,                    column);        }    }

        /**     *     * <p>Title: </p>     * <p>Description: </p>     * <p>Copyright: Copyright (c) 2007</p>     * <p>Company: 中兴通讯股分有限公司</p>     * @author not attributable     * @version 3.0     */    private class UpdateHandler implements Runnable    {

            private TableBcpInDialogOfMSSQL dbResDialog = null;

            /**         * 更新界面         * @param dialog DBResourceDialog         */        public UpdateHandler(TableBcpInDialogOfMSSQL dialog)        {            dbResDialog = dialog;        }

            /**         * 更新界面         */        public void run()        {            dbResDialog.setCursor(new Cursor(Cursor.WAIT_CURSOR));            try            {                dbResDialog.loadTableInfoofCurrUser();            }            catch(Exception ex)            {                ex.printStackTrace();            }            catch(Throwable ex)            {                ex.printStackTrace();            }            dbResDialog.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

            }    }

        public AbstractProcessJFrame getMain()    {        return main;    }

        public void setMain(AbstractProcessJFrame main)    {        this.main = main;    }}

    最新回复(0)