use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class MainFrame method updateWindowTitle.
/**
* Updates this window's title to show currently active folder and window number.
* This method is called by this class and WindowManager.
*/
public void updateWindowTitle() {
// Update window title
String title = activeTable.getFolderPanel().getCurrentFolder().getAbsolutePath();
// Add the application name to window title on all OSs except MAC
if (!OsFamily.MAC_OS.isCurrent())
title += " - muCommander";
java.util.List<MainFrame> mainFrames = WindowManager.getMainFrames();
if (mainFrames.size() > 1)
title += " [" + (mainFrames.indexOf(this) + 1) + "]";
setTitle(title);
if (OsFamily.MAC_OS.isCurrent()) {
// Displays the document icon in the window title bar, works only for local files
AbstractFile currentFolder = activeTable.getFolderPanel().getCurrentFolder();
Object javaIoFile;
if (currentFolder.getURL().getScheme().equals(LocalFile.SCHEMA)) {
// with a java.io.File
if (currentFolder.hasAncestor(AbstractArchiveEntryFile.class))
javaIoFile = currentFolder.getParentArchive().getUnderlyingFileObject();
else
javaIoFile = currentFolder.getUnderlyingFileObject();
} else {
// If the current folder is not a local file, use the special /Network directory which is sort of
// 'Network Neighborhood'.
javaIoFile = new java.io.File("/Network");
}
// Note that for some strange reason (looks like a bug), setting the property to null won't remove
// the previous icon.
getRootPane().putClientProperty("Window.documentFile", javaIoFile);
}
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class StatusBar method updateSelectedFilesInfo.
/**
* Updates info about currently selected files ((nb of selected files, combined size), displayed on the left-side of this status bar.
*/
// Making this method synchronized creates a deadlock with FileTable
// public synchronized void updateSelectedFilesInfo() {
public void updateSelectedFilesInfo() {
// No need to waste precious cycles if status bar is not visible
if (!isVisible())
return;
FileTable currentFileTable = mainFrame.getActiveTable();
// Currently select file, can be null
AbstractFile selectedFile = currentFileTable.getSelectedFile(false, true);
FileTableModel tableModel = currentFileTable.getFileTableModel();
// Number of marked files, can be 0
int nbMarkedFiles = tableModel.getNbMarkedFiles();
// Combined size of marked files, 0 if no file has been marked
long markedTotalSize = tableModel.getTotalMarkedSize();
// number of files in folder
int fileCount = tableModel.getFileCount();
// Update files info based on marked files if there are some, or currently selected file otherwise
int nbSelectedFiles;
if (nbMarkedFiles == 0 && selectedFile != null)
nbSelectedFiles = 1;
else
nbSelectedFiles = nbMarkedFiles;
String filesInfo;
if (fileCount == 0) {
// Set status bar to a space character, not an empty string
// otherwise it will disappear
filesInfo = " ";
} else {
filesInfo = Translator.get("status_bar.selected_files", "" + nbSelectedFiles, "" + fileCount);
if (nbMarkedFiles > 0)
filesInfo += " - " + SizeFormat.format(markedTotalSize, selectedFileSizeFormat);
if (selectedFile != null)
filesInfo += " - " + selectedFile.getName();
}
// Update label
setStatusInfo(filesInfo);
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class CommandBarIO method saveCommandBar.
/**
* Writes the current command bar to the user's command bar file.
* @throws IOException
* @throws IOException
*/
public static void saveCommandBar() throws IOException {
if (CommandBarAttributes.areDefaultAttributes()) {
AbstractFile commandBarFile = getDescriptionFile();
if (commandBarFile != null && commandBarFile.exists()) {
LOGGER.info("Command bar use default settings, removing descriptor file");
commandBarFile.delete();
} else
LOGGER.debug("Command bar not modified, not saving");
} else if (commandBarWriter != null) {
if (wasCommandBarModified)
commandBarWriter.write();
else
LOGGER.debug("Command bar not modified, not saving");
} else
LOGGER.warn("Could not save command bar. writer is null");
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class MainFrameBuilder method getInitialPath.
/**
* Retrieves the user's initial path for the specified frame.
* <p>
* If the path found in preferences is either illegal or does not exist, this method will
* return the user's home directory - we assume this will always exist, which might be a bit
* of a leap of faith.
* </p>
* @param folderPanelType panel for which the initial path should be returned (either {@link com.mucommander.ui.main.FolderPanel.FolderPanelType.LEFT} or
* {@link #@link com.mucommander.ui.main.FolderPanel.FolderPanelType.RIGHT}).
* @return the user's initial path for the specified frame.
*/
protected FileURL getInitialPath(FolderPanelType folderPanelType) {
// Preferences configuration
MuPreferencesAPI preferences = MuConfigurations.getPreferences();
// Checks which kind of initial path we're dealing with.
boolean isCustom = preferences.getVariable(MuPreference.STARTUP_FOLDERS, MuPreferences.DEFAULT_STARTUP_FOLDERS).equals(MuPreferences.STARTUP_FOLDERS_CUSTOM);
String customPath = null;
// Handles custom initial paths.
if (isCustom) {
customPath = (folderPanelType == FolderPanelType.LEFT ? preferences.getVariable(MuPreference.LEFT_CUSTOM_FOLDER) : preferences.getVariable(MuPreference.RIGHT_CUSTOM_FOLDER));
}
AbstractFile result = null;
if (customPath == null || (result = FileFactory.getFile(customPath)) == null || !result.exists())
result = getHomeFolder();
LOGGER.debug("initial folder: " + result);
return result.getURL();
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class ToolBarIO method loadDescriptionFile.
/**
* Parses the XML file describing the toolbar's buttons and associated actions.
* If the file doesn't exist, default toolbar elements will be used.
*/
public static void loadDescriptionFile() throws Exception {
AbstractFile descriptionFile = getDescriptionFile();
if (descriptionFile != null && descriptionFile.exists()) {
ToolBarReader reader = new ToolBarReader(descriptionFile);
ToolBarAttributes.setActions(reader.getActionsRead());
} else
LOGGER.debug("User toolbar.xml was not found, using default toolbar");
toolBarWriter = ToolBarWriter.create();
}
Aggregations