use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.
the class StressTester method run.
public void run() {
Random random = new Random();
MainFrame mainFrame = WindowManager.getCurrentMainFrame();
while (run) {
if (random.nextInt(2) == 0)
ActionManager.performAction(com.mucommander.ui.action.impl.SwitchActiveTableAction.Descriptor.ACTION_ID, mainFrame);
FolderPanel folderPanel = mainFrame.getActivePanel();
FileTable fileTable = mainFrame.getActiveTable();
AbstractFile currentFolder = folderPanel.getCurrentFolder();
try {
AbstractFile parentFolder = currentFolder.getParent();
AbstractFile[] children = currentFolder.ls();
// 1 in 3 chance to go up if folder has children
if (children.length == 0 || (random.nextInt(3) == 0 && parentFolder != null)) {
fileTable.selectRow(0);
ActionManager.performAction(com.mucommander.ui.action.impl.OpenAction.Descriptor.ACTION_ID, mainFrame);
} else {
AbstractFile randomChild = children[random.nextInt(children.length)];
if (!randomChild.isBrowsable())
continue;
// Try to ls() in RandomChild to trigger an IOException if folder is not readable
// so that no error dialog pops up when calling tryChangeCurrentFolder()
randomChild.ls();
fileTable.selectFile(randomChild);
ActionManager.performAction(com.mucommander.ui.action.impl.OpenAction.Descriptor.ACTION_ID, mainFrame);
// folderPanel.tryChangeCurrentFolder(randomChild, true);
}
} catch (Exception e) {
LOGGER.debug("Caught Exception", e);
}
LOGGER.trace("Sleeping for a bit...");
try {
Thread.sleep(100 + random.nextInt(200));
} catch (InterruptedException e) {
LOGGER.debug("Caught InterruptedException", e);
}
}
}
use of com.mucommander.ui.main.table.FileTable 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();
}
use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.
the class FileViewerPresenter method goToFile.
@Override
public void goToFile(Function<Integer, Integer> advance, FileViewerService viewerService) throws IOException {
FileTable fileTable = getFrame().getMainFrame().getActiveTable();
AbstractFile newFile;
int originalRow = fileTable.getSelectedRow();
boolean canView;
do {
int currentRow = fileTable.getSelectedRow();
int newRow = advance.apply(currentRow);
if (newRow < 0 || newRow >= fileTable.getRowCount()) {
fileTable.selectRow(originalRow);
return;
}
fileTable.selectRow(newRow);
newFile = fileTable.getSelectedFile();
try {
canView = viewerService.canViewFile(newFile);
} catch (WarnUserException ex) {
canView = false;
}
} while (newFile == null || !canView);
setCurrentFile(newFile);
fileViewer.open(newFile);
}
use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.
the class InternalViewAction method performInternalAction.
// - AbstractViewerAction implementation ---------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------
@Override
protected void performInternalAction(AbstractFile file) {
if (file.isDirectory()) {
FileTable activeTable = mainFrame.getActiveTable();
FileTableModel fileTableModel = (FileTableModel) activeTable.getModel();
fileTableModel.startDirectorySizeCalculation(activeTable, file);
} else {
ViewerRegistrar.createViewerFrame(mainFrame, file, getIcon().getImage());
}
}
use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.
the class InvertSelectionAction method performAction.
@Override
public void performAction() {
FileTable fileTable = mainFrame.getActiveTable();
FileTableModel tableModel = fileTable.getFileTableModel();
// Starts at 1 if current folder is not root so that '..' is not marked
AbstractFile file;
int nbRows = tableModel.getRowCount();
for (int i = tableModel.getFirstMarkableRow(); i < nbRows; i++) {
file = tableModel.getFileAtRow(i);
tableModel.setRowMarked(i, !tableModel.isRowMarked(i));
}
fileTable.repaint();
// Notify registered listeners that currently marked files have changed on the FileTable
fileTable.fireMarkedFilesChangedEvent();
}
Aggregations