use of ch.cyberduck.core.local.ApplicationFinder in project cyberduck by iterate-ch.
the class PreferencesController method editorPathPanelDidEnd_returnCode_contextInfo.
public void editorPathPanelDidEnd_returnCode_contextInfo(NSOpenPanel sheet, int returncode, ID contextInfo) {
if (returncode == SheetCallback.DEFAULT_OPTION) {
NSObject selected = sheet.URLs().lastObject();
if (selected != null) {
final String path = LocalFactory.get(Rococoa.cast(selected, NSURL.class).path()).getAbsolute();
final ApplicationFinder finder = ApplicationFinderFactory.get();
final Application application = finder.getDescription(path);
if (finder.isInstalled(application)) {
preferences.setProperty("editor.bundleIdentifier", application.getIdentifier());
for (BrowserController controller : MainController.getBrowsers()) {
controller.validateToolbar();
}
} else {
log.error(String.format("Loading bundle %s failed", path));
}
}
}
this.updateEditorCombobox();
}
use of ch.cyberduck.core.local.ApplicationFinder in project cyberduck by iterate-ch.
the class Terminal method edit.
protected Exit edit(final SessionPool session, final Path remote) throws BackgroundException {
final EditorFactory factory = EditorFactory.instance();
final Application application;
final ApplicationFinder finder = ApplicationFinderFactory.get();
if (StringUtils.isNotBlank(input.getOptionValue(TerminalOptionsBuilder.Params.application.name()))) {
application = finder.getDescription(input.getOptionValue(TerminalOptionsBuilder.Params.application.name()));
if (!finder.isInstalled(application)) {
throw new BackgroundException(LocaleFactory.localizedString("Unknown"), String.format("Application %s not found", input.getOptionValue(TerminalOptionsBuilder.Params.application.name())));
}
} else {
application = EditorFactory.getEditor(remote.getName());
}
if (!finder.isInstalled(application)) {
throw new BackgroundException(LocaleFactory.localizedString("Unknown"), String.format("No application found to edit %s", remote.getName()));
}
final Editor editor = factory.create(session.getHost(), remote, controller);
final CountDownLatch lock = new CountDownLatch(1);
final Worker<Transfer> worker = editor.open(application, lock::countDown, new DefaultEditorListener(controller, session, editor, new DefaultEditorListener.Listener() {
@Override
public void saved() {
//
}
}));
final SessionBackgroundAction<Transfer> action = new TerminalBackgroundAction<>(controller, session, worker);
try {
this.execute(action);
} catch (TerminalBackgroundException e) {
return Exit.failure;
}
Uninterruptibles.awaitUninterruptibly(lock);
return Exit.success;
}
Aggregations