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);
}
});
}
}));
}
}
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);
}
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();
}
Aggregations