Example #1
0
  /** *************************************************** */
  private void setCopyList(TreeNode copiedNode) {
    if (index++ == 0) {
      copyFile = new Vector<TreeNode>();
      copyFile.add(copiedNode);

      copiedList.add(copyFile);
      pos = copiedNode.getPath().toString().lastIndexOf(File.separator);
    }

    File[] copieFiles = copiedNode.getFile().listFiles();

    if (copieFiles != null) {
      for (File file : copieFiles) {
        if (file.isDirectory()) {
          copyFile = new Vector<TreeNode>();

          TreeNode node_ = new TreeNode(file);
          copyFile.add(node_);
          copiedList.add(copyFile);

          setCopyList(node_);
        } else {
          copyFile = new Vector<TreeNode>();

          TreeNode node_ = new TreeNode(file);
          copyFile.add(node_);
          copiedList.add(copyFile);
        }
      }
    }
  }
Example #2
0
  /** *************************************************** */
  public void createNewFolder(TreeNode node) {
    String name = node.getPath() + File.separator;
    int index = getNewFolderIndex(name);

    if (index != 0) {
      name = name + "(" + (index + 1) + ")";
    }

    File folder = new File(name);
    folder.mkdir();

    TreeNode newFolder = new TreeNode(folder);
    node.addChild(newFolder);

    newNodeIndex = 0;
  }
Example #3
0
  public Vector<TreeNode> getPastedNode(TreeNode pastedFileNode) {
    Vector<TreeNode> pastedNodeList = new Vector<TreeNode>();

    if (pastedNodeList.size() != 0) {
      pastedNodeList.removeAllElements();
    }

    for (String path : pastedFilePath) {
      String pastedNodePath = pastedFileNode.getPath() + path;
      if (path.lastIndexOf(File.separator) == 0) {
        TreeNode pastedNode = new TreeNode(new File(pastedNodePath));
        pastedNodeList.add(pastedNode);
      }
    }
    return pastedNodeList;
  }
Example #4
0
  public void copy(TreeNode copiedFileNode, TreeNode pastedFileNode) {
    try {
      setCopyList(copiedFileNode);

      for (Vector<TreeNode> copyFile : copiedList) {
        String copyPath = copyFile.get(0).getPath().toString();
        String pastePath = pastedFileNode.getPath() + copyPath.substring(pos);

        pastedFilePath.add(copyPath.substring(pos));

        if (copyFile.get(0).getFile().isFile()) {
          copyFile(copyPath, pastePath);
        } else if (copyFile.get(0).getFile().isDirectory()) {
          new File(pastePath).mkdir();
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }