Example #1
0
  /** Copy constructor */
  public MainFrame(MainFrame mainFrame) {
    FolderPanel leftFolderPanel = mainFrame.getLeftPanel();
    FolderPanel rightFolderPanel = mainFrame.getRightPanel();
    FileTable leftFileTable = leftFolderPanel.getFileTable();
    FileTable rightFileTable = rightFolderPanel.getFileTable();

    init(
        new FolderPanel(
            this,
            new ConfFileTableTab[] {
              new ConfFileTableTab(leftFolderPanel.getCurrentFolder().getURL())
            },
            0,
            leftFileTable.getConfiguration()),
        new FolderPanel(
            this,
            new ConfFileTableTab[] {
              new ConfFileTableTab(rightFolderPanel.getCurrentFolder().getURL())
            },
            0,
            rightFileTable.getConfiguration()));

    // TODO: Sorting should be part of the FileTable configuration
    this.leftTable.sortBy(leftFileTable.getSortInfo());
    this.rightTable.sortBy(rightFileTable.getSortInfo());
  }
Example #2
0
  /**
   * Swaps the two FolderPanel instances: after a call to this method, the left FolderPanel will be
   * the right one and vice-versa.
   */
  public void swapFolders() {
    splitPane.remove(leftFolderPanel);
    splitPane.remove(rightFolderPanel);

    // Swaps the folder panels.
    FolderPanel tempPanel = leftFolderPanel;
    leftFolderPanel = rightFolderPanel;
    rightFolderPanel = tempPanel;

    // swaps folders trees
    int tempTreeWidth = leftFolderPanel.getTreeWidth();
    leftFolderPanel.setTreeWidth(rightFolderPanel.getTreeWidth());
    rightFolderPanel.setTreeWidth(tempTreeWidth);
    boolean tempTreeVisible = leftFolderPanel.isTreeVisible();
    leftFolderPanel.setTreeVisible(rightFolderPanel.isTreeVisible());
    rightFolderPanel.setTreeVisible(tempTreeVisible);

    // Resets the tables.
    FileTable tempTable = leftTable;
    leftTable = rightTable;
    rightTable = tempTable;

    // Preserve the sort order and columns visibility.
    TableColumnModel model = leftTable.getColumnModel();
    leftTable.setColumnModel(rightTable.getColumnModel());
    rightTable.setColumnModel(model);

    SortInfo sortInfo = (SortInfo) leftTable.getSortInfo().clone();

    leftTable.sortBy(rightTable.getSortInfo());
    leftTable.updateColumnsVisibility();

    rightTable.sortBy(sortInfo);
    rightTable.updateColumnsVisibility();

    // Do the swap and update the split pane
    splitPane.setLeftComponent(leftFolderPanel);
    splitPane.setRightComponent(rightFolderPanel);

    splitPane.doLayout();

    // Update split pane divider's location
    splitPane.updateDividerLocation();

    activeTable.requestFocus();
  }