use of com.mucommander.job.impl.TempExecJob 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.job.impl.TempExecJob in project mucommander by mucommander.
the class RecentExecutedFilesQL method acceptListItem.
@Override
protected void acceptListItem(AbstractFile item) {
MainFrame mainFrame = WindowManager.getCurrentMainFrame();
if (item.getURL().getScheme().equals(LocalFile.SCHEMA) && (item.hasAncestor(LocalFile.class))) {
try {
DesktopManager.open(item);
} catch (IOException e) {
}
} else // Copies non-local file in a temporary local file and opens them using their native association.
{
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
TempExecJob job = new TempExecJob(progressDialog, mainFrame, item);
progressDialog.start(job);
}
}
use of com.mucommander.job.impl.TempExecJob in project mucommander by mucommander.
the class OpenAction method open.
/**
* Opens the specified file in the specified folder panel.
* <p>
* <code>file</code> will be opened using the following rules:
* <ul>
* <li>
* If <code>file</code> is {@link com.mucommander.commons.file.AbstractFile#isBrowsable() browsable},
* it will be opened in <code>destination</code>.
* </li>
* <li>
* If <code>file</code> is local, it will be opened using its native associations.
* </li>
* <li>
* If <code>file</code> is remote, it will first be copied in a temporary local file and
* then opened using its native association.
* </li>
* </ul>
* </p>
* @param file file to open.
* @param destination if <code>file</code> is browsable, folder panel in which to open the file.
*/
protected void open(AbstractFile file, FolderPanel destination) {
AbstractFile resolvedFile;
if (file.isSymlink()) {
resolvedFile = resolveSymlink(file);
if (resolvedFile == null) {
InformationDialog.showErrorDialog(mainFrame, Translator.get("cannot_open_cyclic_symlink"));
return;
}
} else
resolvedFile = file;
// Opens browsable files in the destination FolderPanel.
if (resolvedFile.isBrowsable()) {
resolvedFile = MuConfigurations.getPreferences().getVariable(MuPreference.CD_FOLLOWS_SYMLINKS, MuPreferences.DEFAULT_CD_FOLLOWS_SYMLINKS) ? resolvedFile : file;
FileTableTabs tabs = destination.getTabs();
if (BookmarkManager.isBookmark(resolvedFile.getURL())) {
String bookmarkLocation = BookmarkManager.getBookmark(resolvedFile.getName()).getLocation();
FileURL bookmarkURL;
try {
bookmarkURL = FileURL.getFileURL(bookmarkLocation);
} catch (MalformedURLException e) {
LOGGER.error("Failed to resolve bookmark's location: " + bookmarkLocation);
return;
}
if (tabs.getCurrentTab().isLocked())
tabs.add(bookmarkURL);
else
destination.tryChangeCurrentFolder(bookmarkURL);
} else {
if (tabs.getCurrentTab().isLocked())
tabs.add(resolvedFile);
else
destination.tryChangeCurrentFolder(resolvedFile);
}
} else // Opens local files using their native associations.
if (resolvedFile.getURL().getScheme().equals(LocalFile.SCHEMA) && (resolvedFile.hasAncestor(LocalFile.class))) {
try {
OpenAction.openFile(getMainFrame(), resolvedFile);
RecentExecutedFilesQL.addFile(resolvedFile);
} catch (IOException e) {
InformationDialog.showErrorDialog(mainFrame);
}
} else // Copies non-local file in a temporary local file and opens them using their native association.
{
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
TempExecJob job = new TempExecJob(progressDialog, mainFrame, resolvedFile);
progressDialog.start(job);
}
}
Aggregations