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");
}
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);
}
});
}
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;
}
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();
}
}
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());
}
Aggregations