Пример #1
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();
  }
Пример #2
0
  /**
   * Creates a new main frame set to the given initial folders.
   *
   * @param leftInitialFolders the initial folders to display in the left panel's tabs
   * @param rightInitialFolders the initial folders to display in the right panel's tabs
   */
  public MainFrame(
      ConfFileTableTab[] leftTabs,
      int indexOfLeftSelectedTab,
      FileTableConfiguration leftTableConf,
      ConfFileTableTab[] rightTabs,
      int indexOfRightSelectedTab,
      FileTableConfiguration rightTableConf) {
    /*AbstractFile[] leftInitialFolders, AbstractFile[] rightInitialFolders,
    int indexOfLeftSelectedTab, int indexOfRightSelectedTab,
       FileURL[] leftLocationHistory, FileURL[] rightLocationHistory) { */
    init(
        new FolderPanel(this, leftTabs, indexOfLeftSelectedTab, leftTableConf),
        new FolderPanel(this, rightTabs, indexOfRightSelectedTab, rightTableConf));

    for (boolean isLeft = true; ; isLeft = false) {
      FileTable fileTable = isLeft ? leftTable : rightTable;
      fileTable.sortBy(
          Column.valueOf(
              MuConfigurations.getSnapshot()
                  .getVariable(
                      MuSnapshot.getFileTableSortByVariable(0, isLeft), MuSnapshot.DEFAULT_SORT_BY)
                  .toUpperCase()),
          !MuConfigurations.getSnapshot()
              .getVariable(
                  MuSnapshot.getFileTableSortOrderVariable(0, isLeft),
                  MuSnapshot.DEFAULT_SORT_ORDER)
              .equals(MuSnapshot.SORT_ORDER_DESCENDING));

      FolderPanel folderPanel = isLeft ? leftFolderPanel : rightFolderPanel;
      folderPanel.setTreeWidth(
          MuConfigurations.getSnapshot()
              .getVariable(MuSnapshot.getTreeWidthVariable(0, isLeft), 150));
      folderPanel.setTreeVisible(
          MuConfigurations.getSnapshot()
              .getVariable(MuSnapshot.getTreeVisiblityVariable(0, isLeft), false));

      if (!isLeft) break;
    }
  }