Search in sources :

Example 1 with DisabledApplicationQuitCallback

use of ch.cyberduck.core.local.DisabledApplicationQuitCallback in project cyberduck by iterate-ch.

the class DefaultWatchEditorTest method testNotfound.

@Test(expected = NoSuchFileException.class)
public void testNotfound() throws Exception {
    final DefaultWatchEditor editor = new DefaultWatchEditor(new Host(new TestProtocol()), new Path("/remote", EnumSet.of(Path.Type.file)), new DisabledListProgressListener());
    editor.watch(new Application("com.app"), new Local(System.getProperty("java.io.tmpdir") + "/notfound", UUID.randomUUID().toString()), new DisabledFileWatcherListener(), new DisabledApplicationQuitCallback());
}
Also used : Path(ch.cyberduck.core.Path) TestProtocol(ch.cyberduck.core.TestProtocol) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) DisabledFileWatcherListener(ch.cyberduck.core.local.DisabledFileWatcherListener) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) Application(ch.cyberduck.core.local.Application) DisabledApplicationQuitCallback(ch.cyberduck.core.local.DisabledApplicationQuitCallback) Test(org.junit.Test)

Example 2 with DisabledApplicationQuitCallback

use of ch.cyberduck.core.local.DisabledApplicationQuitCallback in project cyberduck by iterate-ch.

the class BrowserController method edit.

protected void edit(final Application application, final Path file) {
    final Editor editor = editors.getOrDefault(file, EditorFactory.instance().create(pool.getHost(), file, this));
    this.background(new WorkerBackgroundAction<>(this, pool, editor.open(application, new DisabledApplicationQuitCallback(), new DefaultEditorListener(this, pool, editor, new DefaultEditorListener.Listener() {

        @Override
        public void saved() {
            reload(workdir, new PathReloadFinder().find(Collections.singletonList(file)), Collections.singletonList(file), true);
        }
    }))));
}
Also used : DefaultEditorListener(ch.cyberduck.core.editor.DefaultEditorListener) LoadingVaultLookupListener(ch.cyberduck.core.vault.LoadingVaultLookupListener) PromptLimitedListProgressListener(ch.cyberduck.ui.cocoa.callback.PromptLimitedListProgressListener) UnifiedSystemLogTranscriptListener(ch.cyberduck.core.logging.UnifiedSystemLogTranscriptListener) DefaultEditorListener(ch.cyberduck.core.editor.DefaultEditorListener) Editor(ch.cyberduck.core.editor.Editor) DisabledApplicationQuitCallback(ch.cyberduck.core.local.DisabledApplicationQuitCallback) PathReloadFinder(ch.cyberduck.ui.browser.PathReloadFinder)

Example 3 with DisabledApplicationQuitCallback

use of ch.cyberduck.core.local.DisabledApplicationQuitCallback in project cyberduck by iterate-ch.

the class AbstractEditorTest method testOpen.

@Test
public void testOpen() throws Exception {
    final AtomicBoolean t = new AtomicBoolean();
    final Host host = new Host(new TestProtocol());
    final NullSession session = new NullTransferSession(host) {

        @Override
        @SuppressWarnings("unchecked")
        public <T> T _getFeature(final Class<T> type) {
            if (type.equals(Read.class)) {
                return (T) new Read() {

                    @Override
                    public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) {
                        t.set(true);
                        return IOUtils.toInputStream("content", Charset.defaultCharset());
                    }

                    @Override
                    public boolean offset(final Path file) {
                        assertEquals(new Path("/f", EnumSet.of(Path.Type.file)), file);
                        return false;
                    }
                };
            }
            return super._getFeature(type);
        }
    };
    final AtomicBoolean e = new AtomicBoolean();
    final Path file = new Path("/f", EnumSet.of(Path.Type.file));
    final Local temporary = new DefaultTemporaryFileService().create(host.getUuid(), file);
    file.attributes().setSize("content".getBytes().length);
    final AbstractEditor editor = new AbstractEditor(host, file, new DisabledProgressListener()) {

        @Override
        public void close() {
        // 
        }

        @Override
        protected void edit(final Application editor, final Path file, final Local temporary, final FileWatcherListener listener) {
            e.set(true);
        }

        @Override
        protected void watch(final Application application, final Local temporary, final FileWatcherListener listener, final ApplicationQuitCallback quit) {
        // 
        }
    };
    editor.open(new Application("com.editor"), new DisabledApplicationQuitCallback(), new DisabledFileWatcherListener()).run(session);
    assertTrue(t.get());
    assertTrue(e.get());
    assertTrue(temporary.exists());
}
Also used : Path(ch.cyberduck.core.Path) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) DefaultTemporaryFileService(ch.cyberduck.core.local.DefaultTemporaryFileService) InputStream(java.io.InputStream) NullSession(ch.cyberduck.core.NullSession) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) NullTransferSession(ch.cyberduck.core.NullTransferSession) Read(ch.cyberduck.core.features.Read) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ApplicationQuitCallback(ch.cyberduck.core.local.ApplicationQuitCallback) DisabledApplicationQuitCallback(ch.cyberduck.core.local.DisabledApplicationQuitCallback) FileWatcherListener(ch.cyberduck.core.local.FileWatcherListener) DisabledFileWatcherListener(ch.cyberduck.core.local.DisabledFileWatcherListener) DisabledFileWatcherListener(ch.cyberduck.core.local.DisabledFileWatcherListener) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) ConnectionCallback(ch.cyberduck.core.ConnectionCallback) Application(ch.cyberduck.core.local.Application) DisabledApplicationQuitCallback(ch.cyberduck.core.local.DisabledApplicationQuitCallback) Test(org.junit.Test)

Aggregations

DisabledApplicationQuitCallback (ch.cyberduck.core.local.DisabledApplicationQuitCallback)3 Host (ch.cyberduck.core.Host)2 Local (ch.cyberduck.core.Local)2 Path (ch.cyberduck.core.Path)2 TestProtocol (ch.cyberduck.core.TestProtocol)2 Application (ch.cyberduck.core.local.Application)2 DisabledFileWatcherListener (ch.cyberduck.core.local.DisabledFileWatcherListener)2 Test (org.junit.Test)2 ConnectionCallback (ch.cyberduck.core.ConnectionCallback)1 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)1 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)1 NullSession (ch.cyberduck.core.NullSession)1 NullTransferSession (ch.cyberduck.core.NullTransferSession)1 DefaultEditorListener (ch.cyberduck.core.editor.DefaultEditorListener)1 Editor (ch.cyberduck.core.editor.Editor)1 Read (ch.cyberduck.core.features.Read)1 ApplicationQuitCallback (ch.cyberduck.core.local.ApplicationQuitCallback)1 DefaultTemporaryFileService (ch.cyberduck.core.local.DefaultTemporaryFileService)1 FileWatcherListener (ch.cyberduck.core.local.FileWatcherListener)1 UnifiedSystemLogTranscriptListener (ch.cyberduck.core.logging.UnifiedSystemLogTranscriptListener)1