use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class ShowFilePopupMenuAction method performAction.
@Override
public void performAction() {
try {
AbstractFile selectedFile = mainFrame.getActiveTable().getSelectedFile();
FileTable fileTable = mainFrame.getActiveTable();
FileTableModel tableModel = (FileTableModel) fileTable.getModel();
int selectedRow = fileTable.getSelectedRow();
Rectangle rect = fileTable.getCellRect(selectedRow, fileTable.convertColumnIndexToView(Column.NAME.ordinal()), true);
boolean parentFolderSelected = selectedRow == 0 && tableModel.hasParentFolder();
new TablePopupMenu(mainFrame, fileTable.getFolderPanel().getCurrentFolder(), parentFolderSelected ? null : selectedFile, parentFolderSelected, tableModel.getMarkedFiles()).show(fileTable, rect.x + rect.width, rect.y);
} catch (Exception e) {
InformationDialog.showErrorDialog(mainFrame);
}
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class ShowInEnclosingFolderAction method performAction.
@Override
public void performAction() {
AbstractFile currentFolder = mainFrame.getActivePanel().getCurrentFolder();
if (!SearchFile.SCHEMA.equals(currentFolder.getURL().getScheme()))
return;
AbstractFile file = mainFrame.getActiveTable().getSelectedFile(true, true);
if (file == null)
return;
AbstractFile enclosingFolder = file.getParent();
mainFrame.getInactivePanel().getTabs().add(enclosingFolder, file);
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class FilesService method getPossibleCompletions.
public Vector<String> getPossibleCompletions(String path) {
Vector<String> result = new Vector<String>();
int index = Math.max(path.lastIndexOf('\\'), path.lastIndexOf('/'));
if (index != -1) {
String currentDirectoryName = path.substring(0, index + 1);
AbstractFile currentDirectory = FileFactory.getFile(currentDirectoryName);
if (currentDirectory != null && currentDirectory.exists()) {
long currentDirectoryDate = currentDirectory.getDate();
if (cachedDirectoryName == null || !cachedDirectoryName.equals(currentDirectoryName) || currentDirectoryDate != cachedDirectoryDate) {
AbstractFile[] currentDirectoryFiles;
try {
currentDirectoryFiles = getFiles(currentDirectory);
} catch (IOException e) {
LOGGER.debug("Caught exception", e);
return new Vector<String>();
}
int nbCurrentDirectoryFiles = currentDirectoryFiles.length;
cachedDirectoryFileNames = new String[nbCurrentDirectoryFiles];
for (int i = 0; i < nbCurrentDirectoryFiles; i++) {
AbstractFile abstractFileI = currentDirectoryFiles[i];
cachedDirectoryFileNames[i] = abstractFileI.getName() + (abstractFileI.isDirectory() ? abstractFileI.getSeparator() : "");
}
Arrays.sort(cachedDirectoryFileNames, String.CASE_INSENSITIVE_ORDER);
cachedDirectoryName = currentDirectory.getAbsolutePath() + (currentDirectory.isDirectory() ? "" : currentDirectory.getSeparator());
cachedDirectoryDate = currentDirectoryDate;
}
final String prefix = index == path.length() - 1 ? null : path.substring(index + 1).toLowerCase();
result = PrefixFilter.createPrefixFilter(prefix).filter(cachedDirectoryFileNames);
}
}
return result;
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class FileViewerPresenter method show.
@Override
protected void show(AbstractFile file) throws IOException {
setCurrentFile(file);
if (fileViewer == null) {
MnemonicHelper menuItemMnemonicHelper = new MnemonicHelper();
viewerMenu.addSeparator();
closeMenuItem = MenuToolkit.addMenuItem(viewerMenu, Translator.get("file_viewer.close"), menuItemMnemonicHelper, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), (e) -> {
fileViewer.close();
getFrame().dispose();
});
viewerMenu.add(closeMenuItem);
switchFileViewer(0);
}
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class ThemeManager method getThemeNames.
private static Iterator<String> getThemeNames(AbstractFile themeFolder) {
AbstractFile[] files;
Vector<String> names;
try {
files = themeFolder.ls(new ExtensionFilenameFilter(".xml"));
names = new Vector<String>();
for (AbstractFile file : files) names.add(getThemeName(file));
return names.iterator();
} catch (Exception e) {
return new Vector<String>().iterator();
}
}
Aggregations