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

📄 ftpwizard.java

📁 eclipse平台的CDT项目3.0版本的源代码
💻 JAVA
字号:
//Title:        Curriculum Development Tool
//Copyright:    Copyright (c) 2001
//Author:       David Bradford - dbrad@medstat.med.utah.edu
//Company:      Knowledge Weavers - http://medstat.med.utah.edu/kw/
//File:         FtpWizard2.java
//Description:  1st page of Ftp Wizard

package cdt.projects.export.ftp;

import javax.swing.*;
import java.awt.*;

import cdt.wizard.*;
import com.ibm.network.ftp.protocol.*;
import cdt.projects.Project;
import cdt.Cdt;

/**
 * This is the first page is the great ftp wizard.  This uses the wizard framework.
 * I got the ftp stuff from ibm's website.  This first part of the wizard has the user
 * log on to their server.
 *
 * @version 1.0
 * @author David Bradford
 */
public class FtpWizard extends WizardFrame {
    /** Project to be exported. */
    private Project proj;
    /** Textfield to hold username. */
	private JTextField username = new JTextField(30);
	/** Textfield to hold the server name. */
	private JTextField server = new JTextField(30);
	/** Textfield to hold the password. */
	private JPasswordField password = new JPasswordField(30);

	/**
	 * Creates the ftp wizard.
	 *
	 * @param proj Project to export.
	 * @param parent main frame of cdt.
	 */
	public FtpWizard(Project proj, JFrame parent) {
        super(parent);
		this.proj = proj;
        server.setText(Cdt.config.getProperty("ftp-server"));
        username.setText(Cdt.config.getProperty("ftp-username"));
        putData("Project", this.proj);
		init();
	}

	/**
	 * Sets up the frame.
	 */
	public void customize() {
		setTitle("FTP Wizard");
		setFrameLabel1("Login");

		showPreviousButton(false);
		showFinishButton(false);

		JPanel panel = new JPanel();
		panel.setLayout(new GridLayout(3, 0));

		JPanel serv = new JPanel();
		serv.add(new JLabel("Enter server:       "));
		serv.add(server);
		panel.add(serv);
		JPanel user = new JPanel();
		user.add(new JLabel("Enter username: "));
		user.add(username);
		panel.add(user);
		JPanel pass = new JPanel();
		pass.add(new JLabel("Enter password: "));
		pass.add(password);
		panel.add(pass);

		centerPanel.add(panel);
	}

	/**
	 * The next button has been pressed.  Connect to the ftp and save the connection.
	 */
	public void nextAction() {
		char[] pass;
		pass = password.getPassword();
		if(pass.length == 0) {
			cdt.ErrorD.ErrorDlg.ErrorMsg("Password Missing");
			return;
		}
		if (server.getText().length() == 0) {
			cdt.ErrorD.ErrorDlg.ErrorMsg("Server Name Missing");
		} else if(username.getText().length() == 0) {
			cdt.ErrorD.ErrorDlg.ErrorMsg("Username Missing");
		} else {
			FTPProtocol ftp = new FTPProtocol();
			ftp.connectLogin(server.getText(), username.getText(), new String(pass));
			for(int i=0;i<pass.length;i++) {
				pass[i] = 0;
			}
			if(ftp.getCurrentDir(true).equals("")) {
				cdt.ErrorD.ErrorDlg.ErrorMsg("Could Not Login");
				return;
			}
			putData("ftp", ftp);
            Cdt.config.setProperty("ftp-server", server.getText());
            Cdt.config.setProperty("ftp-username", username.getText());
			pushFrame(this);
            setVisible(false);
            new FtpWizard1((JFrame)getData().get("parentFrame"));
		}
	}
}

⌨️ 快捷键说明

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