choosepropertiesaboutbox.java#1.2

来自「数据库远程同步软件NetBeans项目源文件 项目采用Jdesktop集成组件」· 2 代码 · 共 353 行 · 第 1/2 页

2
353
字号
        pack();    }// </editor-fold>//GEN-END:initComponents    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked        // TODO add your handling code here:       submit(evt);    }//GEN-LAST:event_jButton3MouseClicked    @Action    public void FileChoose1() {        JFileChooser chooser = new JFileChooser();        FileNameExtensionFilter filter = new FileNameExtensionFilter(                "Properties File", "properties");        chooser.setFileFilter(filter);        chooser.setCurrentDirectory(new File(currentDir));        chooser.setVisible(true);        int returnVal = chooser.showOpenDialog(null);        if (returnVal == JFileChooser.APPROVE_OPTION) {            strSourceFile = chooser.getSelectedFile().getAbsolutePath();            getTxtFile1().setText(strSourceFile);            currentDir = strSourceFile;        }    }    private javax.swing.JTextField getTxtFile1() {        if (fileTextField1 == null) {            fileTextField1 = new javax.swing.JTextField();        }        return fileTextField1;    }    private javax.swing.JTextField getTxtFile2() {        if (fileTextField2 == null) {            fileTextField2 = new javax.swing.JTextField();        }        return fileTextField2;    }    @Action    public void applyModify() {    //submit(evt);    }    @Action    public void FileChoose2() {        JFileChooser chooser = new JFileChooser();        FileNameExtensionFilter filter = new FileNameExtensionFilter(                "Properties File", "properties");        chooser.setFileFilter(filter);        chooser.setCurrentDirectory(new File(currentDir));        chooser.setVisible(true);        int returnVal = chooser.showOpenDialog(null);        if (returnVal == JFileChooser.APPROVE_OPTION) {            strTargetFile = chooser.getSelectedFile().getAbsolutePath();            getTxtFile2().setText(strTargetFile);            currentDir = strTargetFile;        }    }    private StringBuffer stringbuffer;    public StringBuffer getStringbuffer() {        return stringbuffer;    }    private Frame parent;    private TimerAboutBox newTimerJDialog;    private String strSourceFile;    public String getStrSourceFile() {        return strSourceFile;    }    public String getStrTargetFile() {        return strTargetFile;    }    @Action    @SuppressWarnings("static-access")    public void appendTimer() {        if (checkSubmit()) {            app = DataBaseSyncDesktopApplication.getApplication();            con1 = new SourceDataBase(getStrSourceFile()).getConnection();            con2 = new TargetDataBase(getStrTargetFile()).getConnection();            Date date = newTimerJDialog.getDate();            DbSyncTimer dbsyncTimer = new DbSyncTimer(con1, con2, date, newTimerJDialog.getModel());            app.addDbSyncTimer(dbsyncTimer);            System.out.println("Enable=" + newTimerJDialog.isEnable());            if (newTimerJDialog.isEnable()) {                dbsyncTimer.start();            }            if (newTimerJDialog.getModel() == 1) {                Propertie propertie = new Propertie();                propertie.setId(app.getPlanId());                propertie.setName("plan" + app.getPlanId());                propertie.setSourceFilePath(getStrSourceFile());                propertie.setTargetFilePath(getStrTargetFile());                propertie.setTaskTime(date);                PropertiesUtil.save(propertie);            }  stringbuffer = new StringBuffer();        stringbuffer.append("---------------------------------------------------------------");        stringbuffer.append("新增任务").append("\n");        stringbuffer.append("源DB:").append(fileTextField1.getText()).append("\n");        stringbuffer.append("目标DB:").append(fileTextField2.getText()).append("\n");        stringbuffer.append("---------------------------------------------------------------");        stringbuffer.append("\n");            setVisible(false);        }    }    private boolean checkSubmit() {        if ("".equals(getFileText1())) {            JOptionPane.showMessageDialog(null, "源数据库配置文件不能为空", "Warning", JOptionPane.ERROR_MESSAGE);            fileTextField1.setFocusable(true);            return false;        }        if ("".equals(getFileText2())) {            JOptionPane.showMessageDialog(null, "目的数据库配置文件不能为空", "Warning", JOptionPane.ERROR_MESSAGE);             fileTextField2.setFocusable(true);            return false;        }        if ("".equals(getModelText())) {            JOptionPane.showMessageDialog(null, "未设置调度模式", "Warning", JOptionPane.ERROR_MESSAGE);             modelTextField.setFocusable(true);            return false;        }        return true;    }    public String getFileText1() {        return fileTextField1.getText();    }    public String getFileText2() {        return fileTextField2.getText();    }    public String getModelText() {        return modelTextField.getText();    }    public void submit(java.awt.event.MouseEvent evt){        closeAboutBox();        //newTimerJDialog.setPrevious(this);        newTimerJDialog = new TimerAboutBox(this, parent);        Point invokerOrigin = parent.getLocationOnScreen();        newTimerJDialog.setLocation(invokerOrigin.x + evt.getX(), invokerOrigin.y + evt.getY());        newTimerJDialog.setVisible(Boolean.TRUE);        String msg = null;        if (newTimerJDialog.getModel() == 0) {            msg = "一次运行于:" + new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss").format(newTimerJDialog.getDate());        } else {            msg = "每天运行于:" + new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss").format(newTimerJDialog.getDate());        }        //System.out.println("msg="+msg);        modelTextField.setText(msg);    }    private DataBaseSyncDesktopApplication app;    private Connection con1;    private Connection con2;    private String strTargetFile;    private String currentDir;    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton closeButton;    private javax.swing.JTextField fileTextField1;    private javax.swing.JTextField fileTextField2;    private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JButton jButton3;    private javax.swing.JButton jButton4;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JTextField modelTextField;    // End of variables declaration//GEN-END:variables}

⌨️ 快捷键说明

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