private ArrayList<Integer> getValuesFromClipboard() {
    ArrayList<Integer> dataValues = new ArrayList<Integer>();

    try {
      log.debug("Clipboard contents: " + system.getName());
      String trstring =
          (String) (system.getContents(this).getTransferData(DataFlavor.stringFlavor));
      System.out.println("String is:" + trstring);
      StringTokenizer st1 = new StringTokenizer(trstring, "\n");

      String rowstring;
      for (int i = 0; st1.hasMoreTokens(); i++) {
        rowstring = st1.nextToken();

        String[] values = rowstring.split("\t");
        if (values.length == 0) {
          values = rowstring.split(",");
        }
        if (values.length == 0) {
          values = rowstring.split(" ");
        }

        if (values.length == 1) {
          Integer v = Integer.valueOf(values[0]);
          dataValues.add(v);
        } else if (values.length == 2) {
          Integer v = Integer.valueOf(values[1]);
          dataValues.add(v);
        } else {
          log.error("Unable to extract data from clipboard");
          return null;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      log.error("Unable to extract data from clipboard");
    }

    return dataValues;
  }
Example #2
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == upbtn) {
      TreePath p = currentPath.getParentPath();
      path = currentPath;
      if (p != null) {
        tree.setSelectionPath(p);
      }
      downbtn.setEnabled(true);
    }
    if (e.getSource() == downbtn) {
      if (path != null) {
        tree.setSelectionPath(path);
      }
      downbtn.setEnabled(false);
    }
    if (e.getSource() == Turn) {
      String text = addressText.getText();
      File f = new File(text);
      tablemodel.addAllFiles(treeview.GetAll(f));
    }
    if (e.getSource() == FileNewFolder || e.getSource() == NewFolder) {}
    if (e.getSource() == FileNewFile || e.getSource() == FileNewFile) {}
    if (e.getSource() == FileDelete || e.getSource() == Delete) {
      File f = tablemodel.getFile(table.getSelectedRow());
      if (f.isFile()) f.delete();
      else if (f.isDirectory()) {
        File[] child = f.listFiles();
        for (int i = 0; i < child.length; i++) {
          child[i].delete();
        }
        f.delete();
      }
      refreshNode();
    }
    if (e.getSource() == FileRename || e.getSource() == Rename) {}
    if (e.getSource() == FileNature || e.getSource() == Nature) {
      JOptionPane shuxing = new JOptionPane();
      File currentFile = tablemodel.getFile(table.getSelectedRow());
      String str;
      if (currentFile.isDirectory()) str = "文件夹路径:" + currentFile.getAbsolutePath() + "\n";
      else str = "文件路径:" + currentFile.getAbsolutePath() + "\n";
      String str1 = "是否可读:" + currentFile.canRead() + "\n";
      String str2 = "是否可写:" + currentFile.canWrite() + "\n";
      String str3 = "文件的长度:" + currentFile.length() + "M\n";
      SimpleDateFormat s = new SimpleDateFormat("yyyy年MM年dd日HH小时mm分钟ss秒");
      String str4 = "文件上次修改的时间:" + s.format(new Date(currentFile.lastModified())) + "\n";
      String str5 = "文件是否被隐藏:" + currentFile.isHidden() + "\n";
      shuxing.showMessageDialog(
          null, str + str1 + str2 + str3 + str4 + str5, "属性", JOptionPane.ERROR_MESSAGE);
    }
    if (e.getSource() == EditCopy || e.getSource() == Copy) {}

    if (e.getSource() == EditCut || e.getSource() == Cut) {
      File f = tablemodel.getFile(table.getSelectedRow());
      if (f.isFile()) {
        StringSelection text = new StringSelection(f.getName());
        board.setContents(text, null);
        f.delete();
      } else if (f.isDirectory()) {
        StringSelection text = new StringSelection(f.getName());
        board.setContents(text, null);
        File[] child = f.listFiles();
        for (int i = 0; i < child.length; i++) {
          child[i].delete();
        }
        f.delete();
      }
      refreshNode();
    }
    if (e.getSource() == EditPaste || e.getSource() == Paste) {
      File f = tablemodel.getFile(table.getSelectedRow());
      if (f.isFile()) {
        String boardfile = board.getName();
        File file = new File(boardfile);
      }
    }
    if (e.getSource() == EditSelectAll || e.getSource() == SelectAll) {
      table.selectAll();
    }
    if (e.getSource() == EditCancel || e.getSource() == Cancel) {}
    if (e.getSource() == CheckThumbnail
        || e.getSource() == CheckTile
        || e.getSource() == CheckIcon
        || e.getSource() == CheckList
        || e.getSource() == CheckInformation) {
      JOptionPane.showMessageDialog(null, "该功能还为完善,敬请期待!", "提示", JOptionPane.ERROR_MESSAGE);
    }
    if (e.getSource() == FileExit) {
      System.exit(0);
    }
  }