use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class OpenCommandPromptAction method toggleEnabledState.
@Override
protected void toggleEnabledState() {
AbstractFile currentFolder = mainFrame.getActivePanel().getCurrentFolder();
setEnabled(currentFolder.getURL().getScheme().equals(FileProtocols.FILE) && !currentFolder.isArchive() && !currentFolder.hasAncestor(AbstractArchiveEntryFile.class));
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class OpenInBothPanelsAction method performAction.
// - Action code ---------------------------------------------------------------------
// -----------------------------------------------------------------------------------
/**
* Opens the current selection and its inactive equivalent.
*/
@Override
public void performAction() {
Thread openThread;
AbstractFile selectedFile;
AbstractFile otherFile = null;
// Retrieves the current selection, aborts if none (should not normally happen).
if ((selectedFile = mainFrame.getActiveTable().getSelectedFile(true, true)) == null || !selectedFile.isBrowsable())
return;
try {
FileTableModel otherTableModel = mainFrame.getInactiveTable().getFileTableModel();
if (mainFrame.getActiveTable().isParentFolderSelected()) {
otherFile = otherTableModel.getParentFolder();
} else {
// Look for a file in the other table with the same name as the selected one (case insensitive)
int fileCount = otherTableModel.getFileCount();
String targetFilename = selectedFile.getName();
for (int i = otherTableModel.getFirstMarkableRow(); i < fileCount; i++) {
otherFile = otherTableModel.getCachedFileAtRow(i);
if (otherFile.getName().equalsIgnoreCase(targetFilename))
break;
if (i == fileCount - 1)
otherFile = null;
}
}
} catch (Exception e) {
otherFile = null;
}
// Opens 'file' in the active panel.
openThread = mainFrame.getActivePanel().tryChangeCurrentFolder(selectedFile);
// Opens 'otherFile' (if any) in the inactive panel.
if (otherFile != null) {
// Waits for the previous folder change to be finished.
if (openThread != null) {
while (openThread.isAlive()) {
try {
openThread.join();
} catch (InterruptedException e) {
}
}
}
mainFrame.getInactivePanel().tryChangeCurrentFolder(otherFile);
}
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class OpenNativelyAction method performAction.
@Override
public void performAction() {
AbstractFile selectedFile = mainFrame.getActiveTable().getSelectedFile(true, true);
if (selectedFile == null)
return;
// file is not on a local filesystem or file is an archive entry
if (!LocalFile.SCHEMA.equals(selectedFile.getURL().getScheme()) || selectedFile.hasAncestor(AbstractArchiveEntryFile.class)) {
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
TempExecJob job = new TempExecJob(progressDialog, mainFrame, selectedFile);
progressDialog.start(job);
} else {
// Tries to execute file with native file associations
try {
OpenAction.openFile(getMainFrame(), selectedFile);
RecentExecutedFilesQL.addFile(selectedFile);
} catch (IOException | UnsupportedOperationException e) {
InformationDialog.showErrorDialog(mainFrame);
}
}
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class PasteClipboardFilesAction method performAction.
@Override
public void performAction() {
// Retrieve clipboard files
FileSet clipboardFiles = ClipboardSupport.getClipboardFiles();
if (clipboardFiles == null || clipboardFiles.isEmpty())
return;
// Start copying files
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
AbstractFile destFolder = mainFrame.getActivePanel().getCurrentFolder();
CopyJob job = new CopyJob(progressDialog, mainFrame, clipboardFiles, destFolder, null, TransferMode.COPY, FileCollisionDialog.FileCollisionAction.ASK);
progressDialog.start(job);
}
use of com.mucommander.commons.file.AbstractFile in project mucommander by mucommander.
the class QuickFindAction method performAction.
@Override
public void performAction() {
AbstractFile currentFile = mainFrame.getActivePanel().getCurrentFolder();
FileURL searchURL = SearchUtils.toSearchURL(currentFile);
LocationTextField locationTextField = mainFrame.getActivePanel().getLocationTextField();
locationTextField.setText(searchURL.toString());
locationTextField.requestFocus();
}
Aggregations