use of com.mucommander.ui.main.table.SortInfo in project mucommander by mucommander.
the class MainFrame method swapFolders.
/**
* 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();
}
Aggregations