|
<Number>: [00000976]
<Date>: 2016/01/03 21:59:32
<Title>:
<Name>: amanojaku@管理人
|
|
|
今回は複数のフォルダーの単位のファイルの Synchronize(同期) です(子フォルダーに対する再帰的な処理)。
TransferList にデータが存在する場合は「HostFolder、LocalFolder」のデータは無視され、TransferList にデータが存在しない場合は「HostFolder、LocalFolder」のデータで処理される。
ファイルを Synchronize(同期) したい場合は LocalFolder にはファイル名は含めずにフォルダー名だけにして下さい。
処理の実行中に[Break]ボタンをクリックしても その時点でマウス・イベントが発生しなかったが、時間のかかる処理を別の Thread として実行させてやることで その時点で[Break]ボタンのマウス・イベントを処理できるようにしている。
マウスのダブル・クリック検出用プログラムを変更、少しばかり冗長的でスマートとは言えないが、以前のように力技でゴリ押していたよりはマシ。
(Android OS のバージョンによって違うかもしれないが) Android端末にファイルをコピーすると その時点のタイム・スタンプに変更されてしまうが、それはファイルの Synchronize(同期) の障害となり、ファイルのムダなダウンロードが発生してしまう。
それを回避するためには『Local側から Android側にアップロードした時に、(ファイルのタイム・スタンプではなく実際の)ファイルの製作 年月日が Local側と Android側のファイルが同じか古い』事がチェックできるように それらのファイルのタイム・スタンプを別途 保存してしてやれば良い(ここでは便宜的に それを SnapShot と呼ぶ)。
SnapShot のファイル名は".FTPConnect.SnapShot"としており、対象となる各フォルダー内(子フォルダー内にも)に作成される(一旦 Local側で作成し Host側(Server側) にアップロードしている)。
このプログラムは あくまでも Android用での使用を前提としている(ファイル転送モードに Auto が無いので他の FTP Server は想定外となる)。
現状で『「Host側(Server側)、Local側」の双方のファイルが完全に Synchronize(同期) されている』事が判っているなら SnapShot の[Make]を実行することにより、ムダなファイルのダウンロードを回避できる。
手動で Synchronize(同期) してから SnapShot の[Make]を実行してやると言う手もある。
《参考》
『Java2 FTP Connect 9』
http://artemis.rosx.net/sjis/smt.cgi?r+izanami/&bid+00000918&tsn+00000972-00000972&
『Java2 MouseDoubleClicked 1』
http://artemis.rosx.net/sjis/smt.cgi?r+izanami/&bid+00000918&tsn+0000096B.+&
クラスパスの設定
http://www.hot-surprise.org/IntroEclipse/Operation/N01/3_3.html
FTP に関するプログラムは下記ページを参照.
JavaによるFTP転送サンプル | Pa-kun plus idea
http://web.plus-idea.net/2011/06/javaftp/
> client.setControlEncoding("MS932");
↑ Host 側のキャラクター・セットを設定すれば良いと思われる。
Windows 系では「CP932」(Microsoft Windows CodePage 932)、UNIX 系では「UTF-8、EUC-JP(日本の場合)」などが大半のようだ、Android は「UTF-8」となる。
厳密に言うと Windows のキャラクター・セットは「shift_jis」と完全な互換ではない、今まで Windows のキャラクター・セットのスタンダードな表記法は「CP932」だったが、「commons-net-3.3」では「MS932」でないとエラーになるようだ.
JavaでFTPアップロードを行う。 - sinsengumi.net
http://sinsengumi.net/blog/2011/02/java%E3%81%A7ftp%E3%82%A2%E3%83%83%E3%83%97%E3%83%AD%E3%83%BC%E3%83%89%E3%82%92%E8%A1%8C%E3%81%86%E3%80%82/
(分かりやすければ他のファイル名でも良い)「MainPanelDesign」(MainPanelDesign.java)ファイルを Visual Swing for Eclipse でビジュアルに画面デザイン(GUI 部品の配置)を作成している(Java コードが自動生成される)。
「MainAppFrameObj、MainPanelImplementationObj」 からアプレット独自メソッドにアクセスしているので、「MainAppFrameObj、MainPanelImplementationObj」はアプレット・クラス内に設置している。
(アプリーケーションの初期実行用) main( ) メソッドで(MainAppFrameObjなどのような)クラス内クラスをインスタンス化したい場合(main( ) メソッド実行時には、まだアプレット自体のインスタンスが生成されておらず、通常のクラス内クラスではインスタンス化できないので) 、クラス内クラスには「static」修飾子を付与しなければならない(この場合、オブジェクトは1つだけしか作成できない)。
クリック時にマウス・カーソルが動いてしまった場合 mouseClicked イベントだとイベントが発生しない"仕様"になっているようなので、mouse イベントに関しては mouseReleased イベントを使用している。
なお、ダブル・クリック検出用に mousePressed イベントも使用している。
変更した部分はイベント用メソッドの「HostLogout_CbtMouseMouseReleased、HostLogin_CbtMouseMouseReleased、FTPFileList_CbtMouseMouseReleased、FTPDownload_CbtMouseMouseReleased、FTPUpload_CbtMouseMouseReleased、HostFileList_CbtNativeMouseMousePressed、HostFileList_CltNativeMouseMouseReleased、LocalFileList_CbtNativeMouseMousePressed、LocalFileList_CltNativeMouseMouseReleased、SetupFileList_HostFolder_CbtMouseMouseReleased、SetupFileList_LocalFolder_CbtMouseMouseReleased、FTPBreak_CbtMouseMouseReleased、TransferList_Entry_CbtMouseMouseReleased、TransferList_Delete_CbtMouseMouseReleased、FTPSnapShot_Makera_CbtMouseMouseReleased、FTPSnapShot_Delete_CbtMouseMouseReleased、FTPSynchronize_CbtMouseMouseReleased」の private 修飾子を削除。
その他、「ctfHostUserName、ctfHostName、cpfHostPassword、ctfHostFolder、ctfLocalFolder、ctfHostPortNum、ctaMessage、cltHostFileList、cltLocalFileList、ccbFTPFileDataType、ctpFileListTabs、cckHostPASVMode、ccbHostEncode、cpnFTPSetting、ctpBaseTabs、cltHostTransferList、cltLocalTransferList、ctpTransferListTabs」変数の private 修飾子を削除(Button など Component を直にイジる必要がなければ private 修飾子を削除しなくても良い)。
『FTPConnect.java』
import java.awt.Dimension;
//Event を使う場合は、その Event に対応する「〜Adapter、〜Event」を import しなければならない。
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter;
import java.net.SocketException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.DefaultListModel;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
@SuppressWarnings("serial")
public class FTPConnect extends JApplet {
// volatile:最適化の抑制.
private static volatile FTPConnect oMainApp;
private static volatile boolean lApplication = false; // true; //
private static volatile MainAppFrameObj oMainAppFrame;
private volatile MainPanelImplementationObj oMainPanelImp;
private final String fvsSerialFile = "FTPConnect.sr";
private final String fvsSerialVersion = "1.1";
private final String fvsFTPSnapShotFile = ".FTPConnect.SnapShot";
private SimpleDateFormat oSDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
// private final String fvsPathListTag_Folder = ":+Folder:=";
private final String fvsPathListTag_Error = "*<Error>";
private final String fvsPathListTag_File = "-<File>";
private final String fvsReg_PathListTag_File = "\\-<File>";
private final String fvsPathListTag_Folder = "+<Directory>";
private final String fvsReg_PathListTag_Folder = "\\+<Directory>";
private final String fvsPathListTag_TimeStamp = " <TimeStamp>";
private final String fvsReg_PathListTag_TimeStamp = fvsPathListTag_TimeStamp;
private enum FTPTransfer_Enum { feFTPUpload, feFTPDownload, feFTPSnapShot_Makera, feFTPSnapShot_Delete, feFTPSynchronize, };
private volatile Thread oThread_FTPTransfer;
private volatile Thread oThread_FTPDownload;
private volatile Thread oThread_FTPUpload;
private volatile Thread oThread_FTPSnapShot_Makera;
private volatile Thread oThread_FTPSnapShot_Delete;
private volatile Thread oThread_FTPSynchronize;
private volatile Matcher matcher;
// Pattern pattern;
// Transfer // Connect
private volatile boolean lFTPConnection = false; // true; //
private volatile boolean lFTPBreak = false; // true; //
private volatile boolean lFTPThread = false; // true; //
private volatile FTPClient client;
// Binary転送Modeを利用?(true=Yes、false=No)
// TransferFileDataType
private static volatile boolean lFTPTransfer_Binary = false; // true; //
// PASV Modeを利用?(true=Yes、false=No)
private static volatile boolean lFTPPassiveMode = true; // false; //
private static final String fvsFTPTransfer_Binary = "Binary";
// 連想配列
private volatile HashMap<String,String> da1CharEncodeSets;
private volatile String vsHostEncode;
private volatile String vsLocalEncode;
private volatile String vsHostName;
private volatile String vsHostPortNum;
private volatile int iHostPortNum;
private volatile String vsHostUserName;
private volatile String vsHostPassword;
private volatile String vsHostCurrent;
private volatile String vsHostFolder;
private volatile String vsLocalCurrent;
private volatile String vsLocalFolder;
public static void main(String[] args) {
oMainApp = new FTPConnect( );
lApplication = true; // false;
oMainAppFrame =
new MainAppFrameObj( );
oMainAppFrame.oAppThread.start();
try{
oMainAppFrame.oAppThread.join();
}
catch(InterruptedException e){ }
// oMainAppFrame.oAppThread = null;
System.exit(0);
}
public void AppRepaint() {
System.out.println("AppRepaint( );");
repaint();
}
public void init() {
System.out.println("init( );");
oMainApp = this;
oMainPanelImp = new MainPanelImplementationObj();
Read( );
getContentPane().add(oMainPanelImp,"Center");
oMainPanelImp.setVisible(true);
if( oMainAppFrame!=null ){
System.out.println("if(lApplication)");
oMainAppFrame.setPreSize(oMainPanelImp.getSize( ));
System.out.println("MainPanelWidth="+oMainPanelImp.getSize( ).getWidth());
System.out.println("MainPanelHeight="+oMainPanelImp.getSize( ).getHeight());
}
System.out.println("Hello, World!");
// UTF8, Windows, EUC-JP, ASCII
da1CharEncodeSets = new HashMap<String, String>(){
{
put("UTF-8", "utf-8");
put("Windows", "MS932"); // Microsoft Windows CodePage 932
// ↑厳密に言うと Windows は「shift_jis」と完全な互換ではない.
// 今までスタンダードな表記法は「CP932」だったが、
// 「commons-net-3.3」では「MS932」でないとエラーになるようだ.
put("EUC-JP", "EUC-JP"); //
put("ASCII", "ISO-8859-1"); //
}
};
}
public void start(){
System.out.println("start( );");
repaint();
}
public void stop(){
System.out.println("stop( );");
}
public void destroy(){
System.out.println("destroy( );");
Write( );
}
public void Write( ) {
String vsProcessName = "Write";
System.out.println(vsProcessName+"( ).");
try {
int iListSize;
ObjectOutputStream oOOSSerial = new ObjectOutputStream(new FileOutputStream(fvsSerialFile));
oOOSSerial.writeObject(fvsSerialVersion);
oOOSSerial.writeBoolean(oMainPanelImp.cckHostPASVMode.isSelected( ));
oOOSSerial.writeObject(oMainPanelImp.ccbHostEncode.getSelectedObjects( ));
oOOSSerial.writeObject(oMainPanelImp.ctfHostName.getText( ));
oOOSSerial.writeObject(oMainPanelImp.ctfHostPortNum.getText( ));
oOOSSerial.writeObject(oMainPanelImp.ctfHostUserName.getText( ));
oOOSSerial.writeObject(new String(oMainPanelImp.cpfHostPassword.getPassword( )));
oOOSSerial.writeObject(oMainPanelImp.ccbFTPFileDataType.getSelectedObjects( ));
oOOSSerial.writeObject(oMainPanelImp.ctfLocalFolder.getText( ));
oOOSSerial.writeObject(oMainPanelImp.ctfHostFolder.getText( ));
iListSize = ((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).getSize( );
oOOSSerial.writeInt(iListSize );
for(int i=0; i<iListSize; i++ ){
oOOSSerial.writeObject(
((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).getElementAt(i));
}
iListSize = ((DefaultListModel)oMainPanelImp.cltLocalTransferList.getModel( )).getSize( );
oOOSSerial.writeInt(iListSize );
for(int i=0; i<iListSize; i++ ){
oOOSSerial.writeObject(
((DefaultListModel)oMainPanelImp.cltLocalTransferList.getModel( )).getElementAt(i));
}
oOOSSerial.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public void Read() {
String vsProcessName = "Read";
System.out.println(vsProcessName+"( ).");
try {
ObjectInputStream oOISSerial = new ObjectInputStream(new FileInputStream(fvsSerialFile));
String vsVersion = (String)oOISSerial.readObject( );
if( 0==fvsSerialVersion.compareTo("") ){
// Non-Operation
}else if( fvsSerialVersion.compareTo(vsVersion)!=0){
System.out.println("Error:SerialVersion.");
PutMessage("Error:SerialVersion.\n");
}else{
int iListSize;
oMainPanelImp.cckHostPASVMode.setSelected(oOISSerial.readBoolean( ));
oMainPanelImp.ccbHostEncode.setSelectedItem(oOISSerial.readObject( ));
oMainPanelImp.ctfHostName.setText((String)oOISSerial.readObject( ));
oMainPanelImp.ctfHostPortNum.setText((String)oOISSerial.readObject( ));
oMainPanelImp.ctfHostUserName.setText((String)oOISSerial.readObject( ));
oMainPanelImp.cpfHostPassword.setText((String)oOISSerial.readObject( ));
oMainPanelImp.ccbFTPFileDataType.setSelectedItem(oOISSerial.readObject( ));
oMainPanelImp.ctfLocalFolder.setText((String)oOISSerial.readObject( ));
oMainPanelImp.ctfHostFolder.setText((String)oOISSerial.readObject( ));
iListSize = oOISSerial.readInt( );
for(int i=0; i<iListSize; i++ ){
((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).addElement(
oOISSerial.readObject( ));
}
iListSize = oOISSerial.readInt( );
for(int i=0; i<iListSize; i++ ){
((DefaultListModel)oMainPanelImp.cltLocalTransferList.getModel( )).addElement(
oOISSerial.readObject( ));
}
oOISSerial.close( );
}
} catch (FileNotFoundException e) {
// e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
// PutMessage("FileNotFoundException:"+vsProcessName+".\n");
// PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.out.println("ClassNotFoundException:"+vsProcessName+".");
PutMessage("ClassNotFoundException:"+vsProcessName+".\n");
}
}
public void PutMessage(String vsMsg){
String vsProcessName = "PutMessage";
// JScrollPane には暗黙の子 JViewport が存在するようだ。
// つまり、この場合の ctaMessage の親は JViewport になり、
// JList の親の親が JScrollPane となる。
JScrollPane oTabSelectedComponent = (JScrollPane)(oMainPanelImp.ctaMessage.getParent( ).getParent( ));
oMainPanelImp.ctpBaseTabs.setSelectedComponent(oTabSelectedComponent);
oMainPanelImp.ctaMessage.append(vsMsg);
}
public void FTPLogin( ) {
String vsProcessName = "FTPLogin";
System.out.println(vsProcessName+"( ).");
oMainPanelImp.ctaMessage.setText("");
PutMessage("FTPLogin.\n");
lFTPPassiveMode = oMainPanelImp.cckHostPASVMode.isSelected( );
vsHostEncode =
da1CharEncodeSets.get((String)oMainPanelImp.ccbHostEncode.getSelectedItem());
Pattern pattern = Pattern.compile("( |\n)$");
vsHostName = oMainPanelImp.ctfHostName.getText();
matcher = pattern.matcher(vsHostName);
vsHostName = matcher.replaceAll("");
vsHostPortNum = oMainPanelImp.ctfHostPortNum.getText( );
matcher = pattern.matcher(vsHostPortNum);
vsHostPortNum = matcher.replaceAll("");
if(vsHostPortNum.isEmpty( )){ vsHostPortNum = "0"; }
iHostPortNum = Integer.parseInt(vsHostPortNum);
vsHostUserName = oMainPanelImp.ctfHostUserName.getText();
matcher = pattern.matcher(vsHostUserName);
vsHostUserName = matcher.replaceAll("");
vsHostPassword = String.valueOf(oMainPanelImp.cpfHostPassword.getPassword( ));
matcher = pattern.matcher(vsHostPassword);
vsHostPassword = matcher.replaceAll("");
try {
client = new FTPClient();
String vsEncode = client.getControlEncoding();
System.out.println("vsEncode="+vsEncode+"; ");
System.out.println(
"vsHostEncode="+vsHostEncode+"; "+
"vsHostName="+vsHostName+"; "+
"iHostPortNum="+iHostPortNum+"; "+
"vsHostUserName="+vsHostUserName+"; "+
"vsHostPassword="+vsHostPassword+"; "+
"");
client.setControlEncoding(vsHostEncode);
// ↑ Host 側のキャラクター・セットを設定してやれば良いようだ.
System.out.println("Connect...");
client.connect(vsHostName, iHostPortNum);
System.out.println("Connected to Server:" + vsHostName + " on "+client.getRemotePort());
System.out.println(client.getReplyString());
client.login(vsHostUserName,vsHostPassword);
System.out.println(client.getReplyString());
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
if( ! FTPReply.isPositiveCompletion(client.getReplyCode( )) ){
lFTPConnection = true; // false; //
FTPLogout();
return;
}
if (lFTPPassiveMode) {
client.enterLocalPassiveMode();
System.out.println("PassiveMode = ON");
} else {
client.enterLocalActiveMode();
System.out.println("PassiveMode = OFF");
}
HostFileList(null, true); // lTabSelected : true; / false; //
LocalFileList(null, false); // lTabSelected : true; / false; //
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public void FTPLogout() {
String vsProcessName = "FTPLogout";
System.out.println(vsProcessName+"( ).");
PutMessage("FTPLogout.\n");
try {
lFTPConnection = false; // true; //
if( client!=null && client.isConnected( ) ){
client.disconnect( );
System.out.println("FTP Disconnect.");
PutMessage("FTP Disconnect.\n");
}
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public void HostFileList(String vsTargetFile, boolean lTabSelected){ // lTabSelected : true; / false; //
String vsProcessName = "HostFileList";
System.out.println(vsProcessName+"( ).");
if( client==null || ! client.isConnected( ) ){
PutMessage("Login されていません。\n");
return;
}
try {
((DefaultListModel)oMainPanelImp.cltHostFileList.getModel( )).removeAllElements( );
if( lTabSelected ){
// JScrollPane には暗黙の子 JViewport が存在するようだ。
// つまり、この場合の JList の親は JViewport になり、
// JList の親の親が JScrollPane となる。
JScrollPane oTabSelectedComponent = (JScrollPane)(oMainPanelImp.cltHostFileList.getParent( ).getParent( ));
oMainPanelImp.ctpFileListTabs.setSelectedComponent(oTabSelectedComponent);
}
Pattern pattern = Pattern.compile("( |\n)$");
vsHostCurrent = oMainPanelImp.ctfHostFolder.getText();
System.out.println("vsHostCurrent="+vsHostCurrent+"; ");
matcher = pattern.matcher(vsHostCurrent);
vsHostCurrent = matcher.replaceAll("");
System.out.println("vsHostCurrent="+vsHostCurrent+"; ");
System.out.println("vsTargetFile="+vsTargetFile+"; ");
if( null==vsTargetFile ){
vsTargetFile = "";
}
if( 0==vsTargetFile.compareTo("..") ){
System.out.println("if( 0==vsTargetFile.compareTo(..) )");
vsTargetFile = "";
client.changeToParentDirectory();
}else{
if( vsTargetFile.compareTo("")!=0 ){
vsHostCurrent = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+vsTargetFile;
}
// client.doCommand("CWD", vsHostCurrent);
client.changeWorkingDirectory(vsHostCurrent);
}
vsHostCurrent = client.printWorkingDirectory( );
oMainPanelImp.ctfHostFolder.setText(vsHostCurrent);
System.out.println("vsHostCurrent="+vsHostCurrent+"; ");
if( vsHostCurrent.compareTo("/")!=0 ){
((DefaultListModel)oMainPanelImp.cltHostFileList.getModel( )).addElement(
fvsPathListTag_Folder+"..");
}
String vsElement = "";
String[] d1vsHostFile = new String[client.listFiles().length];
HashMap<String, String> da1PathListSets = new HashMap<String, String>( );
int i = 0;
for (FTPFile oFTPFile : client.listFiles()) {
String vsTimeStamp = fvsPathListTag_TimeStamp+oSDateFormat.format(oFTPFile.getTimestamp().getTime());
String vsHostFile = oFTPFile.getName();
String vsHostPath = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+vsHostFile;
if( oFTPFile.isFile( ) ){
vsElement = fvsPathListTag_File;
}else if( oFTPFile.isDirectory( ) ){
vsElement = fvsPathListTag_Folder;
}
d1vsHostFile[i] = vsElement+vsHostFile;
da1PathListSets.put(d1vsHostFile[i], vsTimeStamp);
System.out.println(d1vsHostFile[i]);
System.out.println(vsTimeStamp);
i++;
}
FileSort(d1vsHostFile);
for ( i = 0; i<d1vsHostFile.length; ++i) {
((DefaultListModel)oMainPanelImp.cltHostFileList.getModel( )).addElement(
d1vsHostFile[i]);
String vsTimeStamp = da1PathListSets.get(d1vsHostFile[i]);
System.out.println(d1vsHostFile[i]);
System.out.println(vsTimeStamp);
char[] d1vcFileElement = d1vsHostFile[i].toCharArray();
System.out.print("Hex = ");
for(int j = 0; j<d1vcFileElement.length; j++){
int k = d1vcFileElement[j];
if( k<0 ){ k = 65536+k; }
// ↑2の補数の負の値を正の値に変換している.
System.out.print(Integer.toHexString(k)+"; ");
}
System.out.println("");
}
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public void LocalFileList(String vsTargetFile, boolean lTabSelected){ // lTabSelected : true; / false; //
String vsProcessName = "LocalFileList";
System.out.println(vsProcessName+"( ).");
((DefaultListModel)oMainPanelImp.cltLocalFileList.getModel( )).removeAllElements( );
if( lTabSelected ){
// JScrollPane には暗黙の子 JViewport が存在するようだ。
// つまり、この場合の JList の親は JViewport になり、
// JList の親の親が JScrollPane となる。
JScrollPane oTabSelectedComponent = (JScrollPane)(oMainPanelImp.cltLocalFileList.getParent( ).getParent( ));
oMainPanelImp.ctpFileListTabs.setSelectedComponent(oTabSelectedComponent);
}
Pattern pattern = Pattern.compile("( |\n)$");
vsLocalCurrent = oMainPanelImp.ctfLocalFolder.getText();
matcher = pattern.matcher(vsLocalCurrent);
vsLocalCurrent = matcher.replaceAll("");
File oLocalCurrent = null;
System.out.println("vsTargetFile="+vsTargetFile+"; ");
try {
vsHostCurrent = "";
if( null==vsTargetFile ){
vsTargetFile = "";
}
oLocalCurrent = new File(vsLocalCurrent,vsTargetFile);
vsLocalCurrent = oLocalCurrent.getCanonicalPath( );
if( 0==vsTargetFile.compareTo("..") ){
System.out.println("if( 0==vsTargetFile.compareTo(..) )");
vsTargetFile = "";
}
oMainPanelImp.ctfLocalFolder.setText(vsLocalCurrent);
System.out.println("vsLocalCurrent="+vsLocalCurrent+"; ");
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
oLocalCurrent = null;
}
if( oLocalCurrent!=null && oLocalCurrent.isDirectory( ) ){
pattern = Pattern.compile("^?(.:)(/|\\\\)$");
// ↑この「\\\\」は内部的に「\\」の文字列となり、
// 正規表現では「\」の文字と解釈される.
matcher = pattern.matcher(vsLocalCurrent);
System.out.println("pattern = Pattern.compile(^?(.:)(/|\\\\)$)");
if( ! matcher.find( ) ){
System.out.println("if( matcher.find( ) )");
// vsLocalCurrent = matcher.replaceAll("");
((DefaultListModel)oMainPanelImp.cltLocalFileList.getModel( )).addElement(
fvsPathListTag_Folder+"..");
}
String[] d1vsLocalFile = new String[oLocalCurrent.listFiles().length];
File oLocalPath;
String vsLocalFile;
String vsLocalPath;
String vsElement = "";
int i = 0;
for (File oFile : oLocalCurrent.listFiles( )) {
vsLocalFile = oFile.getName();
// vsLocalPath = vsLocalCurrent+(vsLocalCurrent.endsWith("/") ? "" : "/")+vsLocalFile;
try {
oLocalPath = new File(vsLocalCurrent,vsLocalFile);
vsLocalPath = oLocalPath.getCanonicalPath( );
if( 0==vsLocalFile.compareTo("..") ){
System.out.println("if( 0==vsLocalFile.compareTo(..) )");
vsLocalFile = "";
}
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
if(oFile.isFile()){
vsElement = fvsPathListTag_File;
}else if(oFile.isDirectory( )){
vsElement = fvsPathListTag_Folder;
}
d1vsLocalFile[i] = vsElement+vsLocalFile;
i++;
}
FileSort(d1vsLocalFile);
for ( i = 0; i<d1vsLocalFile.length; ++i) {
((DefaultListModel)oMainPanelImp.cltLocalFileList.getModel( )).addElement(
d1vsLocalFile[i]);
System.out.println(d1vsLocalFile[i]);
char[] d1vcFileElement = d1vsLocalFile[i].toCharArray( );
System.out.print("Hex = ");
for(int j = 0; j<d1vcFileElement.length; j++){
int k = d1vcFileElement[j];
if( k<0 ){ k = 65536+k; }
// ↑2の補数の負の値を正の値に変換している.
System.out.print(Integer.toHexString(k)+"; ");
}
System.out.println("");
}
}
}
public void FileSort(String[] d1vsFile){
String vsProcessName = "FileSort";
System.out.println(vsProcessName+"( ).");
Arrays.sort(d1vsFile, new Comparator<String>() {
@Override
public int compare(String vs0, String vs1) {
// このソートを Windows 的な File 名のソート順にカスタマイズしている.
String vs, vsAscTab = new String(Character.toChars(0x09));
vs = vs0;
vs0 = vs.toUpperCase( )+vsAscTab+vs;
vs = vs1;
vs1 = vs.toUpperCase( )+vsAscTab+vs;
return vs0.compareTo(vs1);
}
});
}
public void FTPTransfer( FTPTransfer_Enum eFTPTransfer ){
String vsProcessName = "FTPDownloadTransfer";
System.out.println(vsProcessName+"( ).");
if( client==null || ! client.isConnected( ) ){
PutMessage("Login されていません。\n");
return;
}
String vsSaveBuf_HostFolder, vsSaveBuf_LocalFolder;
String vsHostPath, vsLocalPath;
vsSaveBuf_HostFolder = oMainPanelImp.ctfHostFolder.getText( );
vsSaveBuf_LocalFolder = oMainPanelImp.ctfLocalFolder.getText( );
int iListSize = ((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).getSize( );
for(int i = 0; i<iListSize; i++){
oMainPanelImp.ctfHostFolder.setText( (String)
((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).getElementAt(i));
oMainPanelImp.ctfLocalFolder.setText( (String)
((DefaultListModel)oMainPanelImp.cltLocalTransferList.getModel( )).getElementAt(i));
System.out.println(
"oMainPanelImp.ctfHostFolder.getText="+oMainPanelImp.ctfHostFolder.getText()+"; "+
"oMainPanelImp.ctfHostFolder.getText="+oMainPanelImp.ctfLocalFolder.getText()+"; "+
"");
switch (eFTPTransfer) {
case feFTPUpload :{
FTPUpload( );
} break;
case feFTPDownload :{
FTPDownload( );
} break;
case feFTPSnapShot_Makera :{
FTPSnapShot(true); // lMakera : true; / false;
} break;
case feFTPSnapShot_Delete :{
FTPSnapShot(false); // lMakera : true; / false;
} break;
case feFTPSynchronize :{
FTPSynchronize( );
} break;
default:{
//
} break;
};
}
oMainPanelImp.ctfHostFolder.setText(vsSaveBuf_HostFolder);
oMainPanelImp.ctfLocalFolder.setText(vsSaveBuf_LocalFolder);
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
}
public void FTPDownload( ){
String vsProcessName = "FTPDownload";
System.out.println(vsProcessName+"( ).");
if( client==null || ! client.isConnected( ) ){
PutMessage("Login されていません。\n");
return;
}
matcher = null;
Pattern pattern = null;
String vsTargetFile = null;
String vsHostPath = null;
pattern = Pattern.compile("( |\n)$");
vsHostCurrent = oMainPanelImp.ctfHostFolder.getText();
matcher = pattern.matcher(vsHostCurrent);
vsHostCurrent = matcher.replaceAll("");
vsLocalCurrent = oMainPanelImp.ctfLocalFolder.getText();
matcher = pattern.matcher(vsLocalCurrent);
vsLocalCurrent = matcher.replaceAll("");
String vsLocalPath = vsLocalCurrent;
if( ! oMainPanelImp.cltHostFileList.isSelectionEmpty() ){
vsTargetFile = (String)oMainPanelImp.cltHostFileList.getSelectedValue();
pattern = Pattern.compile("^"+fvsPathListTag_File);
matcher = pattern.matcher(vsTargetFile);
vsTargetFile = matcher.replaceAll("");
pattern = Pattern.compile("^"+fvsPathListTag_Folder);
matcher = pattern.matcher(vsTargetFile);
vsTargetFile = matcher.replaceAll("");
if(matcher.find()){
System.out.println("if(matcher.find( ))");
vsHostPath = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+vsTargetFile;
vsTargetFile = "";
}
}else{
vsTargetFile = "";
}
if( vsTargetFile!=null ){
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"vsHostPath="+vsHostPath+"; "+
"vsLocalPatht="+vsLocalPath+"; "+
"");
FTPDownloadFolder( vsTargetFile, vsHostCurrent, vsLocalCurrent );
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
// client.changeWorkingDirectory(vsHostCurrent);
}
LocalFileList(null, true); // lTabSelected : true; / false; //
}
public void FTPDownloadFolder( String vsTargetFile, String vsHostCurrent, String vsLocalCurrent ){
String vsProcessName = "FTPDownloadFolder";
System.out.println(vsProcessName+"( ).");
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"");
if( vsTargetFile!=null && 0!=vsTargetFile.compareTo("") ){
FTPDownloadFile( vsTargetFile, vsHostCurrent, vsLocalCurrent, -1);
}else{
String vsHostPrevious = "";
String vsHostPath = null;
Body : try {
vsHostPrevious = client.printWorkingDirectory( );
System.out.println("vsHostPrevious="+vsHostPrevious+"; ");
client.changeWorkingDirectory(vsHostCurrent);
if( lFTPBreak ){
break Body;
}
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
// FTPFile[] d1oFTPFile = client.listFiles();
File oLocalPath;
for (FTPFile oFTPFile : client.listFiles()) {
if( lFTPBreak ){
break Body;
}
System.out.println("lFTPBreak="+lFTPBreak+"; ");
String vsHostFile = oFTPFile.getName();
if( oFTPFile.isFile( ) ){
FTPDownloadFile( vsHostFile, vsHostCurrent, vsLocalCurrent, -1);
}else if( oFTPFile.isDirectory( ) ){
String vsLocalPath = vsLocalCurrent;
vsHostPath = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+vsHostFile;
// vsLocalPath = vsLocalPath+(vsLocalPath.endsWith("/") ? "" : "/")+vsHostFile;
oLocalPath = new File(vsLocalCurrent,vsHostFile);
vsLocalPath = oLocalPath.getCanonicalPath( );
if( 0==vsHostFile.compareTo("..") ){
System.out.println("if( 0==vsHostFile.compareTo(..) )");
vsHostFile = "";
}
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"vsHostPath="+vsHostPath+"; "+
"vsLocalPath="+vsLocalPath+"; "+
"");
oLocalPath = new File(vsLocalPath);
if( ! oLocalPath.exists( ) ){
oLocalPath.mkdir();
}
FTPDownloadFolder( "", vsHostPath, vsLocalPath );
// client.changeWorkingDirectory(vsHostCurrent);
}
}
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
try {
Pattern pattern = Pattern.compile("^/");
matcher = pattern.matcher(vsHostPrevious);
if( matcher.find( ) ){
client.changeWorkingDirectory(vsHostPrevious);
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
}
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
}
public void FTPDownloadFile(String vsTargetFile,String vsHostCurrent,String vsLocalCurrent, int iFTPTransferMode){
String vsProcessName = "FTPDownloadFile";
System.out.println(vsProcessName+"( ).");
File oLocalPath;
String vsHostPrevious = "";
String vsMsg;
String vsLocalPath = null;
String vsHostPath = null;
try{
vsHostPrevious = client.printWorkingDirectory( );
System.out.println("vsHostPrevious="+vsHostPrevious+"; ");
vsLocalPath = vsLocalCurrent;
if( 0==vsLocalPath.compareTo("") ){
vsLocalPath = ".";
}
vsHostPath = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+vsTargetFile;
// vsLocalPath = vsLocalPath+(vsLocalPath.endsWith("/") ? "" : "/")+vsTargetFile;
oLocalPath = new File(vsLocalPath,vsTargetFile);
// ↑「File( )」コンストラクターの第1引数がブランクだとルートになってしまうようだ。
// カレントにしたい場合は第1引数に明示的に"."(ピリオッド)を指定しなければならないようだ。
vsLocalPath = oLocalPath.getCanonicalPath( );
if( 0==vsTargetFile.compareTo("..") ){
System.out.println("if( 0==vsTargetFile.compareTo(..) )");
vsTargetFile = "";
}
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"vsHostPath="+vsHostPath+"; "+
"vsLocalPath="+vsLocalPath+"; "+
"");
lFTPTransfer_Binary = false; // true; //
if( 0==fvsFTPTransfer_Binary.compareTo(
(String)oMainPanelImp.ccbFTPFileDataType.getSelectedItem( )) ){
lFTPTransfer_Binary = true; // false; //
}
if( FTP.BINARY_FILE_TYPE==iFTPTransferMode ||
FTP.ASCII_FILE_TYPE==iFTPTransferMode ){
client.setFileType(iFTPTransferMode);
}else if(lFTPTransfer_Binary){
client.setFileType(FTP.BINARY_FILE_TYPE);
System.out.println("Transfer:Binary.");
}else{
client.setFileType(FTP.ASCII_FILE_TYPE);
System.out.println("Transfer:ASCII.");
}
// FTP Download.
PutMessage("HostPath="+vsHostPath+"; "+"\n");
PutMessage("LocalPath="+vsLocalPath+"; "+"\n");
FileOutputStream oFOS = null;
oFOS = new FileOutputStream(vsLocalPath);
client.retrieveFile(vsHostPath, oFOS);
oFOS.close();
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public void FTPUpload( ){
String vsProcessName = "FTPUpload";
System.out.println(vsProcessName+"( ).");
if( client==null || ! client.isConnected( ) ){
PutMessage("Login されていません。\n");
return;
}
matcher = null;
Pattern pattern = null;
String vsTargetFile = null;
String vsHostPath = null;
pattern = Pattern.compile("( |\n)$");
vsHostCurrent = oMainPanelImp.ctfHostFolder.getText();
matcher = pattern.matcher(vsHostCurrent);
vsHostCurrent = matcher.replaceAll("");
vsLocalCurrent = oMainPanelImp.ctfLocalFolder.getText();
matcher = pattern.matcher(vsLocalCurrent);
vsLocalCurrent = matcher.replaceAll("");
String vsLocalPath = vsLocalCurrent;
try {
File oLocalCurrent;
File oLocalPath = new File(vsLocalPath);
if( oLocalPath.isFile( ) ){
vsTargetFile = oLocalPath.getName( );
vsLocalCurrent = oLocalPath.getParent( );
oLocalCurrent = new File(vsLocalCurrent);
vsLocalCurrent = oLocalCurrent.getCanonicalPath();
}else if( ! oMainPanelImp.cltLocalFileList.isSelectionEmpty() ){
vsTargetFile = (String)oMainPanelImp.cltLocalFileList.getSelectedValue();
pattern = Pattern.compile("^"+fvsPathListTag_File);
matcher = pattern.matcher(vsTargetFile);
vsTargetFile = matcher.replaceAll("");
pattern = Pattern.compile("^"+fvsPathListTag_Folder);
matcher = pattern.matcher(vsTargetFile);
vsTargetFile = matcher.replaceAll("");
if(matcher.find()){
System.out.println("if(matcher.find( ))");
// vsLocalPath = vsLocalCurrent+(vsLocalCurrent.endsWith("/") ? "" : "/")+vsTargetFile;
oLocalPath = new File(vsLocalCurrent,vsTargetFile);
vsLocalPath = oLocalPath.getCanonicalPath( );
if( 0==vsTargetFile.compareTo("..") ){
System.out.println("if( 0==vsTargetFile.compareTo(..) )");
// vsTargetFile = "";
}
vsTargetFile = "";
}
}else{
vsTargetFile = "";
}
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
vsTargetFile = null;
}
if( vsTargetFile!=null ){
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"vsHostPath="+vsHostPath+"; "+
"vsLocalPatht="+vsLocalPath+"; "+
"");
FTPUploadFolder( vsTargetFile, vsHostCurrent, vsLocalCurrent );
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
// client.changeWorkingDirectory(vsHostCurrent);
}
HostFileList(null, true); // lTabSelected : true; / false; //
}
public void FTPUploadFolder( String vsTargetFile, String vsHostCurrent, String vsLocalCurrent ){
String vsProcessName = "FTPUploadFolder";
System.out.println(vsProcessName+"( ).");
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"");
if( vsTargetFile!=null && 0!=vsTargetFile.compareTo("") ){
FTPUploadFile( vsTargetFile, vsHostCurrent, vsLocalCurrent, -1);
}else{
String vsHostPrevious = "";
String vsHostPath = null;
Body : try {
vsHostPrevious = client.printWorkingDirectory( );
System.out.println("vsHostPrevious="+vsHostPrevious+"; ");
if( lFTPBreak ){
break Body;
}
File oLocalCurrent = new File(vsLocalCurrent);
File oLocalPath;
System.out.println("oLocalCurrent = new File(vsLocalCurrent)");
for (File oFile : oLocalCurrent.listFiles()) {
if( lFTPBreak ){
break Body;
}
System.out.println("lFTPBreak="+lFTPBreak+"; ");
String vsLocalFile = oFile.getName();
if( oFile.isFile( ) ){
FTPUploadFile( vsLocalFile, vsHostCurrent, vsLocalCurrent, -1);
}else if( oFile.isDirectory( ) ){
String vsLocalPath = vsLocalCurrent;
vsHostPath = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+vsLocalFile;
// vsLocalPath = vsLocalPath+(vsLocalPath.endsWith("/") ? "" : "/")+vsLocalFile;
oLocalPath = new File(vsLocalCurrent,vsLocalFile);
vsLocalPath = oLocalPath.getCanonicalPath( );
if( 0==vsLocalFile.compareTo("..") ){
System.out.println("if( 0==vsLocalFile.compareTo(..) )");
vsLocalFile = "";
}
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"vsHostPath="+vsHostPath+"; "+
"vsLocalPath="+vsLocalPath+"; "+
"");
try {
// client.changeWorkingDirectory(vsHostPath);
System.out.println("client.makeDirectory(vsHostPath).");
client.makeDirectory(vsHostPath);
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
FTPUploadFolder( "", vsHostPath, vsLocalPath );
// client.changeWorkingDirectory(vsHostCurrent);
}
}
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
try {
Pattern pattern = Pattern.compile("^/");
matcher = pattern.matcher(vsHostPrevious);
if( matcher.find( ) ){
client.changeWorkingDirectory(vsHostPrevious);
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
}
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
}
public void FTPUploadFile(String vsTargetFile,String vsHostCurrent,String vsLocalCurrent, int iFTPTransferMode){
String vsProcessName = "FTPUploadFile";
System.out.println(vsProcessName+"( ).");
String vsHostPrevious = "";
try{
vsHostPrevious = client.printWorkingDirectory( );
System.out.println("vsHostPrevious="+vsHostPrevious+"; ");
String vsMsg;
String vsLocalPath = null;
// String vsLocalAbsolute = null;
String vsHostPath = null;
FileInputStream oFIS = null;
File oLocalPath;
vsLocalPath = vsLocalCurrent;
if( 0==vsLocalPath.compareTo("") ){
vsLocalPath = ".";
}
vsHostPath = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+vsTargetFile;
// vsLocalPath = vsLocalPath+(vsLocalPath.endsWith("/") ? "" : "/")+vsTargetFile;
oLocalPath = new File(vsLocalPath,vsTargetFile);
// ↑「File( )」コンストラクターの第1引数がブランクだとルートになってしまうようだ。
// カレントにしたい場合は第1引数に明示的に"."(ピリオッド)を指定しなければならないようだ。
vsLocalPath = oLocalPath.getCanonicalPath( );
// vsLocalAbsolute = oLocalPath.getAbsolutePath( );
if( 0==vsTargetFile.compareTo("..") ){
System.out.println("if( 0==vsTargetFile.compareTo(..) )");
vsTargetFile = "";
}
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"vsHostPath="+vsHostPath+"; "+
"vsLocalPath="+vsLocalPath+"; "+
"");
lFTPTransfer_Binary = false; // true; //
if( 0==fvsFTPTransfer_Binary.compareTo(
(String)oMainPanelImp.ccbFTPFileDataType.getSelectedItem( )) ){
lFTPTransfer_Binary = true; // false; //
}
if( FTP.BINARY_FILE_TYPE==iFTPTransferMode ||
FTP.ASCII_FILE_TYPE==iFTPTransferMode ){
client.setFileType(iFTPTransferMode);
}else if(lFTPTransfer_Binary){
client.setFileType(FTP.BINARY_FILE_TYPE);
System.out.println("Transfer:Binary.");
}else{
client.setFileType(FTP.ASCII_FILE_TYPE);
System.out.println("Transfer:ASCII.");
}
// FTP Upload.
PutMessage("vsHostPath="+vsHostPath+";\n");
PutMessage("vsLocalPath="+vsLocalPath+";\n");
oFIS = new FileInputStream(vsLocalPath);
client.storeFile(vsHostPath, oFIS);
oFIS.close();
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public void FTPSnapShot(boolean lMakera){ // lMakera : true; / false;
String vsProcessName = "FTPSnapShot";
System.out.println(vsProcessName+"( ).");
vsHostCurrent = oMainPanelImp.ctfHostFolder.getText();
if(lMakera){
vsProcessName = vsProcessName+":Makera";
FTPSnapShotFolder_Makera(vsHostCurrent);
}else{
vsProcessName = vsProcessName+":Delete";
FTPSnapShotFolder_Delete(vsHostCurrent);
}
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
HostFileList(null, true); // lTabSelected : true; / false; //
}
public void FTPSnapShotFolder_Makera(String vsHostCurrent){
String vsProcessName = "FTPSnapShotFolder_Makera";
System.out.println(vsProcessName+"( ).");
System.out.println("vsHostCurrent="+vsHostCurrent+"; ");
if( client==null || ! client.isConnected( ) ){
PutMessage("Login されていません。\n");
return;
}
int i;
String vsElement = "";
String vsHostPrevious = "";
String vsHostPath = null;
String vsPathListTag;
String vsFTPSnapShotPath;
String vsHostFileInform;
String vsTimeStampInform;
Body : try {
vsHostPrevious = client.printWorkingDirectory( );
System.out.println("vsHostPrevious="+vsHostPrevious+"; ");
if( lFTPBreak ){
break Body;
}
client.changeWorkingDirectory(vsHostCurrent);
vsHostCurrent = client.printWorkingDirectory( );
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
System.out.println("vsHostCurrent="+vsHostCurrent+"; ");
HashMap<String, String[]> da1PathListSets = new HashMap<String, String[]>( );
String[] d1vsHostFile = new String[client.listFiles().length];
// FTPFile[] d1oHostFile = new FTPFile[client.listFiles().length];
String vsHostFile;
String vsTimeStamp;
i = 0;
for (FTPFile oFTPFile : client.listFiles( )) {
if( lFTPBreak ){
break Body;
}
vsHostFile = oFTPFile.getName();
System.out.println("vsHostFile="+vsHostFile+"; ");
// d1oHostFile[i] = null;
vsElement = "";
vsPathListTag = null;
vsTimeStamp = null;
if( 0!=fvsFTPSnapShotFile.compareTo(vsHostFile) ){
vsTimeStamp = oSDateFormat.format(oFTPFile.getTimestamp().getTime());
if( oFTPFile.isFile( ) ){
vsPathListTag = fvsPathListTag_File;
}else if( oFTPFile.isDirectory( ) ){
vsPathListTag = fvsPathListTag_Folder;
}
}
// d1oHostFile[i] = oFTPFile;
d1vsHostFile[i] = vsPathListTag+vsHostFile;
da1PathListSets.put(d1vsHostFile[i],
new String[]{vsPathListTag, vsHostFile, vsTimeStamp});
// System.out.println(vsElement);
System.out.println(
"i="+i+"; "+
"vsPathListTag="+vsPathListTag+"; "+
"d1vsHostFile[i]="+d1vsHostFile[i]+"; "+
"vsTimeStamp="+vsTimeStamp+"; "+
"");
i++;
}
FileSort(d1vsHostFile);
// client.setFileType(FTP.BINARY_FILE_TYPE);
// client.setFileType(FTP.ASCII_FILE_TYPE);
vsFTPSnapShotPath = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+fvsFTPSnapShotFile;
// OutputStream oOSFTPSnapShot = client.storeFileStream(vsFTPSnapShotPath);
// ↑「client.storeFileStream( )」による Stream で WorkingDirectory が null になってしまう場合があるようだ。
FileOutputStream oFOSFTPSnapShot = new FileOutputStream(fvsFTPSnapShotFile);
OutputStreamWriter oOSWFTPSnapShot = new OutputStreamWriter(oFOSFTPSnapShot);
BufferedWriter oBWFTPSnapShot = new BufferedWriter(oOSWFTPSnapShot);
// ArrayList<String[]> dl1oHostFile = new ArrayList<String[]>();
String[] d1svFileInform;
for (i = 0; i<d1vsHostFile.length; i++) {
if( lFTPBreak ){
break Body;
}
vsHostFileInform = d1vsHostFile[i];
d1svFileInform = da1PathListSets.get(vsHostFileInform);
vsPathListTag = d1svFileInform[0];
vsHostFile = d1svFileInform[1];
vsTimeStampInform = fvsPathListTag_TimeStamp+d1svFileInform[2];
System.out.println(
"vsHostFile="+vsHostFile+"; "+
"vsPathListTag="+vsPathListTag+"; "+
"vsTimeStampInform="+vsTimeStampInform+"; "+
"");
vsElement = "";
if( null!=vsPathListTag ){
vsElement = vsPathListTag;
oBWFTPSnapShot.write(vsHostFileInform+vsTimeStampInform);
oBWFTPSnapShot.newLine( );
System.out.println(vsHostFileInform+vsTimeStampInform);
}
}
oBWFTPSnapShot.close( );
// client.setFileType(FTP.BINARY_FILE_TYPE);
// client.setFileType(FTP.ASCII_FILE_TYPE);
FTPUploadFile(fvsFTPSnapShotFile, vsHostCurrent, "", FTP.ASCII_FILE_TYPE);
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
for (i = 0; i<d1vsHostFile.length; i++) {
if( lFTPBreak ){
break Body;
}
vsHostFileInform = d1vsHostFile[i];
d1svFileInform = da1PathListSets.get(vsHostFileInform);
vsPathListTag = d1svFileInform[0];
vsHostFile = d1svFileInform[1];
if( vsPathListTag!=null ){
if( 0==fvsPathListTag_File.compareTo(vsPathListTag) ){
//
}
if( 0==fvsPathListTag_Folder.compareTo(vsPathListTag) ){
System.out.println("vsHostFile="+vsHostFile+"; ");
FTPSnapShotFolder_Makera(vsHostFile);
}
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
try {
Pattern pattern = Pattern.compile("^/");
matcher = pattern.matcher(vsHostPrevious);
if( matcher.find( ) ){
client.changeWorkingDirectory(vsHostPrevious);
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
}
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public void FTPSnapShotFolder_Delete(String vsHostCurrent){
String vsProcessName = "FTPSnapShotFolder_Delete";
System.out.println(vsProcessName+"( ).");
System.out.println("vsHostCurrent="+vsHostCurrent+"; ");
if( client==null || ! client.isConnected( ) ){
PutMessage("Login されていません。\n");
return;
}
int i;
String vsElement = "";
String vsHostPrevious = "";
String vsHostPath = null;
try {
vsHostPrevious = client.printWorkingDirectory( );
System.out.println("vsHostPrevious="+vsHostPrevious+"; ");
client.changeWorkingDirectory(vsHostCurrent);
vsHostCurrent = client.printWorkingDirectory( );
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
PutMessage("Current="+vsHostCurrent+";\n");
client.deleteFile(fvsFTPSnapShotFile);
for (FTPFile oFTPFile : client.listFiles( )) {
String vsHostFile = oFTPFile.getName();
if( oFTPFile.isFile( ) ){
//
}else if( oFTPFile.isDirectory( ) ){
System.out.println("vsHostFile="+vsHostFile+"; ");
FTPSnapShotFolder_Delete(vsHostFile);
}
}
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
try {
Pattern pattern = Pattern.compile("^/");
matcher = pattern.matcher(vsHostPrevious);
if( matcher.find( ) ){
client.changeWorkingDirectory(vsHostPrevious);
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
}
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public void FTPSynchronize( ){
String vsProcessName = "FTPSynchronize";
System.out.println(vsProcessName+"( ).");
if( client==null || ! client.isConnected( ) ){
PutMessage("Login されていません。\n");
return;
}
Pattern pattern = Pattern.compile("( |\n)$");
vsHostCurrent = oMainPanelImp.ctfHostFolder.getText();
matcher = pattern.matcher(vsHostCurrent);
vsHostCurrent = matcher.replaceAll("");
vsLocalCurrent = oMainPanelImp.ctfLocalFolder.getText();
matcher = pattern.matcher(vsLocalCurrent);
vsLocalCurrent = matcher.replaceAll("");
FTPSynchronizeFolder( "", vsHostCurrent, vsLocalCurrent );
FTPSnapShot(true); // lMakera : true; / false;
HostFileList(null, false); // lTabSelected : true; / false; //
LocalFileList(null, false); // lTabSelected : true; / false; //
}
public void FTPSynchronizeFolder( String vsTargetFile, String vsHostCurrent, String vsLocalCurrent ){
String vsProcessName = "FTPSynchronizeFolder";
System.out.println(vsProcessName+"( ).");
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"");
int i;
String vsElement = "";
String vsFTPSnapShotLine = "";
String vsHostPrevious = "";
String vsHostPath = null;
String vsLocalPath = null;
// String vsTimeStamp;
String vsHostTimeStamp, vsLocalTimeStamp;
String vsSnapShotCurrent, vsSnapShotPath, vsSnapShotTimeStamp;
String vsHostFile = "";
String vsLocalFile = "";
String vsPathListTag;
String vsHostPathListTag = "";
String vsLocalPathListTag = "";
File oLocalPath;
boolean lFTPSnapShotFile = false; // true; //
Body : try {
vsHostPrevious = client.printWorkingDirectory( );
System.out.println(
"lFTPBreak="+lFTPBreak+"; "+
"vsHostPrevious="+vsHostPrevious+"; "+
"");
if( lFTPBreak ){
break Body;
}
if( 0!=vsTargetFile.compareTo("") ){
vsHostPath = vsHostCurrent+(vsHostCurrent.endsWith("/") ? "" : "/")+vsTargetFile;
// vsLocalPath = vsLocalCurrent+(vsLocalCurrent.endsWith("/") ? "" : "/")+vsTargetFile;
oLocalPath = new File(vsLocalCurrent, vsTargetFile);
vsLocalPath = oLocalPath.getCanonicalPath( );
if( 0==vsTargetFile.compareTo("..") ){
System.out.println("if( 0==vsTargetFile.compareTo(..) )");
vsTargetFile = "";
}
vsHostCurrent = vsHostPath;
vsLocalCurrent = vsLocalPath;
}
System.out.println(
"vsTargetFile="+vsTargetFile+"; "+
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"");
client.changeWorkingDirectory(vsHostCurrent);
vsHostCurrent = client.printWorkingDirectory( );
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
PutMessage("HostCurrent="+vsHostCurrent+";\n");
PutMessage("LocalCurrent="+vsLocalCurrent+";\n");
System.out.println("◆client.listFiles( )");
// HashMap<String, String> da1SnapShotSets = new HashMap<String, String>( );
// HashMap<String, String> da1HostPathListSets = new HashMap<String, String>( );
HashMap<String, String[]> da1FileListSets = new HashMap<String, String[]>( );
String[] d1vsHostFile = new String[client.listFiles().length];
FTPFile[] d1oHostFile = new FTPFile[client.listFiles().length];
i = 0;
for (FTPFile oFTPFile : client.listFiles( )) {
if( lFTPBreak ){
break Body;
}
System.out.println("lFTPBreak="+lFTPBreak+"; ");
vsHostTimeStamp = oSDateFormat.format(oFTPFile.getTimestamp( ).getTime( ));
vsHostFile = oFTPFile.getName( );
// System.out.println("vsHostFile="+vsHostFile+"; ");
d1oHostFile[i] = null;
vsLocalPath = null;
vsHostPathListTag = null;
vsLocalPathListTag = null;
vsElement = "";
if( oFTPFile.isFile( ) ){
vsElement = fvsPathListTag_File;
vsHostPathListTag = fvsPathListTag_File;
da1FileListSets.put(vsHostFile,
new String[]{fvsPathListTag_File, null, vsHostTimeStamp, null});
}else if( oFTPFile.isDirectory( ) ){
vsElement = fvsPathListTag_Folder;
vsHostPathListTag = fvsPathListTag_Folder;
da1FileListSets.put(vsHostFile,
new String[]{fvsPathListTag_Folder, null, vsHostTimeStamp, null});
// vsLocalPath = vsLocalCurrent+(vsLocalCurrent.endsWith("/") ? "" : "/")+vsHostFile;
oLocalPath = new File(vsLocalCurrent,vsHostFile);
vsLocalPath = oLocalPath.getCanonicalPath( );
if( 0==vsHostFile.compareTo("..") ){
System.out.println("if( 0==vsHostFile.compareTo(..) )");
vsHostFile = "";
}
// oLocalPath = new File(vsLocalPath);
if( ! oLocalPath.exists( ) ){
oLocalPath.mkdir();
}
}
d1oHostFile[i] = oFTPFile;
d1vsHostFile[i] = vsHostFile;
vsElement = vsElement+vsHostFile;
System.out.println(
"vsHostPathListTag="+vsHostPathListTag+"; "+
"vsHostFile="+vsHostFile+"; "+
"vsHostTimeStamp="+vsHostTimeStamp+"; "+
"vsElement="+vsElement+"; "+
"");
i++;
}
// String[] d1vsSnapShotFile = new String[d1oHostFile[i].length];
// HashMap<String, String> da1SnapShotSets = new HashMap<String, String>( );
// ArrayList<String> dl1vsSnapShotFile = new ArrayList<String>( );
// ArrayList<String> dl1vsSnapShotTimeStamp = new ArrayList<String>( );
String[] d1svFileInform;
System.out.println("◆BufferedReader oBRFTPSnapShot");
if( null!=da1FileListSets.get(fvsFTPSnapShotFile) ){
// 「client.retrieveFileStream( )」による Stream で WorkingDirectory が null になってしまう場合があるようだ。
// client.setFileType(FTP.BINARY_FILE_TYPE);
// client.setFileType(FTP.ASCII_FILE_TYPE);
FTPDownloadFile( fvsFTPSnapShotFile, vsHostCurrent, "", FTP.ASCII_FILE_TYPE );
System.out.println(
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"");
FileInputStream oFISFTPSnapShot = new FileInputStream(fvsFTPSnapShotFile);
InputStreamReader oISRFTPSnapShot = new InputStreamReader(oFISFTPSnapShot);
BufferedReader oBRFTPSnapShot = new BufferedReader(oISRFTPSnapShot);
Pattern pattern = Pattern.compile(fvsReg_PathListTag_File+"(.*)"+fvsReg_PathListTag_TimeStamp+"(.*)$");
vsFTPSnapShotLine = "";
i = 0;
while(true){
if( lFTPBreak ){
break Body;
}
System.out.println("lFTPBreak="+lFTPBreak+"; ");
vsFTPSnapShotLine = oBRFTPSnapShot.readLine( );
if( null==vsFTPSnapShotLine ){
break;
}
matcher = pattern.matcher(vsFTPSnapShotLine);
if( matcher.find( ) ){
vsSnapShotPath = matcher.group(1);
vsSnapShotTimeStamp = matcher.group(2);
d1svFileInform = da1FileListSets.get(vsSnapShotPath);
vsHostPathListTag = d1svFileInform[0];
vsHostTimeStamp = d1svFileInform[2];
System.out.println(
"i="+i+"; "+
"vsHostPathListTag="+vsHostPathListTag+"; "+
"vsSnapShotPath="+vsSnapShotPath+"; "+
"vsHostTimeStamp="+vsHostTimeStamp+"; "+
"");
if( 0==fvsPathListTag_File.compareTo(vsHostPathListTag) &&
0==vsSnapShotTimeStamp.compareTo(vsHostTimeStamp) ){
d1svFileInform[1] = vsSnapShotTimeStamp;
d1svFileInform[2] = null;
da1FileListSets.put(vsSnapShotPath, d1svFileInform);
System.out.println(
"vsSnapShotTimeStamp="+vsSnapShotTimeStamp+"; "+
"");
}
// dl1vsSnapShotFile.add(vsSnapShotPath);
// d1svFileInform = da1FileListSets.get(matcher.group(1));
// da1SnapShotSets.put(matcher.group(1), matcher.group(2));
i++;
}
}
oBRFTPSnapShot.close( );
}
System.out.println("vsHostCurrent="+vsHostCurrent+"; ");
client.changeWorkingDirectory(vsHostCurrent);
System.out.println("client.printWorkingDirectory="+client.printWorkingDirectory( )+"; ");
System.out.println("◆oLocalCurrent.listFiles( )");
// File[] d1oLocalFile = new File[oLocalCurrent.listFiles().length];
File oLocalCurrent = new File(vsLocalCurrent);
vsHostPathListTag = "";
vsLocalPathListTag = "";
vsLocalTimeStamp = "";
i = 0;
vsLocalTimeStamp = "";
i = 0;
for (File oFile : oLocalCurrent.listFiles( )) {
if( lFTPBreak ){
break Body;
}
vsLocalTimeStamp = oSDateFormat.format(oFile.lastModified( ));
vsLocalFile = oFile.getName( );
System.out.println(
"lFTPBreak="+lFTPBreak+"; "+
"vsLocalFile="+vsLocalFile+"; "+
"vsLocalTimeStamp="+vsLocalTimeStamp+"; "+
"");
vsLocalPathListTag = fvsPathListTag_File;
d1svFileInform = da1FileListSets.get(vsLocalFile);
vsPathListTag = null;
vsSnapShotTimeStamp = null;
vsHostTimeStamp = null;
if(null!=d1svFileInform){
vsPathListTag = d1svFileInform[0];
vsSnapShotTimeStamp = d1svFileInform[1];
vsHostTimeStamp = d1svFileInform[2];
}
System.out.println(
"d1svFileInform="+d1svFileInform+"; "+
"vsPathListTag="+vsPathListTag+"; "+
"vsLocalFile="+vsLocalFile+"; "+
"vsSnapShotTimeStamp="+vsSnapShotTimeStamp+"; "+
"vsHostTimeStamp="+vsHostTimeStamp+"; "+
"");
vsElement = "";
if( oFile.isFile( ) ){
vsLocalPathListTag = fvsPathListTag_File;
}
if( oFile.isDirectory( ) ){
vsLocalPathListTag = fvsPathListTag_Folder;
}
if( null==vsPathListTag ){
vsPathListTag = vsLocalPathListTag;
}
if( 0!=vsLocalPathListTag.compareTo(vsPathListTag) ){
PutMessage(vsProcessName+":Error.\n");
PutMessage("PathListTag="+vsPathListTag+"\n");
PutMessage("LocalPathListTag="+vsLocalPathListTag+"\n");
PutMessage("HostCurrent="+vsHostCurrent+"\n");
PutMessage("LocalCurrent="+vsLocalCurrent+"\n");
PutMessage("LocalFile="+vsLocalFile+"\n");
vsPathListTag = fvsPathListTag_Error;
}
da1FileListSets.put(vsLocalFile,
new String[]{vsPathListTag, vsSnapShotTimeStamp, vsHostTimeStamp, vsLocalTimeStamp});
if( 0==fvsPathListTag_Folder.compareTo(vsPathListTag) ){
if( null==vsSnapShotTimeStamp && null==vsHostTimeStamp &&
null!=vsLocalTimeStamp ){
client.makeDirectory(vsLocalFile);
}
}
i++;
}
System.out.println("◆da1FileListSets.keySet( )");
// PutMessage("◆da1FileListSets.keySet( )"+"\n"); // dbg //
System.out.println(
"vsHostCurrent="+vsHostCurrent+"; "+
"vsLocalCurrent="+vsLocalCurrent+"; "+
"");
// dbg //
// PutMessage(
// "vsHostCurrent="+vsHostCurrent+"; "+
// "vsLocalCurrent="+vsLocalCurrent+"; "+
// "\n");
for ( String vsFileListKeySet : da1FileListSets.keySet( ) ) {
if( lFTPBreak ){
break Body;
}
if( 0!=fvsFTPSnapShotFile.compareTo(vsFileListKeySet) ){
d1svFileInform = da1FileListSets.get(vsFileListKeySet);
vsPathListTag = d1svFileInform[0];
vsSnapShotTimeStamp = d1svFileInform[1];
vsHostTimeStamp = d1svFileInform[2];
vsLocalTimeStamp = d1svFileInform[3];
System.out.println("◆Operation.");
System.out.println(
"lFTPBreak="+lFTPBreak+"; "+
"vsPathListTag="+vsPathListTag+"; "+
"vsFileListKeySet="+vsFileListKeySet+"; "+
"vsSnapShotTimeStamp="+vsSnapShotTimeStamp+"; "+
"vsHostTimeStamp="+vsHostTimeStamp+"; "+
"vsLocalTimeStamp="+vsLocalTimeStamp+"; "+
"");
if( null!=vsPathListTag &&
0==fvsPathListTag_File.compareTo(vsPathListTag) ){
if( null!=vsSnapShotTimeStamp ){
if( null==vsLocalTimeStamp ){
// Download
System.out.println("▼ 1 Download.");
// PutMessage("▼ 1 Download."+"\n"); // dbg //
FTPDownloadFile(vsFileListKeySet, vsHostCurrent,vsLocalCurrent, -1);
}else if( vsSnapShotTimeStamp.compareTo(vsLocalTimeStamp)<0 ){
// Upload
System.out.println("▲ 2 Upload.");
// PutMessage("▲ 2 Upload."+"\n"); // dbg //
FTPUploadFile(vsFileListKeySet, vsHostCurrent,vsLocalCurrent, -1);
}
}else if( null!=vsHostTimeStamp ){
if( null==vsLocalTimeStamp ||
vsHostTimeStamp.compareTo(vsLocalTimeStamp)>0 ){
// Download
System.out.println("▼ 3 Download.");
// PutMessage("▼ 3 Download."+"\n"); // dbg //
FTPDownloadFile(vsFileListKeySet, vsHostCurrent,vsLocalCurrent, -1);
}else if( vsHostTimeStamp.compareTo(vsLocalTimeStamp)<0 ){
// Upload
System.out.println("▲ 4 Upload.");
// PutMessage("▲ 4 Upload."+"\n"); // dbg //
FTPUploadFile(vsFileListKeySet, vsHostCurrent,vsLocalCurrent, -1);
}
}else {
if( null==vsLocalTimeStamp ){
PutMessage("Program:Error.\n");
PutMessage(vsProcessName+".\n");
PutMessage("PathListTag="+vsPathListTag+"\n");
PutMessage("LocalPathListTag="+vsLocalPathListTag+"\n");
PutMessage("HostCurrent="+vsHostCurrent+"\n");
PutMessage("LocalCurrent="+vsLocalCurrent+"\n");
PutMessage("LocalFile="+vsLocalFile+"\n");
}else{
// Upload
System.out.println("▲ 5 Upload.");
// PutMessage("▲ 5 Upload."+"\n"); // dbg //
FTPUploadFile(vsFileListKeySet, vsHostCurrent,vsLocalCurrent, -1);
}
}
}
}
}
PutMessage(client.getReplyString( ));
lFTPConnection = FTPReply.isPositiveCompletion(client.getReplyCode());
PutMessage(vsProcessName+" Completed.\n");
String vsMsg = "Connection Check => " + (lFTPConnection ? "OK." : "NG:一旦 Logout してみて下さい。");
PutMessage(vsMsg+"\n");
for ( String vsFileListKeySet : da1FileListSets.keySet( ) ) {
if( lFTPBreak ){
break Body;
}
d1svFileInform = da1FileListSets.get(vsFileListKeySet);
vsPathListTag = d1svFileInform[0];
System.out.println(
"lFTPBreak="+lFTPBreak+"; "+
"vsPathListTag="+vsPathListTag+"; "+
"vsFileListKeySet="+vsFileListKeySet+"; "+
"");
if( 0==fvsPathListTag_Folder.compareTo(vsPathListTag) ){
FTPSynchronizeFolder( vsFileListKeySet, vsHostCurrent, vsLocalCurrent );
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
System.out.println("NumberFormatException:"+vsProcessName+".");
PutMessage("NumberFormatException:"+vsProcessName+".\n");
PutMessage("FTP ポートの値が数値ではありません。\n");
} catch (SocketException e) {
e.printStackTrace();
System.out.println("SocketException:"+vsProcessName+".");
PutMessage("SocketException:"+vsProcessName+".\n");
PutMessage("Socket 通信に失敗しました。\n");
} catch (FileNotFoundException e) {
e.printStackTrace();
System.out.println("FileNotFoundException:"+vsProcessName+".");
PutMessage("FileNotFoundException:"+vsProcessName+".\n");
PutMessage("ファイルが見つかりません。\n");
} catch (IOException e) {
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
try {
Pattern pattern = Pattern.compile("^/");
matcher = pattern.matcher(vsHostPrevious);
if( matcher.find( ) ){
client.changeWorkingDirectory(vsHostPrevious);
System.out.println("client.printWorkingDirectory( )="+client.printWorkingDirectory( )+"; ");
}
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
System.out.println("IOException:"+vsProcessName+".");
PutMessage("IOException:"+vsProcessName+".\n");
}
}
public boolean FTPThreadCheck( ){
boolean lThread = false; // true; //
if(null!=oThread_FTPDownload){
lThread = true; // false; //
System.out.println("現在、すでに FTPDownload が実行中です。");
PutMessage("現在、すでに FTPDownload が実行中です。\n");
}
if(null!=oThread_FTPUpload){
lThread = true; // false; //
System.out.println("現在、すでに FTPUpload が実行中です。");
PutMessage("現在、すでに FTPUpload が実行中です。\n");
}
if(null!=oThread_FTPSnapShot_Makera){
lThread = true; // false; //
System.out.println("現在、すでに FTPSnapShot_Makera が実行中です。");
PutMessage("現在、すでに FTPSnapShot_Makera が実行中です。\n");
}
if(null!=oThread_FTPSnapShot_Delete){
lThread = true; // false; //
System.out.println("現在、すでに FTPSnapShot_Delete が実行中です。");
PutMessage("現在、すでに FTPSnapShot_Delete が実行中です。\n");
}
if(null!=oThread_FTPSynchronize){
lThread = true; // false; //
System.out.println("現在、すでに FTPSynchronize が実行中です。");
PutMessage("現在、すでに FTPSynchronize が実行中です。\n");
}
return lThread; // true; // false; //
}
enum MouseMouseDoubleClicked_Enum { feHostFileList, feLocalFileList };
class MainPanelImplementationObj extends MainPanelDesign {
private long ilMouseDoubleClickedIntervalMax = 250; // 350; 300;
private HashMap<MouseMouseDoubleClicked_Enum, Runner_MouseMouseDoubleClicked> da1oRunnable_MouseMouseDoubleClicked =
new HashMap<MouseMouseDoubleClicked_Enum, Runner_MouseMouseDoubleClicked>( );
class Runner_MouseMouseDoubleClicked implements Runnable {
private Thread oThread;
volatile private MouseMouseDoubleClicked_Enum eMouseDoubleClicked;
// volatile:最適化の抑制.
volatile byte ibCnt_MouseEvent = 0;
MouseEvent oEvent_MouseClicked = null;
Runner_MouseMouseDoubleClicked( MouseMouseDoubleClicked_Enum eMMDC ){
eMouseDoubleClicked = eMMDC;
oThread = new Thread(this);
oThread.start();
}
void NativeMouseMousePressed(MouseEvent event) {
System.out.println("NativeMouseMousePressed( ).");
System.out.println(
"eMouseDoubleClicked.name( )="+eMouseDoubleClicked.name( )+"; "+
"ibCnt_MouseEvent="+ibCnt_MouseEvent+"; "+
"");
oEvent_MouseClicked = null;
if(oThread.getState()==Thread.State.TIMED_WAITING){
ibCnt_MouseEvent = 3;
oThread.interrupt();
}else{
ibCnt_MouseEvent = 1;
}
System.out.println(
"eMouseDoubleClicked.name( )="+eMouseDoubleClicked.name( )+"; "+
"ibCnt_MouseEvent="+ibCnt_MouseEvent+"; "+
"");
}
boolean NativeMouseMouseReleased(MouseEvent event) {
System.out.println("NativeMouseMouseReleased( ).");
System.out.println(
"eMouseDoubleClicked.name( )="+eMouseDoubleClicked.name( )+"; "+
"ibCnt_MouseEvent="+ibCnt_MouseEvent+"; "+
"");
oEvent_MouseClicked = event;
boolean lDoubleClicked = false; // true; //
if(ibCnt_MouseEvent==3){
ibCnt_MouseEvent = 0;
lDoubleClicked = true; // false; //
}else if(oThread.getState()==Thread.State.WAITING){
ibCnt_MouseEvent = 2;
synchronized(this) {
notify();
// ↑メソッドを synchronized 指定するか、
// synchronized(自分のインスタンス) ブロックで囲うかしないと
// 実行時に「IllegalMonitorStateException」が発生する。
}
}
System.out.println(
"eMouseDoubleClicked.name( )="+eMouseDoubleClicked.name( )+"; "+
"ibCnt_MouseEvent="+ibCnt_MouseEvent+"; "+
"lDoubleClicked="+lDoubleClicked+"; "+
"");
return lDoubleClicked;
}
@Override
public void run( ) {
System.out.println("run.");
boolean lInterrupted = false; // true; //
while(true){
try {
synchronized(this) {
wait( );
// ↑メソッドを synchronized 指定するか、
// synchronized(自分のインスタンス) ブロックで囲うかしないと
// 実行時に「IllegalMonitorStateException」が発生する。
}
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("wait:End.");
lInterrupted = false; // true; //
try {
Thread.sleep(ilMouseDoubleClickedIntervalMax);
} catch (InterruptedException e) {
// e.printStackTrace();
System.out.println("sleep:InterruptedException.");
lInterrupted = true; // false; //
}
System.out.println("sleep:End.");
if( ! lInterrupted &&
ibCnt_MouseEvent==2 ){
ibCnt_MouseEvent = 0;
switch(eMouseDoubleClicked){
case feHostFileList :
HostFileList_CltMouseMouseClicked(oEvent_MouseClicked);
break;
case feLocalFileList :
LocalFileList_CltMouseMouseClicked(oEvent_MouseClicked);
break;
default:
System.out.println(
"★Error:MouseDoubleClicked="+eMouseDoubleClicked.name( )+"; "+
"");
PutMessage(
"★Error:MouseDoubleClicked="+eMouseDoubleClicked.name( )+"; "+
"\n");
}
oEvent_MouseClicked = null;
}
}
}
}
MainPanelImplementationObj( ){
super( );
for( MouseMouseDoubleClicked_Enum eEnum : MouseMouseDoubleClicked_Enum.values( ) ){
da1oRunnable_MouseMouseDoubleClicked.put(eEnum,
new Runner_MouseMouseDoubleClicked(eEnum));
}
}
@Override
synchronized void FTPLogin_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:HostLogin_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("FTPLogin は実行できませんでした。\n");
return;
}
oMainApp.FTPLogin( );
}
@Override
synchronized void FTPLogout_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:HostLogout_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("FTPLogou は実行できませんでした。\n");
return;
}
oMainApp.FTPLogout( );
}
@Override
@SuppressWarnings("rawtypes")
synchronized void FTPDownload_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:FTPDownload_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("FTPDownload は実行できませんでした。\n");
return;
}
oThread_FTPDownload = new Thread( ){
@Override
public void run( ){
if( 0==((DefaultListModel)
oMainPanelImp.cltHostTransferList.getModel( )).getSize( ) ){
FTPDownload( );
}else{
FTPTransfer( FTPTransfer_Enum.feFTPDownload);
}
lFTPBreak = false; // true; //
oThread_FTPDownload = null;
}
};
oThread_FTPDownload.start();
}
@Override
@SuppressWarnings("rawtypes")
synchronized void FTPUpload_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:FTPUpload_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("FTPUpload は実行できませんでした。\n");
return;
}
oThread_FTPUpload = new Thread( ){
@Override
public void run( ){
if( 0==((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).getSize( ) ){
FTPUpload( );
}else{
FTPTransfer( FTPTransfer_Enum.feFTPUpload );
}
lFTPBreak = false; // true; //
oThread_FTPUpload = null;
}
};
oThread_FTPUpload.start();
}
synchronized void HostFileList_CltMouseMouseClicked(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:HostFileList_CltMouseMouseClicked.");
}
synchronized void HostFileList_CltMouseMouseDoubleClicked(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:HostFileList_CltMouseMouseDoubleClicked.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("HostFileList は実行できませんでした。\n");
return;
}
Pattern pattern = null;
String vsTargetFile = null;
if( ! oMainPanelImp.cltHostFileList.isSelectionEmpty( ) ){
vsTargetFile = (String)oMainPanelImp.cltHostFileList.getSelectedValue( );
pattern = Pattern.compile("^("+fvsReg_PathListTag_Folder+")");
matcher = pattern.matcher(vsTargetFile);
if(matcher.find()){
vsTargetFile = matcher.replaceAll("");
System.out.println("vsTargetFile = "+vsTargetFile+"; ");
HostFileList(vsTargetFile, true); // lTabSelected : true; / false; //
}
}else{
vsTargetFile = null;
PutMessage("HostFileList で項目が選択せれていません.\n");
}
}
@Override
void HostFileList_CltNativeMouseMousePressed(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:HostFileList_CltNativeMouseMousePressed");
da1oRunnable_MouseMouseDoubleClicked.get(
MouseMouseDoubleClicked_Enum.feHostFileList).NativeMouseMousePressed(event);
}
@Override
void HostFileList_CltNativeMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:HostFileList_CltNativeMouseMouseReleased.");
boolean lDoubleClicked = da1oRunnable_MouseMouseDoubleClicked.get(
MouseMouseDoubleClicked_Enum.feHostFileList).NativeMouseMouseReleased(event);
if( lDoubleClicked ){
HostFileList_CltMouseMouseDoubleClicked(event);
}
}
synchronized void LocalFileList_CltMouseMouseClicked(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:LocalFileList_CltMouseMouseClicked.");
}
synchronized void LocalFileList_CltMouseMouseDoubleClicked(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:LocalFileList_CltMouseMouseDoubleClicked.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("LocalFileList は実行できませんでした。\n");
return;
}
Pattern pattern = null;
String vsTargetFile = null;
if( ! oMainPanelImp.cltLocalFileList.isSelectionEmpty() ){
vsTargetFile = (String)oMainPanelImp.cltLocalFileList.getSelectedValue();
pattern = Pattern.compile("^("+fvsReg_PathListTag_Folder+")");
matcher = pattern.matcher(vsTargetFile);
if(matcher.find()){
vsTargetFile = matcher.replaceAll("");
System.out.println("vsTargetFile = "+vsTargetFile+"; ");
LocalFileList(vsTargetFile, true); // lTabSelected : true; / false; //
}
}else{
vsTargetFile = null;
PutMessage("LocalFileList で項目が選択せれていません.\n");
}
}
@Override
void LocalFileList_CltNativeMouseMousePressed(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:LocalFileList_CltNativeMouseMousePressed");
da1oRunnable_MouseMouseDoubleClicked.get(
MouseMouseDoubleClicked_Enum.feLocalFileList).NativeMouseMousePressed(event);
}
@Override
void LocalFileList_CltNativeMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:LocalFileList_CltNativeMouseMouseReleased");
boolean lDoubleClicked = da1oRunnable_MouseMouseDoubleClicked.get(
MouseMouseDoubleClicked_Enum.feLocalFileList).NativeMouseMouseReleased(event);
if( lDoubleClicked ){
LocalFileList_CltMouseMouseDoubleClicked(event);
}
}
@Override
synchronized void SetupFileList_HostFolder_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:SetupFileList_HostFolder_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("HostFileList は実行できませんでした。\n");
return;
}
HostFileList(null, true); // lTabSelected : true; / false; //
}
@Override
synchronized void SetupFileList_LocalFolder_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:SetupFileList_LocalFolder_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("LocalFileList は実行できませんでした。\n");
return;
}
LocalFileList(null, true); // lTabSelected : true; / false; //
}
@Override
void FTPBreak_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:FTPBreak_CbtMouseMouseReleased.");
lFTPBreak = true; // false; //
System.out.println("lFTPBreak="+lFTPBreak+"; ");
}
@Override
synchronized void TransferList_Entry_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:TransferListEntry_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("TransferList_Entry は実行できませんでした。\n");
return;
}
((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).addElement(
ctfHostFolder.getText( ));
((DefaultListModel)oMainPanelImp.cltLocalTransferList.getModel( )).addElement(
ctfLocalFolder.getText( ));
}
@Override
synchronized void TransferList_Delete_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:TransferListDelete_CbtMouseMouseReleased.");
int iSelectedIndex = -1;
JScrollPane oTabSelectedComponent = (JScrollPane)oMainPanelImp.ctpTransferListTabs.getSelectedComponent( );
// JScrollPane には暗黙の子 JViewport が存在し、
// 「JScrollPane.getViewport( ) 」で(暗黙の子) JViewport のインスタンスを取得できる。
// つまり、この場合の JList の親は JViewport となる。
// ちなみに、この場合の JList の親の親が JScrollPane となる。
if( oTabSelectedComponent.getViewport( )==oMainPanelImp.cltHostTransferList.getParent( ) ){
System.out.println("if(oTabSelectedComponent.getViewport( )==cltHostTransferList.getParent( )).");
if( oMainPanelImp.cltHostTransferList.isSelectionEmpty( ) ){
PutMessage("cltHostTransferList:表示されているタブに選択されている項目がありません。\n");
}else{
iSelectedIndex = oMainPanelImp.cltHostTransferList.getSelectedIndex( );
}
}
if( oTabSelectedComponent.getViewport( )==oMainPanelImp.cltLocalTransferList.getParent( ) ){
System.out.println("(oTabSelectedComponent.getViewport( )==cltLocalTransferList.getParent( )).");
if( oMainPanelImp.cltLocalTransferList.isSelectionEmpty( ) ){
PutMessage("cltLocalTransferList:表示されているタブに選択されている項目がありません。\n");
}else{
iSelectedIndex = oMainPanelImp.cltLocalTransferList.getSelectedIndex( );
}
}
System.out.println("iSelectedIndex="+iSelectedIndex+"; ");
if( 0<=iSelectedIndex ){
System.out.println("if( 0<=iSelectedIndex )");
((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).remove(iSelectedIndex);
((DefaultListModel)oMainPanelImp.cltLocalTransferList.getModel( )).remove(iSelectedIndex);
}
}
@Override
synchronized void FTPSnapShot_Makera_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:FTPSnapShot_Make_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("FTPSnapShot_Makera は実行できませんでした。\n");
return;
}
oThread_FTPSnapShot_Makera = new Thread( ){
@Override
public void run( ){
if( 0==((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).getSize( ) ){
FTPSnapShot(true); // lMakera : true; / false;
}else{
FTPTransfer( FTPTransfer_Enum.feFTPSnapShot_Makera );
}
lFTPBreak = false; // true; //
oThread_FTPSnapShot_Makera = null;
}
};
oThread_FTPSnapShot_Makera.start();
}
@Override
synchronized void FTPSnapShot_Delete_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:FTPSnapShot_Make_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("FTPSnapShot_Delete は実行できませんでした。\n");
return;
}
oThread_FTPSnapShot_Delete = new Thread( ){
@Override
public void run( ){
if( 0==((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).getSize( ) ){
FTPSnapShot(false); // lMakera : true; / false;
}else{
FTPTransfer( FTPTransfer_Enum.feFTPSnapShot_Delete );
}
lFTPBreak = false; // true; //
oThread_FTPSnapShot_Delete = null;
}
};
oThread_FTPSnapShot_Delete.start();
}
@Override
@SuppressWarnings("rawtypes")
synchronized void FTPSynchronize_CbtMouseMouseReleased(MouseEvent event) {
System.out.println("MainPanelImplementationObj:MouseEvent:Synchronize_CbtMouseMouseReleased.");
if( oMainApp.FTPThreadCheck( ) ){
PutMessage("FTPSynchronize は実行できませんでした。\n");
return;
}
oThread_FTPSynchronize = new Thread( ){
@Override
public void run( ){
if( 0==((DefaultListModel)oMainPanelImp.cltHostTransferList.getModel( )).getSize( ) ){
FTPSynchronize( );
}else{
FTPTransfer( FTPTransfer_Enum.feFTPSynchronize );
}
lFTPBreak = false; // true; //
oThread_FTPSynchronize = null;
}
};
oThread_FTPSynchronize.start();
}
}
static class MainAppFrameObj extends JFrame implements Runnable {
// JApplet oApplet;
Thread oAppThread;
public MainAppFrameObj( ) {
super("Application frame.");
//setVisible(false);
System.out.println("Construct:Application frame window.");
// oApplet = oEntApplet; // new JAppletcation();
addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent event){
// ユーザーがウインドウを閉じようとした時].
Object oSource = event.getSource();
if (oSource == MainAppFrameObj.this){
System.out.println("MainAppFrameObj:WindowEvent:windowClosing.");
oMainApp.FTPLogout();
Close();
}
}
}
);
addWindowListener(
new WindowAdapter(){
public void windowClosed(WindowEvent event){
// ウインドウが閉じた時.
Object oSource = event.getSource();
if (oSource == MainAppFrameObj.this){
System.out.println("MainAppFrameObj:WindowEvent:windowClosed.");
}
}
}
);
addWindowListener(
new WindowAdapter(){
public void windowDeiconified(WindowEvent event){
// ウィンドウが最小化された状態から通常の状態に変更された時.
Object oSource = event.getSource();
if (oSource == MainAppFrameObj.this){
System.out.println("MainAppFrameObj:WindowEvent:windowDeiconified.");
oMainApp.repaint();
}
}
}
);
addComponentListener(
new ComponentAdapter(){
public void componentResized(ComponentEvent event){
// コンポーネントのサイズが変更された時.
Object oSource = event.getSource();
if (oSource == MainAppFrameObj.this){
System.out.println("ComponentEvent:componentResized.");
System.out.println("MainAppFrameObj:"+
"width="+Integer.toString(MainAppFrameObj.this.getSize( ).width)+"; "+
"Height="+Integer.toString(MainAppFrameObj.this.getSize( ).height)+"; "+
"");
oMainApp.repaint();
}
}
}
);
getContentPane().add(oMainApp,"Center");
oAppThread = new Thread(this);
}
public synchronized void setPreSize(Dimension oSize){
// dispose();
getContentPane().setPreferredSize(oSize);
pack();
setVisible(true);
requestFocus();
}
public synchronized void run(){
System.out.println("Open:Application frame window.");
oMainApp.init();
oMainApp.start();
oMainApp.repaint();
try{
wait();
}
catch(InterruptedException e){
e.printStackTrace();
}
oMainApp.stop();
oMainApp.destroy();
oAppThread = null;
}
public synchronized void Close(){
System.out.println("Close:Application frame window.");
dispose();
notify();
}
}
}
|
|
|
<Number>: [00000977]
<Date>: 2015/12/31 17:51:41
<Title>:
<Name>: amanojaku@管理人
|
|
|
『MainPanelDesign.java』
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.dyno.visual.swing.layouts.Bilateral;
import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;
//VS4E -- DO NOT REMOVE THIS LINE!
public class MainPanelDesign extends JPanel {
private static final long serialVersionUID = 1L;
private JButton cbtHostLogin;
private JButton cbtHostLogout;
private JButton cbtFTPUpload;
private JButton cbtFTPBreak;
private JButton cbtFTPDownload;
private JButton cbtSetupFileList_HostFolder;
private JButton cbtSetupFileList_LocalFolder;
private JButton cbtTransferList_Delete;
private JButton cbtTransferList_Entry;
private JButton cbtFTPSnapShot_Make;
private JButton cbtFTPSnapShot_Delete;
private JButton cbtFTPSynchronize;
JTextField ctfHostUserName;
JTextField ctfHostName;
JPasswordField cpfHostPassword;
JTextField ctfHostFolder;
JTextField ctfLocalFolder;
JTextField ctfHostPortNum;
JTextArea ctaMessage;
JList cltHostFileList;
JList cltLocalFileList;
JComboBox ccbFTPFileDataType;
JTabbedPane ctpFileListTabs;
JCheckBox cckHostPASVMode;
JComboBox ccbHostEncode;
JPanel cpnFTPSetting;
JTabbedPane ctpBaseTabs;
JList cltHostTransferList;
JList cltLocalTransferList;
JTabbedPane ctpTransferListTabs;
private JLabel jLabel2;
private JLabel jLabel6;
private JLabel jLabel5;
private JLabel jLabel0;
private JLabel jLabel1;
private JLabel jLabel7;
private JLabel jLabel9;
private JScrollPane jScrollPane0;
private JScrollPane jScrollPane1;
private JScrollPane jScrollPane2;
private JScrollPane jScrollPane3;
private JScrollPane jScrollPane4;
private JLabel jLabel3;
private JLabel jLabel4;
public MainPanelDesign() {
initComponents();
}
private void initComponents() {
setMinimumSize(new Dimension(479, 400));
setPreferredSize(new Dimension(479, 400));
setLayout(new GroupLayout());
add(getCbtHostLogin(), new Constraints(new Leading(10, 72, 75, 282), new Leading(254, 12, 12)));
add(getJLabel7(), new Constraints(new Leading(289, 12, 12), new Leading(195, 12, 12)));
add(getCtpBaseTabs(), new Constraints(new Leading(8, 271, 23, 23), new Leading(7, 237, 10, 10)));
add(getJLabel3(), new Constraints(new Leading(289, 12, 12), new Leading(15, 87, 177)));
add(getCtpTransferListTabs(), new Constraints(new Bilateral(289, 12, 57), new Leading(46, 139, 10, 10)));
add(getCbtHostLogout(), new Constraints(new Leading(94, 12, 12), new Leading(254, 12, 12)));
add(getCbtTransferList_Entry(), new Constraints(new Leading(368, 12, 12), new Leading(10, 12, 12)));
add(getCbtTransferList_Delete(), new Constraints(new Leading(443, 12, 12), new Leading(10, 12, 12)));
add(getCcbFTPFileDataType(), new Constraints(new Leading(135, 12, 12), new Leading(292, 12, 12)));
add(getJLabel9(), new Constraints(new Leading(10, 12, 12), new Leading(295, 18, 12, 12)));
add(getCbtSetupFileList_HostFolder(), new Constraints(new Leading(8, 12, 12), new Leading(330, 12, 12)));
add(getCtfHostFolder(), new Constraints(new Leading(135, 144, 12, 12), new Leading(333, 12, 12)));
add(getCbtSetupFileList_LocalFolder(), new Constraints(new Leading(8, 12, 12), new Leading(368, 12, 12)));
add(getCtfLocalFolder(), new Constraints(new Leading(136, 144, 12, 12), new Leading(371, 12, 12)));
add(getCbtFTPSynchronize(), new Constraints(new Leading(10, 12, 12), new Leading(445, 10, 10)));
add(getJLabel4(), new Constraints(new Leading(8, 12, 12), new Leading(411, 12, 12)));
add(getCbtFTPUpload(), new Constraints(new Leading(228, 12, 12), new Leading(445, 12, 12)));
add(getCbtFTPDownload(), new Constraints(new Leading(126, 12, 12), new Leading(445, 12, 12)));
add(getCbtFTPBreak(), new Constraints(new Leading(313, 12, 12), new Leading(445, 12, 12)));
add(getCtpFileListTabs(), new Constraints(new Leading(289, 266, 10, 10), new Leading(217, 220, 10, 10)));
add(getCbtFTPSnapShot_Delete(), new Constraints(new Leading(172, 12, 12), new Leading(406, 12, 12)));
add(getCbtFTPSnapShot_Make(), new Constraints(new Leading(94, 12, 12), new Leading(406, 12, 12)));
setSize(565, 486);
}
private JButton getCbtFTPSynchronize() {
if (cbtFTPSynchronize == null) {
cbtFTPSynchronize = new JButton();
cbtFTPSynchronize.setText("Synchronize");
cbtFTPSynchronize.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
FTPSynchronize_CbtMouseMouseReleased(event);
}
});
}
return cbtFTPSynchronize;
}
private JButton getJButton0() {
if (cbtFTPSynchronize == null) {
cbtFTPSynchronize = new JButton();
cbtFTPSynchronize.setText("Synchronize");
}
return cbtFTPSynchronize;
}
private JLabel getJLabel4() {
if (jLabel4 == null) {
jLabel4 = new JLabel();
jLabel4.setText("FTPSnapShot");
}
return jLabel4;
}
private JButton getCbtFTPSnapShot_Delete() {
if (cbtFTPSnapShot_Delete == null) {
cbtFTPSnapShot_Delete = new JButton();
cbtFTPSnapShot_Delete.setText("Delete");
cbtFTPSnapShot_Delete.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
FTPSnapShot_Delete_CbtMouseMouseReleased(event);
}
});
}
return cbtFTPSnapShot_Delete;
}
private JButton getCbtFTPSnapShot_Make() {
if (cbtFTPSnapShot_Make == null) {
cbtFTPSnapShot_Make = new JButton();
cbtFTPSnapShot_Make.setText("Make");
cbtFTPSnapShot_Make.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
FTPSnapShot_Makera_CbtMouseMouseReleased(event);
}
});
}
return cbtFTPSnapShot_Make;
}
private JLabel getJLabel3() {
if (jLabel3 == null) {
jLabel3 = new JLabel();
jLabel3.setText("TransferList");
}
return jLabel3;
}
private JScrollPane getJScrollPane4() {
if (jScrollPane4 == null) {
jScrollPane4 = new JScrollPane();
jScrollPane4.setViewportView(getCltLocalTransferList());
}
return jScrollPane4;
}
private JList getCltLocalTransferList() {
if (cltLocalTransferList == null) {
cltLocalTransferList = new JList();
DefaultListModel listModel = new DefaultListModel();
cltLocalTransferList.setModel(listModel);
}
return cltLocalTransferList;
}
private JScrollPane getJScrollPane3() {
if (jScrollPane3 == null) {
jScrollPane3 = new JScrollPane();
jScrollPane3.setViewportView(getCltHostTransferList());
}
return jScrollPane3;
}
private JList getCltHostTransferList() {
if (cltHostTransferList == null) {
cltHostTransferList = new JList();
DefaultListModel listModel = new DefaultListModel();
cltHostTransferList.setModel(listModel);
}
return cltHostTransferList;
}
private JButton getCbtTransferList_Entry() {
if (cbtTransferList_Entry == null) {
cbtTransferList_Entry = new JButton();
cbtTransferList_Entry.setText("Entry");
cbtTransferList_Entry.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
TransferList_Entry_CbtMouseMouseReleased(event);
}
});
}
return cbtTransferList_Entry;
}
private JButton getCbtTransferList_Delete() {
if (cbtTransferList_Delete == null) {
cbtTransferList_Delete = new JButton();
cbtTransferList_Delete.setText("Delete");
cbtTransferList_Delete.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
TransferList_Delete_CbtMouseMouseReleased(event);
}
});
}
return cbtTransferList_Delete;
}
private JTabbedPane getCtpTransferListTabs() {
if (ctpTransferListTabs == null) {
ctpTransferListTabs = new JTabbedPane();
ctpTransferListTabs.addTab("Host", getJScrollPane3());
ctpTransferListTabs.addTab("Local", getJScrollPane4());
}
return ctpTransferListTabs;
}
private JTabbedPane getCtpBaseTabs() {
if (ctpBaseTabs == null) {
ctpBaseTabs = new JTabbedPane();
ctpBaseTabs.addTab("FTP", getCpnFTPSetting());
ctpBaseTabs.addTab("Message", getJScrollPane0());
}
return ctpBaseTabs;
}
private JPanel getCpnFTPSetting() {
if (cpnFTPSetting == null) {
cpnFTPSetting = new JPanel();
cpnFTPSetting.setLayout(new GroupLayout());
cpnFTPSetting.add(getJLabel1(), new Constraints(new Leading(7, 12, 12), new Leading(42, 134, 134)));
cpnFTPSetting.add(getJLabel2(), new Constraints(new Leading(7, 12, 12), new Leading(176, 12, 12)));
cpnFTPSetting.add(getJLabel6(), new Constraints(new Leading(7, 12, 12), new Leading(140, 12, 12)));
cpnFTPSetting.add(getJLabel5(), new Constraints(new Leading(7, 12, 12), new Leading(74, 12, 12)));
cpnFTPSetting.add(getCckHostPASVMode(), new Constraints(new Leading(7, 12, 12), new Leading(8, 12, 12)));
cpnFTPSetting.add(getCtfHostName(), new Constraints(new Leading(96, 142, 10, 10), new Leading(72, 12, 12)));
cpnFTPSetting.add(getCpfHostPassword(), new Constraints(new Leading(97, 140, 12, 12), new Leading(172, 12, 12)));
cpnFTPSetting.add(getCtfHostPortNum(), new Constraints(new Leading(96, 142, 12, 12), new Leading(104, 12, 12)));
cpnFTPSetting.add(getJLabel0(), new Constraints(new Leading(7, 12, 12), new Leading(106, 12, 12)));
cpnFTPSetting.add(getCtfHostUserName(), new Constraints(new Leading(97, 142, 12, 12), new Leading(138, 12, 12)));
cpnFTPSetting.add(getCcbHostEncode(), new Constraints(new Leading(96, 12, 12), new Leading(38, 12, 12)));
}
return cpnFTPSetting;
}
private JButton getCbtFTPBreak() {
if (cbtFTPBreak == null) {
cbtFTPBreak = new JButton();
cbtFTPBreak.setText("Break");
cbtFTPBreak.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
FTPBreak_CbtMouseMouseReleased(event);
}
});
}
return cbtFTPBreak;
}
private JComboBox getCcbHostEncode() {
if (ccbHostEncode == null) {
ccbHostEncode = new JComboBox();
ccbHostEncode.setModel(new DefaultComboBoxModel(new Object[] { "UTF-8", "Windows", "EUC-JP", "ASCII" }));
ccbHostEncode.setDoubleBuffered(false);
ccbHostEncode.setBorder(null);
}
return ccbHostEncode;
}
private JButton getCbtSetupFileList_HostFolder() {
if (cbtSetupFileList_HostFolder == null) {
cbtSetupFileList_HostFolder = new JButton();
cbtSetupFileList_HostFolder.setText("HostFolder >");
cbtSetupFileList_HostFolder.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
SetupFileList_HostFolder_CbtMouseMouseReleased(event);
}
});
}
return cbtSetupFileList_HostFolder;
}
private JButton getCbtSetupFileList_LocalFolder() {
if (cbtSetupFileList_LocalFolder == null) {
cbtSetupFileList_LocalFolder = new JButton();
cbtSetupFileList_LocalFolder.setText("LocalFolder >");
cbtSetupFileList_LocalFolder.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
SetupFileList_LocalFolder_CbtMouseMouseReleased(event);
}
});
}
return cbtSetupFileList_LocalFolder;
}
private JButton getCbtFTPUpload() {
if (cbtFTPUpload == null) {
cbtFTPUpload = new JButton();
cbtFTPUpload.setText("Upload");
cbtFTPUpload.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
FTPUpload_CbtMouseMouseReleased(event);
}
});
}
return cbtFTPUpload;
}
private JComboBox getCcbFTPFileDataType() {
if (ccbFTPFileDataType == null) {
ccbFTPFileDataType = new JComboBox();
ccbFTPFileDataType.setModel(new DefaultComboBoxModel(new Object[] { "Binary", "ASCII" }));
ccbFTPFileDataType.setDoubleBuffered(false);
ccbFTPFileDataType.setBorder(null);
}
return ccbFTPFileDataType;
}
private JLabel getJLabel9() {
if (jLabel9 == null) {
jLabel9 = new JLabel();
jLabel9.setText("FileDtata");
}
return jLabel9;
}
private JCheckBox getCckHostPASVMode() {
if (cckHostPASVMode == null) {
cckHostPASVMode = new JCheckBox();
cckHostPASVMode.setSelected(true);
cckHostPASVMode.setText("PASVMode");
}
return cckHostPASVMode;
}
private JList getCltLocalFileList() {
if (cltLocalFileList == null) {
cltLocalFileList = new JList();
cltLocalFileList.setBackground(Color.white);
DefaultListModel listModel = new DefaultListModel();
cltLocalFileList.setModel(listModel);
cltLocalFileList.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
LocalFileList_CltNativeMouseMousePressed(event);
}
public void mouseReleased(MouseEvent event) {
LocalFileList_CltNativeMouseMouseReleased(event);
}
});
}
return cltLocalFileList;
}
private JLabel getJLabel7() {
if (jLabel7 == null) {
jLabel7 = new JLabel();
jLabel7.setText("FileList");
}
return jLabel7;
}
private JTabbedPane getCtpFileListTabs() {
if (ctpFileListTabs == null) {
ctpFileListTabs = new JTabbedPane();
ctpFileListTabs.addTab("Host", getJScrollPane1());
ctpFileListTabs.addTab("Local", getJScrollPane2());
}
return ctpFileListTabs;
}
private JScrollPane getJScrollPane2() {
if (jScrollPane2 == null) {
jScrollPane2 = new JScrollPane();
jScrollPane2.setBackground(Color.white);
jScrollPane2.setViewportView(getCltLocalFileList());
}
return jScrollPane2;
}
private JList getJList0() {
if (cltLocalFileList == null) {
cltLocalFileList = new JList();
DefaultListModel listModel = new DefaultListModel();
listModel.addElement("item0");
listModel.addElement("item1");
listModel.addElement("item2");
listModel.addElement("item3");
cltLocalFileList.setModel(listModel);
}
return cltLocalFileList;
}
private JLabel getJLabel1() {
if (jLabel1 == null) {
jLabel1 = new JLabel();
jLabel1.setText("HostEncode");
}
return jLabel1;
}
private JButton getCbtFTPDownload() {
if (cbtFTPDownload == null) {
cbtFTPDownload = new JButton();
cbtFTPDownload.setText("Download");
cbtFTPDownload.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
FTPDownload_CbtMouseMouseReleased(event);
}
});
}
return cbtFTPDownload;
}
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setEnabled(false);
jScrollPane1.setViewportView(getCltHostFileList());
}
return jScrollPane1;
}
private JList getCltHostFileList() {
if (cltHostFileList == null) {
cltHostFileList = new JList();
DefaultListModel listModel = new DefaultListModel();
cltHostFileList.setModel(listModel);
cltHostFileList.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
HostFileList_CltNativeMouseMousePressed(event);
}
public void mouseReleased(MouseEvent event) {
HostFileList_CltNativeMouseMouseReleased(event);
}
});
}
return cltHostFileList;
}
private JScrollPane getJScrollPane0() {
if (jScrollPane0 == null) {
jScrollPane0 = new JScrollPane();
jScrollPane0.setViewportView(getCtaMessage());
}
return jScrollPane0;
}
private JTextArea getCtaMessage() {
if (ctaMessage == null) {
ctaMessage = new JTextArea();
}
return ctaMessage;
}
private JTextField getCtfHostPortNum() {
if (ctfHostPortNum == null) {
ctfHostPortNum = new JTextField();
}
return ctfHostPortNum;
}
private JLabel getJLabel0() {
if (jLabel0 == null) {
jLabel0 = new JLabel();
jLabel0.setText("PortNo");
}
return jLabel0;
}
private JLabel getJLabel5() {
if (jLabel5 == null) {
jLabel5 = new JLabel();
jLabel5.setText("HostName");
}
return jLabel5;
}
private JLabel getJLabel6() {
if (jLabel6 == null) {
jLabel6 = new JLabel();
jLabel6.setText("UserName");
}
return jLabel6;
}
private JTextField getCtfLocalFolder() {
if (ctfLocalFolder == null) {
ctfLocalFolder = new JTextField();
ctfLocalFolder.setBackground(Color.white);
ctfLocalFolder.setText("");
}
return ctfLocalFolder;
}
private JButton getCbtHostLogin() {
if (cbtHostLogin == null) {
cbtHostLogin = new JButton();
cbtHostLogin.setText("Login");
cbtHostLogin.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
HostLogin_CbtMouseMouseReleased(event);
}
});
}
return cbtHostLogin;
}
private JTextField getCtfHostFolder() {
if (ctfHostFolder == null) {
ctfHostFolder = new JTextField();
ctfHostFolder.setBackground(Color.white);
}
return ctfHostFolder;
}
private JButton getCbtHostLogout() {
if (cbtHostLogout == null) {
cbtHostLogout = new JButton();
cbtHostLogout.setText("Logout");
cbtHostLogout.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent event) {
HostLogout_CbtMouseMouseReleased(event);
}
});
}
return cbtHostLogout;
}
private JLabel getJLabel2() {
if (jLabel2 == null) {
jLabel2 = new JLabel();
jLabel2.setText("Password");
}
return jLabel2;
}
private JTextField getCtfHostUserName() {
if (ctfHostUserName == null) {
ctfHostUserName = new JTextField();
}
return ctfHostUserName;
}
private JTextField getCtfHostName() {
if (ctfHostName == null) {
ctfHostName = new JTextField();
}
return ctfHostName;
}
private JPasswordField getCpfHostPassword() {
if (cpfHostPassword == null) {
cpfHostPassword = new JPasswordField();
cpfHostPassword.setEchoChar('*');
}
return cpfHostPassword;
}
void HostLogout_CbtMouseMouseReleased(MouseEvent event) {
}
void HostLogin_CbtMouseMouseReleased(MouseEvent event) {
}
void FTPDownload_CbtMouseMouseReleased(MouseEvent event) {
}
void FTPUpload_CbtMouseMouseReleased(MouseEvent event) {
}
void HostFileList_CltNativeMouseMousePressed(MouseEvent event) {
}
void HostFileList_CltNativeMouseMouseReleased(MouseEvent event) {
}
void LocalFileList_CltNativeMouseMousePressed(MouseEvent event) {
}
void LocalFileList_CltNativeMouseMouseReleased(MouseEvent event) {
}
void SetupFileList_HostFolder_CbtMouseMouseReleased(MouseEvent event) {
}
void SetupFileList_LocalFolder_CbtMouseMouseReleased(MouseEvent event) {
}
void FTPBreak_CbtMouseMouseReleased(MouseEvent event) {
}
void TransferList_Entry_CbtMouseMouseReleased(MouseEvent event) {
}
void TransferList_Delete_CbtMouseMouseReleased(MouseEvent event) {
}
void FTPSnapShot_Makera_CbtMouseMouseReleased(MouseEvent event) {
}
void FTPSnapShot_Delete_CbtMouseMouseReleased(MouseEvent event) {
}
void FTPSynchronize_CbtMouseMouseReleased(MouseEvent event) {
}
}
|
|
|
<Number>: [00000978]
<Date>: 2016/01/03 21:52:57
<Title>:
<Name>: amanojaku@管理人
|
|
|
|
|