Esempio n. 1
0
  private void changeCurrentNode() {

    boolean hasMatchSelectedName = false;
    FileObject[] children = null;
    try {
      children = currentFileObject.getChildren();
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (children == null) return;

    sortFiles(children);

    String selectedName = historyManager.getSelectedItem(currentFileObject.getName().getPath());
    table.removeAll();
    TableItem item;

    for (int i = 0; i < children.length; i++) {
      FileName fileName = children[i].getName();

      if (fileName.getBaseName().equals(selectedName)) {
        currentRow = i;
        hasMatchSelectedName = true;
      }

      item = new TableItem(table, SWT.NONE);
      item.setData("fileObject", children[i]);
      item.setText(fileName.getBaseName());

      try {
        FileType fileType = children[i].getType();
        FileContent fileContent = children[i].getContent();

        if (fileType.equals(FileType.FOLDER)) {
          item.setImage(folderImage);
          item.setText(1, "--");
          item.setText(2, StringUtil.formatDate(fileContent.getLastModifiedTime()));
        } else {
          item.setImage(fileImage);
          item.setText(1, StringUtil.formatSize(fileContent.getSize()));
          item.setText(2, StringUtil.formatDate(fileContent.getLastModifiedTime()));
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    if (!hasMatchSelectedName) currentRow = 0;
    table.setSelection(currentRow);
    table.setFocus();
  }