Search in sources :

Example 1 with ApplicationFinder

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();
}
Also used : NSObject(ch.cyberduck.binding.foundation.NSObject) ApplicationFinder(ch.cyberduck.core.local.ApplicationFinder) NSURL(ch.cyberduck.binding.foundation.NSURL) NSMutableAttributedString(ch.cyberduck.binding.foundation.NSMutableAttributedString) NSAttributedString(ch.cyberduck.binding.foundation.NSAttributedString) Application(ch.cyberduck.core.local.Application)

Example 2 with ApplicationFinder

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;
}
Also used : EditorFactory(ch.cyberduck.core.editor.EditorFactory) LoadingVaultLookupListener(ch.cyberduck.core.vault.LoadingVaultLookupListener) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) DefaultEditorListener(ch.cyberduck.core.editor.DefaultEditorListener) ApplicationFinder(ch.cyberduck.core.local.ApplicationFinder) CountDownLatch(java.util.concurrent.CountDownLatch) CopyTransfer(ch.cyberduck.core.transfer.CopyTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) DefaultEditorListener(ch.cyberduck.core.editor.DefaultEditorListener) Editor(ch.cyberduck.core.editor.Editor) Application(ch.cyberduck.core.local.Application) BackgroundException(ch.cyberduck.core.exception.BackgroundException)

Aggregations

Application (ch.cyberduck.core.local.Application)2 ApplicationFinder (ch.cyberduck.core.local.ApplicationFinder)2 NSAttributedString (ch.cyberduck.binding.foundation.NSAttributedString)1 NSMutableAttributedString (ch.cyberduck.binding.foundation.NSMutableAttributedString)1 NSObject (ch.cyberduck.binding.foundation.NSObject)1 NSURL (ch.cyberduck.binding.foundation.NSURL)1 DefaultEditorListener (ch.cyberduck.core.editor.DefaultEditorListener)1 Editor (ch.cyberduck.core.editor.Editor)1 EditorFactory (ch.cyberduck.core.editor.EditorFactory)1 BackgroundException (ch.cyberduck.core.exception.BackgroundException)1 DisabledStreamListener (ch.cyberduck.core.io.DisabledStreamListener)1 CopyTransfer (ch.cyberduck.core.transfer.CopyTransfer)1 Transfer (ch.cyberduck.core.transfer.Transfer)1 LoadingVaultLookupListener (ch.cyberduck.core.vault.LoadingVaultLookupListener)1 CountDownLatch (java.util.concurrent.CountDownLatch)1