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

📄 codemanager.java

📁 一个网络上传下载器
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    private void changeDownloadPathButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeDownloadPathButtonActionPerformed        // TODO add your handling code here:        ChangeDownloadPath changeDownloadPath = new ChangeDownloadPath(this, true, this.downloadPathTextField.getText());        changeDownloadPath.setLocationByPlatform(true);        changeDownloadPath.show(true);        this.downloadPathTextField.setText(changeDownloadPath.downloadPath);    }//GEN-LAST:event_changeDownloadPathButtonActionPerformed    /**    This method is called when downloading all source codes in a certain     folder.     */    private void SourceCodeDownload() {        java.util.List urlList;        String downloadPath = this.labelPath.getText();        String recorderPath = RecorderDownload("http://168.131.152.215/CodeManager/files.xml",                downloadPath);        File recorderFile = new File(recorderPath);        RecorderDealer recorderDealer = new RecorderDealer(recorderFile);        urlList = recorderDealer.getFilesPath("user1");        String tempPath=downloadPathTextField.getText();        //int tempPathCount=tempPath.replace(oldChar, newChar)        String signal=downloadPath.substring(2,3);        //download files        for (Iterator it = urlList.iterator(); it.hasNext();) {            try {                String fullPath = (String) it.next();                String filePath;                filePath=fullPath.replace(tempPath, downloadPath);                filePath=filePath.replace("/", signal);                filePath=filePath.substring(0,filePath.lastIndexOf(signal) + 1);                Download download = new Download(new URL(fullPath), 1, filePath, "");            } catch (MalformedURLException ex) {                Logger.getLogger(CodeManager.class.getName()).log(Level.SEVERE, null, ex);            }        }        if (recorderFile.delete()) {            System.out.println("finish");        }    }    private void ChooseFolder() {        FolderSelected folderSelected = new FolderSelected(this);        String folderPath = folderSelected.getFolderPath();        this.fileTree = new FileTree(folderPath);        fileTree.setDoubleBuffered(true);        jScrollPane1.setViewportView(fileTree);    }    private void FilesUpload() throws Exception {        uploading();        String path = this.labelPath.getText();        java.util.ArrayList folderList = null;        FolderSearch folderSearch = new FolderSearch();        folderSearch.LocalFileSearch(path);        folderList = (ArrayList) folderSearch.getFileList();        String recorderPath = RecorderDownload("http://168.131.152.215/CodeManager/files.xml",                this.labelPath.getText());        File recorderFile=new File(recorderPath);               RecorderDealer recorderDealer = new RecorderDealer(recorderFile);//                if (recorderFile.delete()) {//            System.out.println("finish");//        }        String temp = path;        int pathNameLength = temp.length();        //the follow codes is used for test        for (Iterator it = folderList.iterator(); it.hasNext();) {                  String fullPath = (String) it.next();            String sourcePath = fullPath.substring(pathNameLength + 1);            String sign = fullPath.substring(pathNameLength, pathNameLength + 1);            sourcePath = sourcePath.replace(sign, "/");            recorderDealer.addNode(sourcePath);            ftpTool.upFile(fullPath, "/upload/user1/" + sourcePath);        }        ftpTool.upFile(recorderPath, "/files.xml");        recorderDealer.close();        recorderDealer.delete();//        recorderFile.deleteOnExit();                if (recorderFile.delete()) {            System.out.println("finish");        }        complete();    }    private String RecorderDownload(String fileURLPath, String fileLocalFolder) {        try {            String fullname;            Download download = new Download(                    new URL(fileURLPath), 1, fileLocalFolder, "");            fullname = download.getFullFileName();            download.close();            return fullname;        } catch (MalformedURLException e) {            System.err.println(e);            return null;        }    }    private void Logon(String username, String password) {        try {            if (username.equalsIgnoreCase("Admin")) {                this.downloadPathTextField.setText("http://168.131.152.215/CodeManager/");                this.uploadPathTextField.setText("/upload/");            }            else if (username.equalsIgnoreCase("user1")) {                this.downloadPathTextField.setText("http://168.131.152.215/CodeManager/");                this.uploadPathTextField.setText("/upload/user1/");            }            else if (username.equalsIgnoreCase("user2")) {                this.downloadPathTextField.setText("http://168.131.152.215/CodeManager/");                this.uploadPathTextField.setText("/upload/user2/");            } else {                JOptionPane.showMessageDialog(null,                        "Unaccessed User", "NOTICE", JOptionPane.ERROR_MESSAGE);                return;            }            ftpTool = new FtpTool(username, password);            ftpTool.login();            this.usernameTextField.setEditable(false);            this.passwordTextField.setEditable(false);            this.logonButton.setEnabled(false);            this.downloadPathTextField.setEditable(false);            this.uploadPathTextField.setEditable(false);            this.downloadButton.setEnabled(true);            this.uploadButton.setEnabled(true);            this.changeDownloadPathButton.setEnabled(true);        } catch (Exception e) {            System.err.println(e);        }    }    private void Logout() {        try {            ftpTool.logout();            this.usernameTextField.setEditable(true);            this.passwordTextField.setEditable(true);            this.logonButton.setEnabled(true);            this.downloadPathTextField.setEditable(false);            this.uploadPathTextField.setEditable(false);            this.downloadButton.setEnabled(false);            this.uploadButton.setEnabled(false);            this.changeDownloadPathButton.setEnabled(false);        } catch (Exception e) {            System.err.println(e);        }    }    private void complete() {        progressLabel.setText("Complete!");    }    private void uploading() {        progressLabel.setText("Uploading...");    }    private void downloading() {        progressLabel.setText("Downloading...");    }        private void stop()    {        progressLabel.setText("Stop");    }    /**    @param args the command line arguments     */    public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new CodeManager().setVisible(true);            }        });    }    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JMenuItem aboutMenuItem;    private javax.swing.JMenuItem aboutMenuItem1;    private javax.swing.JMenuItem aboutMenuItem2;    private javax.swing.JButton buttonGetFileList;    private javax.swing.JButton changeDownloadPathButton;    private javax.swing.JButton downloadButton;    private javax.swing.JTextField downloadPathTextField;    private javax.swing.JMenu editMenuItem1;    private javax.swing.JMenu editMenuItem2;    private javax.swing.JMenu editMenuItem3;    private javax.swing.JMenuItem fileExitMenuItem;    private javax.swing.JMenuItem fileExitMenuItem1;    private javax.swing.JMenuItem fileExitMenuItem2;    private javax.swing.JMenu fileMenuItem1;    private javax.swing.JMenu fileMenuItem2;    private javax.swing.JMenu fileMenuItem3;    private javax.swing.JMenu helpMenuItem;    private javax.swing.JMenu helpMenuItem1;    private javax.swing.JMenu helpMenuItem2;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JLabel jLabel4;    private javax.swing.JMenuBar jMenuBar2;    private javax.swing.JMenuBar jMenuBar3;    private javax.swing.JMenuBar jMenuBar4;    private javax.swing.JMenuItem jMenuItem1;    private javax.swing.JMenuItem jMenuItem2;    private javax.swing.JMenuItem jMenuItem3;    private javax.swing.JPanel jPanel1;    private javax.swing.JProgressBar jProgressBar1;    private javax.swing.JScrollPane jScrollPane1;    private javax.swing.JSeparator jSeparator2;    private javax.swing.JSeparator jSeparator3;    private javax.swing.JSeparator jSeparator4;    private javax.swing.JLabel labelPath;    private javax.swing.JLabel labelPath1;    private javax.swing.JPanel logPanel;    private javax.swing.JButton logonButton;    private javax.swing.JButton logoutButton;    private javax.swing.JMenuItem menuItemDownloadManager;    private javax.swing.JMenuItem menuItemDownloadManager1;    private javax.swing.JMenuItem menuItemDownloadManager2;    private javax.swing.JButton openFolderButton;    private javax.swing.JMenuItem optionsMenuItem;    private javax.swing.JMenuItem optionsMenuItem1;    private javax.swing.JMenuItem optionsMenuItem2;    private javax.swing.JPasswordField passwordTextField;    private javax.swing.JLabel progressLabel;    private javax.swing.JMenu toolsMenuItem;    private javax.swing.JMenu toolsMenuItem1;    private javax.swing.JMenu toolsMenuItem2;    private javax.swing.JButton uploadButton;    private javax.swing.JTextField uploadPathTextField;    private javax.swing.JTextField usernameTextField;    // End of variables declaration//GEN-END:variables    private TreeList.FileTree fileTree;    private FtpTool ftpTool;}

⌨️ 快捷键说明

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