Package de.kout.wlFxp.ftp

Examples of de.kout.wlFxp.ftp.FtpFile


    int n = list.size();
    for (int i = n / 2; i > 0; i--) {
      reheap(list, i, n, sortBy, prio, prioList);
    }
    for (int m = n; m > 0; m--) {
      FtpFile t = (FtpFile) list.elementAt(0);
      list.setElementAt(list.elementAt(m - 1), 0);
      list.setElementAt(t, m-1);
      reheap(list, 1, m - 1, sortBy, prio, prioList);
    }
  }
View Full Code Here


   *@param  sortBy  Description of the Parameter
   *@return         result of compareToIgnoreCase
   */
  private static int compareFiles(Object o1, Object o2, String sortBy,boolean prio, Vector prioList) {
    int ret;
    FtpFile f1 = (FtpFile) o1;
    FtpFile f2 = (FtpFile) o2;
    if (prio) {
      int m1 = matches(prioList, f1.getName()), m2 = matches(prioList, f2.getName());
      if (m1 != -1 || m2 != -1) {
        if (m1 > m2) {
          return -1;
        }
        else if (m2 > m1) {
          return 1;
        }
      }
    }
    if (f1.isDirectory() && !f2.isDirectory()) {
      return -1;
    }
    if (!f1.isDirectory() && f2.isDirectory()) {
      return 1;
    }
    if (sortBy.equals("Name")) {
      return f1.getName().compareToIgnoreCase(f2.getName());
    } else if (sortBy.equals("IName")) {
      return -f1.getName().compareToIgnoreCase(f2.getName());
    } else if (sortBy.equals("Size")) {
      ret = (int) (f1.getSize() - f2.getSize());
    } else if (sortBy.equals("ISize")) {
      ret = (int) (f2.getSize() - f1.getSize());
    } else if (sortBy.equals("Date")) {
      if (f1.getDate().indexOf("/") == 2 && f2.getDate().indexOf("/") > 2) {
        return 1;
      } else if (f1.getDate().indexOf("/") > 2 && f2.getDate().indexOf("/") == 2) {
        return -1;
      }
      ret = f1.getDate().compareToIgnoreCase(f2.getDate());
    } else if (sortBy.equals("IDate")) {
      if (f1.getDate().indexOf("/") == 2 && f2.getDate().indexOf("/") > 2) {
        return -1;
      } else if (f1.getDate().indexOf("/") > 2 && f2.getDate().indexOf("/") == 2) {
        return 1;
      }
      ret = -f1.getDate().compareToIgnoreCase(f2.getDate());
    } else {
      return f1.getName().compareToIgnoreCase(f2.getName());
    }
    if (ret == 0) {
      ret = f1.getName().compareToIgnoreCase(f2.getName());
    }
    return ret;
  }
View Full Code Here

   */
  public static Vector parseList(String output, String ftpDir) {
    String[] completeList = split(output, "\r\n");
  //  FtpFile[] tmpfiles = new FtpFile[completeList.length];
    Vector files = new Vector(completeList.length, 100);
    FtpFile tmp;
    int k = 0;
    int index;
    for (int i = 0; i < completeList.length; i++) {
//      if (!Pattern.matches("([A-Za-z][A-Za-z][A-Za-z]) .[0-9] [0-9 ][0-9]", completeList[i]))
      // ...
      index = -1;
      int j = 0;
      int tindex = 0;
      while (j < monthsWS.length) {
        tindex = completeList[i].indexOf(monthsWS[j]);
        if (tindex != -1 && (index == -1 || tindex < index)) {
          index = tindex;
        }
        j++;
      }
      if (index == -1) {
        continue;
      }
//      System.out.println(index);
      tmp = new FtpFile("");
      files.addElement(tmp);
      if (completeList[i].indexOf(" -> ") != -1) {
        completeList[i] = completeList[i].substring(0, completeList[i].indexOf(" -> "));
      }
      tmp.setName(completeList[i].substring(
          completeList[i].substring(index + 10,
          completeList[i].length()).indexOf(" ")
           + 11 + index,
          completeList[i].length()));
      // if the server outputs the "." or ".." with list
      if (tmp.getName().equals(".")
           || tmp.getName().equals("..")) {
        files.removeElementAt(files.size()-1);
        continue;
      }
      tmp.setSize(Long.parseLong(completeList[i].substring(completeList[i].substring(0, index).lastIndexOf(" ") + 1, index)));
      tmp.setMode(completeList[i].substring(0, 10));
      tmp.setFtpMode(true);
      tmp.setDate(parseDate(completeList[i].substring(index, index + 13)));
      if (ftpDir.equals("/"))
        tmp.setAbsolutePath(ftpDir + tmp.getName());
      else
        tmp.setAbsolutePath(ftpDir +"/"+tmp.getName());
      k++;
    }
    return files;
  }
View Full Code Here

        wlPanel panel = (wlPanel) cmd.firstElement();
        cmd.removeElementAt(0);
        try {
          Transfer transfer = (Transfer) cmd.firstElement();
          cmd.removeElementAt(0);
          FtpFile file = transfer.getSource();
          FtpFile to = transfer.getDest();
          // if dir add files in dir to queue
          if (file.isDirectory()) {
            new File(to.getAbsolutePath()).mkdir();
            frame.getQueueList().removeFirst();
            frame.getQueueList().updateView();
            FtpFile[] files = file.list();
            for (int i = files.length - 1; i >= 0; i--) {
              FtpFile tmp = new FtpFile(files[i].getName());
              tmp.setFtpMode(false);
              tmp.setAbsolutePath(to.getAbsolutePath() + File.separator + files[i].getName());
              frame.getQueueList().addAtBegin(new Transfer(files[i], tmp, transfer.modeFrom, transfer.modeTo, transfer.from_to, null, null));
            }
          // copy the file
          } else {
            copyFileToDir(file, to, panel);
View Full Code Here

      panel.open();
    } else if (cmd.equals("Rename")) {
      int row = panel.view.getSelectedIndex();
      if (row == 0)
        return;
      FtpFile entry = (FtpFile) panel.view.getElementAt(row);
      panel.renameFile =  entry;
      new InputDialog(panel, "Rename", entry.getName(), false);
    } else if (cmd.equals("refresh")) {
      panel.updateView();
    } else if (cmd.equals("transfer")) {
      panel.addTransfers();
      panel.frame.transfer();
View Full Code Here

        if (row == 0) {
          if (new File(panel.dir).getParent() != null) {
            panel.setDir(new File(panel.dir).getParent());
          }
        } else {
          FtpFile entry = (FtpFile) panel.view.getElementAt(row);
          if (entry.isDirectory()) {
            // add the entry
            if (panel.dir.endsWith(File.separator)) {
              panel.setDir(panel.dir + entry.getName());
            } else {
              panel.setDir(panel.dir + File.separator + entry.getName());
            }
          }
        }
      } else if (panel.mode == panel.FTP) {
        // if is Directory
        // make parent
        if (row == 0) {
          panel.ftpSession.cdup();
        } else {
          FtpFile entry = (FtpFile) panel.view.getElementAt(row);
          if (entry.isDirectory() || entry.isLink()) {
            // add entry
            if (panel.ftpDir.endsWith("/")) {
              panel.setDir(panel.ftpDir + entry.getName());
            } else {
              panel.setDir(panel.ftpDir + "/" + entry.getName());
            }
          }
        }
      }
    }
View Full Code Here

        if (panel.view.rowAtPoint(p) == 0) {
          if (new File(panel.dir).getParent() != null) {
            panel.setDir(new File(panel.dir).getParent());
          }
        } else {
          FtpFile entry = (FtpFile) panel.view.getElementAt(p);
          if (entry.isDirectory()) {
            // add the entry
            if (panel.dir.endsWith(File.separator)) {
              panel.setDir(panel.dir + entry.getName());
            } else {
              panel.setDir(panel.dir + File.separator + entry.getName());
            }
          }
        }
      } else if (panel.mode == panel.FTP) {
        // if is Directory
        // make parent
        if (panel.view.rowAtPoint(p) == 0) {
          panel.ftpSession.cdup();
        } else {
          FtpFile entry = (FtpFile) panel.view.getElementAt(p);
          if (entry.isDirectory() || entry.isLink()) {
            // add entry
            if (panel.ftpDir.endsWith("/")) {
              panel.setDir(panel.ftpDir + entry.getName());
            } else {
              panel.setDir(panel.ftpDir + "/" + entry.getName());
            }
          }
        }
      }
    } else {
View Full Code Here

    JPanel p = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc;
    p.setLayout(gbl);

    FtpFile from = t.getSource();
    FtpFile to = t.getDest();
    String text = "overwrite \"" + to.getName() + "\" size: " + to.getSize()
         + " with: \"" + from.getName() + "\" size: " + from.getSize() + " ?";
    rest = to.getSize();

    label = new JLabel(text);
    gbc = makegbc(0, 0, 3, 1);
    gbl.setConstraints(label, gbc);
    p.add(label);

    if (to.getSize() < from.getSize()) {
      resume = new JButton("Resume");
      resume.addActionListener(this);
      gbc = makegbc(0, 1, 1, 1);
      gbl.setConstraints(resume, gbc);
      p.add(resume);
View Full Code Here

      return "..";
    }
    if (files.size() >= index && index > 0) {
      return files.elementAt(index - 1);
    } else {
      return new FtpFile();
    }
  }
View Full Code Here

  public Object getValueAt(int rowIndex, int columnIndex) {
    if (rowIndex == 0) {
      if (columnIndex > 0) {
        return "";
      }
      return new FtpFile("..");
    }
    if (files.size() >= rowIndex && rowIndex > 0) {
      if (columnIndex == 0) {
        return (FtpFile) files.elementAt(rowIndex - 1);
      } else if (columnIndex == 1) {
        return String.valueOf(((FtpFile) files.elementAt(rowIndex - 1)).hSize);
      } else if (columnIndex == 2) {
        return ((FtpFile) files.elementAt(rowIndex - 1)).getMode();
      } else if (columnIndex == 3) {
        return ((FtpFile) files.elementAt(rowIndex - 1)).getDate();
      }
    }
    return new FtpFile();
  }
View Full Code Here

TOP

Related Classes of de.kout.wlFxp.ftp.FtpFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.