Search in sources :

Example 21 with AbstractFile

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);
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileTableModel(com.mucommander.ui.main.table.FileTableModel) Rectangle(java.awt.Rectangle) FileTable(com.mucommander.ui.main.table.FileTable) TablePopupMenu(com.mucommander.ui.main.menu.TablePopupMenu)

Example 22 with AbstractFile

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);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 23 with AbstractFile

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;
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) IOException(java.io.IOException) Vector(java.util.Vector)

Example 24 with AbstractFile

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);
    }
}
Also used : Cursor(java.awt.Cursor) ViewerPresenter(com.mucommander.viewer.ViewerPresenter) MenuToolkit(com.mucommander.commons.util.ui.helper.MenuToolkit) Function(java.util.function.Function) WarnUserException(com.mucommander.viewer.WarnUserException) FileViewerService(com.mucommander.viewer.FileViewerService) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) JMenuItem(javax.swing.JMenuItem) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper) JFrame(javax.swing.JFrame) Translator(com.mucommander.text.Translator) JComponent(javax.swing.JComponent) JMenuBar(javax.swing.JMenuBar) KeyStroke(javax.swing.KeyStroke) FileTable(com.mucommander.ui.main.table.FileTable) ButtonGroup(javax.swing.ButtonGroup) JMenu(javax.swing.JMenu) IOException(java.io.IOException) KeyEvent(java.awt.event.KeyEvent) Logger(java.util.logging.Logger) List(java.util.List) FileViewer(com.mucommander.viewer.FileViewer) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) AbstractFile(com.mucommander.commons.file.AbstractFile) MnemonicHelper(com.mucommander.commons.util.ui.helper.MnemonicHelper)

Example 25 with AbstractFile

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();
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) ExtensionFilenameFilter(com.mucommander.commons.file.filter.ExtensionFilenameFilter) Vector(java.util.Vector) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

AbstractFile (com.mucommander.commons.file.AbstractFile)150 IOException (java.io.IOException)49 FileURL (com.mucommander.commons.file.FileURL)19 FileSet (com.mucommander.commons.file.util.FileSet)11 FileTable (com.mucommander.ui.main.table.FileTable)11 DialogAction (com.mucommander.ui.dialog.DialogAction)10 File (java.io.File)9 List (java.util.List)8 MainFrame (com.mucommander.ui.main.MainFrame)6 InputStream (java.io.InputStream)6 Vector (java.util.Vector)6 AbstractArchiveEntryFile (com.mucommander.commons.file.archive.AbstractArchiveEntryFile)5 ProtocolFile (com.mucommander.commons.file.protocol.ProtocolFile)5 LocalFile (com.mucommander.commons.file.protocol.local.LocalFile)5 ProgressDialog (com.mucommander.ui.dialog.file.ProgressDialog)5 FolderPanel (com.mucommander.ui.main.FolderPanel)5 FileTableModel (com.mucommander.ui.main.table.FileTableModel)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 UnsupportedFileOperationException (com.mucommander.commons.file.UnsupportedFileOperationException)4