Search in sources :

Example 81 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class ToolBarIO method saveToolBar.

/**
 * Writes the current tool bar to the user's tool bar file.
 * @throws IOException
 */
public static void saveToolBar() throws IOException {
    if (ToolBarAttributes.areDefaultAttributes()) {
        AbstractFile toolBarFile = getDescriptionFile();
        if (toolBarFile != null && toolBarFile.exists()) {
            LOGGER.info("Toolbar use default settings, removing descriptor file");
            toolBarFile.delete();
        } else
            LOGGER.debug("Toolbar not modified, not saving");
    } else if (toolBarWriter != null) {
        if (wasToolBarModified)
            toolBarWriter.write();
        else
            LOGGER.debug("Toolbar not modified, not saving");
    } else
        LOGGER.warn("Could not save toolbar. writer is null");
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 82 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class FoldersTreePanel method updateSelectedFolder.

/**
 * Updates selection in a tree to the current folder. When necessary updates
 * the current root of a tree. Invoked when location on folder pane has changed or
 * when a tree has been updated (when directories have been loaded).
 */
private void updateSelectedFolder() {
    final AbstractFile currentFolder = folderPanel.getCurrentFolder();
    // get selected directory (ignore archives - TODO make archives browsable (option))
    AbstractFile tempFolder = currentFolder;
    AbstractFile tempParent;
    while (!tempFolder.isDirectory()) {
        tempParent = tempFolder.getParent();
        if (tempParent == null)
            break;
        tempFolder = tempParent;
    }
    // compare selection on tree and panel
    final AbstractFile selectedFolder = tempFolder;
    TreePath selectionPath = tree.getSelectionPath();
    if (selectionPath != null) {
        if (selectionPath.getLastPathComponent() == currentFolder)
            return;
    }
    // check if root has changed
    final AbstractFile currentRoot = selectedFolder.getRoot();
    if (!currentRoot.equals(model.getRoot())) {
        model.setRoot(currentRoot);
    }
    // refresh selection on tree
    SwingUtilities.invokeLater(() -> {
        try {
            TreePath path = new TreePath(model.getPathToRoot(selectedFolder));
            tree.expandPath(path);
            tree.setSelectionPath(path);
            tree.scrollPathToVisible(path);
        } catch (Exception e) {
            LOGGER.debug("Caught exception", e);
        }
    });
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) TreePath(javax.swing.tree.TreePath)

Example 83 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class FoldersTreeRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    // get file name and create default component (JLabel) to display it
    AbstractFile file = (AbstractFile) value;
    String name = file.isRoot() ? file.getAbsolutePath() : file.getName();
    super.getTreeCellRendererComponent(tree, name, sel, expanded, leaf, row, hasFocus);
    setIcon(model.getCurrentIcon(file));
    return this;
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 84 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class AppearancePanel method importLookAndFeel.

private void importLookAndFeel() {
    // Used to select the theme to import.
    JFileChooser chooser;
    // Path to the theme to import.
    AbstractFile file;
    // Initialises the file chooser.
    chooser = createFileChooser();
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.addChoosableFileFilter(new ExtensionFileFilter("jar", Translator.get("prefs_dialog.jar_file")));
    chooser.setDialogTitle(Translator.get("prefs_dialog.import_look_and_feel"));
    chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    if (chooser.showDialog(parent, Translator.get("prefs_dialog.import")) == JFileChooser.APPROVE_OPTION) {
        file = FileFactory.getFile(chooser.getSelectedFile().getAbsolutePath());
        lastSelectedFolder = file.getParent();
        // Makes sure the file actually exists - JFileChooser apparently doesn't enforce that properly in all look&feels.
        if (!file.exists()) {
            InformationDialog.showErrorDialog(this, Translator.get("this_file_does_not_exist", file.getName()));
            return;
        }
        // Imports the JAR in a separate thread.
        lookAndFeelLibrary = file;
        new Thread(this).start();
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) JFileChooser(javax.swing.JFileChooser)

Example 85 with AbstractFile

use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.

the class DownloadDialog method computeInitialPath.

// ////////////////////////////////////////////
// TransferDestinationDialog implementation //
// ////////////////////////////////////////////
@Override
protected PathFieldContent computeInitialPath(FileSet files) {
    AbstractFile file = files.elementAt(0);
    // AbstractFile activeFolder = mainFrame.getActiveTable().getCurrentFolder();
    AbstractFile unactiveFolder = mainFrame.getInactivePanel().getCurrentFolder();
    // Fill text field with current folder's absolute path and file name
    return new PathFieldContent(unactiveFolder.getAbsolutePath(true) + file.getName());
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile)

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