The Artima Developer Community
Sponsored Link

Java Answers Forum
Changing Directory structure on the server

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Sarath

Posts: 2
Nickname: sarathcb
Registered: Feb, 2004

Changing Directory structure on the server Posted: Apr 21, 2004 5:25 PM
Reply to this message Reply
Advertisement
Hello,

The combo box does'nt refresh when i change the drive options, it lists all the drives of the pc and by default its C on the FTP client application.
After connecting to the server, by default it lists the directory structure of C and when i doubt click on a directory, it lists the files inside that directory.Now, from my combo box when i select to D, it lists me the directories of D,but the combo box shows me only C.Now, when I double click on the directories of D it does'nt change.Could somebody pls help me out, thanks in advance.
some important parts of the code:


public class FTP extends javax.swing.JFrame{
    
    public int count=0;
    Model tableModel=new Model();
    Model tableServerModel=new Model();
    long mouseDoubleClickThreshold = 350;
    long mouseUpClickTime = 0;
    int clickCount=0,connectCount=0;
    String currentPath="C:\\";
    String clientHeader="Filename*Size*Type*Last Modified";
    String currentServerPath="C:\\";
    String sendCommand="";
    String sendString="";
    String renFrom="",renTo="";
    boolean sendCom=false;
    boolean connected=false;
    int a=0;
    Client cl=new Client();
public class FTP extends javax.swing.JFrame{
    
    public int count=0;
    Model tableModel=new Model();
    Model tableServerModel=new Model();
    long mouseDoubleClickThreshold = 350;
    long mouseUpClickTime = 0;
    int clickCount=0,connectCount=0;
    String currentPath="C:\\";
    String clientHeader="Filename*Size*Type*Last Modified";
    String currentServerPath="C:\\";
    String sendCommand="";
    String sendString="";
    String renFrom="",renTo="";
    boolean sendCom=false;
    boolean connected=false;
    int a=0;
    Client cl=new Client();
 
 public String[] getServerDirInfo(String path) {
        
        StringTokenizer tok=new StringTokenizer(path,"*",false);
        String result[] = new String[tok.countTokens()];
        int resultAt=0;
        String temp="";
        while (tok.hasMoreTokens()) {
            temp=tok.nextToken();
            result[resultAt++]=temp.substring(4,temp.length());
        }
        
        return result;
    }
 
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
        if(connectCount==0) {
            synchronized(FTP.this) {
                FTP.this.notifyAll();
            }
            suspended=false;
            currentServerPath="C:\\";
            sendCommand="CON";
            btnConnect.setLabel("Disconnect");
            txtHost.setEnabled(false);
            txtUsername.setEnabled(false);
            txtPassword.setEnabled(false);
            connectCount=1;
            
            
        }
        else if(connectCount==1) {
 
            
            sendCommand="QUIT";
            clrTblServer();
        }
        
		        
        
        
    }//GEN-LAST:event_btnConnectActionPerformed
    
    private void tblServerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblServerMouseClicked
        long eventTime = evt.getWhen();
        long timeDiff = eventTime - mouseUpClickTime;
        
        if ( timeDiff < 0 ) {
            timeDiff = -timeDiff;
        }
        
        if ( mouseDoubleClickThreshold > timeDiff ) {
            clickCount=2;
            mouseUpClickTime = 0;
        }
        else {
            clickCount=1;
            mouseUpClickTime = eventTime;
        }
        if(clickCount==2) {
            if(tblServer.isEnabled()==true) {
                String temp=(String)tblServer.getValueAt(tblServer.getSelectedRow(),0);
                System.out.println(temp);
                if(temp.substring(0,1).equals("<")) {
                    currentServerPath=currentServerPath+temp.substring(1,temp.length()-1)+"\\";
                    sendString=temp;
                    sendCom=false;
                    tblServer.enable(false);
                    cbbServerPath.addItem((Object)currentServerPath);
                    cbbServerPath.setSelectedItem((Object)currentServerPath);
                    while(sendCom);
                    //sendCommand="PWD";
                    
                }
            }
        }
    }//GEN-LAST:event_tblServerMouseClicked
 
 private void cbbServerPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbbServerPathActionPerformed
        sendString=(String)cbbServerPath.getSelectedItem();
        sendCom=false;
        sendCommand="CWD";
        cbbServerPath=sortCBB(cbbServerPath);
        cbbServerPath.setSelectedItem((Object)currentServerPath);
        
        
        
        
    }//GEN-LAST:event_cbbServerPathActionPerformed
    
    private void cbbServerPathItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbServerPathItemStateChanged
                                                            }//GEN-LAST:event_cbbServerPathItemStateChanged
    
    private void btnServerUpMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnServerUpMousePressed
        int count=0;
        boolean test=false;
        String ans="",root="";
        
        for(int i=currentServerPath.length();i>0;i--) {
            String temp=currentServerPath.substring(i-1,i);
            if(temp.equals("\\")) {
                if(count==1) {
                    test=true;
                }
                count=count+1;
            }
            
            if(test==true) {
                ans=temp+ans;
            }
            root=temp+root;
        }
        
        if(count==1)
            currentServerPath=root;
        else
            currentServerPath=ans;
        
        
        //         cbbServerPath.addItem((Object)currentServerPath);
        cbbServerPath.setSelectedItem((Object)currentServerPath);
        
    }//GEN-LAST:event_btnServerUpMousePressed
    
    private void cbbClientPathItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbClientPathItemStateChanged
        // Add your handling code here:
    }//GEN-LAST:event_cbbClientPathItemStateChanged
 
 
//CWD==Change working directory
 
if (sendCommand.equals("CWD")) {
   					txtHistory.append(hrd.getCurrentDate()+" "+ t.getTime()+" > CWD "+sendString+".\n");                    
                    sendString=sendCommand+sp+sendString+crlf;
                    outMsg.write(sendString.getBytes());
                    txtHistory.append(hrd.getCurrentDate()+" "+ t.getTime()+" > Command Sent, Wait for server reply.\n");
                    sendString="";
                    sendCommand="";
                    message="";
                    
                    while(inMsg.available()==0);
                    while (inMsg.available()>0) {
                        message+=(char)inMsg.read();
                    }
                    
                    System.out.println("message :"+message);
                    if(message.equals("200")) {
                        message="";
	                   txtHistory.append(hrd.getCurrentDate()+" "+ t.getTime()+" > Success Change Working Directory. \n");
                        sendCommand="PWD";
                    }
					else
					{
						txtHistory.append(hrd.getCurrentDate()+" "+ t.getTime()+" > Fail To Change Working Directory. \n");
					}
 
                    
                }

Topic: JToggleButton Question Previous Topic   Next Topic Topic: Sockets & images

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use