Search in sources :

Example 1 with WindowMainAction

use of ch.cyberduck.core.threading.WindowMainAction in project cyberduck by iterate-ch.

the class InfoController method calculateSizeButtonClicked.

@Action
public void calculateSizeButtonClicked(final ID sender) {
    if (this.toggleSizeSettings(false)) {
        this.background(new WorkerBackgroundAction<>(controller, session, new CalculateSizeWorker(files, controller) {

            @Override
            public void cleanup(final Long size) {
                setSize(size);
                toggleSizeSettings(true);
            }

            @Override
            protected void update(final long size) {
                invoke(new WindowMainAction(InfoController.this) {

                    @Override
                    public void run() {
                        setSize(size);
                    }
                });
            }
        }));
    }
}
Also used : WindowMainAction(ch.cyberduck.core.threading.WindowMainAction) Action(ch.cyberduck.binding.Action) RegistryBackgroundAction(ch.cyberduck.core.threading.RegistryBackgroundAction) WindowMainAction(ch.cyberduck.core.threading.WindowMainAction) WorkerBackgroundAction(ch.cyberduck.core.threading.WorkerBackgroundAction)

Example 2 with WindowMainAction

use of ch.cyberduck.core.threading.WindowMainAction in project cyberduck by iterate-ch.

the class BookmarkTableDataSource method setSource.

public void setSource(final AbstractHostCollection source) {
    // Remove previous listener
    this.source.removeListener(listener);
    this.source = source;
    this.source.addListener(listener = new CollectionListener<Host>() {

        private ScheduledFuture<?> delayed = null;

        @Override
        public void collectionLoaded() {
            controller.invoke(new WindowMainAction(controller) {

                @Override
                public void run() {
                    controller.reloadBookmarks();
                }
            });
        }

        @Override
        public void collectionItemAdded(final Host item) {
            controller.invoke(new WindowMainAction(controller) {

                @Override
                public void run() {
                    controller.reloadBookmarks();
                }
            });
        }

        @Override
        public void collectionItemRemoved(final Host item) {
            controller.invoke(new WindowMainAction(controller) {

                @Override
                public void run() {
                    controller.reloadBookmarks();
                }
            });
        }

        @Override
        public void collectionItemChanged(final Host item) {
            if (null != delayed) {
                delayed.cancel(false);
            }
            // Delay to 1 second. When typing changes we don't have to save every iteration.
            delayed = timerPool.schedule(new Runnable() {

                public void run() {
                    controller.invoke(new WindowMainAction(controller) {

                        @Override
                        public void run() {
                            controller.reloadBookmarks();
                        }
                    });
                }
            }, 1L, TimeUnit.SECONDS);
        }
    });
    this.setFilter(null);
}
Also used : WindowMainAction(ch.cyberduck.core.threading.WindowMainAction) ScheduledFuture(java.util.concurrent.ScheduledFuture)

Example 3 with WindowMainAction

use of ch.cyberduck.core.threading.WindowMainAction in project cyberduck by iterate-ch.

the class BrowserController method selectBookmarks.

private void selectBookmarks(final BookmarkSwitchSegement selected) {
    bookmarkSwitchView.setSelectedSegment(selected.ordinal());
    this.setNavigation(false);
    // Display bookmarks
    browserTabView.selectTabViewItemAtIndex(BrowserTab.bookmarks.ordinal());
    final AbstractHostCollection source;
    switch(selected) {
        case history:
            source = HistoryCollection.defaultCollection();
            break;
        case rendezvous:
            source = RendezvousCollection.defaultCollection();
            break;
        case bookmarks:
        default:
            source = bookmarks;
            break;
    }
    if (!source.isLoaded()) {
        browserSpinner.startAnimation(null);
        source.addListener(new AbstractCollectionListener<Host>() {

            @Override
            public void collectionLoaded() {
                invoke(new WindowMainAction(BrowserController.this) {

                    @Override
                    public void run() {
                        browserSpinner.stopAnimation(null);
                        bookmarkTable.setGridStyleMask(NSTableView.NSTableViewSolidHorizontalGridLineMask);
                    }
                });
                source.removeListener(this);
            }
        });
    } else {
        browserSpinner.stopAnimation(null);
        bookmarkTable.setGridStyleMask(NSTableView.NSTableViewSolidHorizontalGridLineMask);
    }
    bookmarkModel.setSource(source);
    this.setBookmarkFilter(null);
    this.reloadBookmarks();
    if (this.isMounted()) {
        int row = this.bookmarkModel.getSource().indexOf(pool.getHost());
        if (row != -1) {
            this.bookmarkTable.selectRowIndexes(NSIndexSet.indexSetWithIndex(new NSInteger(row)), false);
            this.bookmarkTable.scrollRowToVisible(new NSInteger(row));
        } else {
            this.bookmarkTable.selectRowIndexes(NSIndexSet.indexSetWithIndex(new NSInteger(0)), false);
            this.bookmarkTable.scrollRowToVisible(new NSInteger(0));
        }
    } else {
        this.bookmarkTable.selectRowIndexes(NSIndexSet.indexSetWithIndex(new NSInteger(0)), false);
        this.bookmarkTable.scrollRowToVisible(new NSInteger(0));
    }
    this.getFocus();
}
Also used : NSInteger(org.rococoa.cocoa.foundation.NSInteger) WindowMainAction(ch.cyberduck.core.threading.WindowMainAction) NSPoint(org.rococoa.cocoa.foundation.NSPoint)

Aggregations

WindowMainAction (ch.cyberduck.core.threading.WindowMainAction)3 Action (ch.cyberduck.binding.Action)1 RegistryBackgroundAction (ch.cyberduck.core.threading.RegistryBackgroundAction)1 WorkerBackgroundAction (ch.cyberduck.core.threading.WorkerBackgroundAction)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 NSInteger (org.rococoa.cocoa.foundation.NSInteger)1 NSPoint (org.rococoa.cocoa.foundation.NSPoint)1