@Override public void chunk(final Path folder, final AttributedList<Path> list) throws ConnectionCanceledException { int i = index; while(i < list.size()) { final int before = list.size(); this.visit(list, i, list.get(i)); if(list.size() == before) { i++; } // Else current item has been removed } index = list.size(); }
@Override public void chunk(final Path parent, final AttributedList<Path> list) throws ConnectionCanceledException { if(log.isInfoEnabled()) { log.info(String.format("Retrieved chunk of %d items in %s", list.size(), directory)); } if(worker.isCanceled()) { throw new ConnectionCanceledException(); } proxy.chunk(directory, list); }
@Override protected Path pathAtRow(int row) { final AttributedList<Path> children = browserListModel.get(workdir()); if(row < children.size()) { return children.get(row); } log.warn(String.format("No item at row %d", row)); return null; } }
@Override public void chunk(final Path folder, final AttributedList<Path> list) throws ListCanceledException { if(folder.isRoot()) { if(list.size() >= container) { // Allow another chunk until limit is reached again container += preferences.getInteger("browser.list.limit.container"); throw new ListCanceledException(list); } } if(list.size() >= directory) { // Allow another chunk until limit is reached again directory += preferences.getInteger("browser.list.limit.directory"); throw new ListCanceledException(list); } }
@Override public NSInteger numberOfItemsInComboBox(NSComboBox combo) { return new NSInteger(cache.get(workdir).filter(comparator, filter).size()); }
@Override public NSInteger numberOfRowsInTableView(final NSTableView view) { if(controller.isMounted()) { return new NSInteger(this.get(controller.workdir()).size()); } return new NSInteger(0); }
/** * @see NSOutlineView.DataSource * Invoked by outlineView, and returns the child item at the specified index. Children * of a given parent item are accessed sequentially. If item is null, this method should * return the appropriate child item of the root object */ @Override public NSObject outlineView_child_ofItem(final NSOutlineView view, final NSInteger index, final NSObject item) { if(log.isTraceEnabled()) { log.trace("outlineView_child_ofItem:" + item); } final Path path; if(null == item) { path = controller.workdir(); } else { path = cache.lookup(new NSObjectPathReference(item)); if(null == path) { return null; } } final AttributedList<Path> children = this.get(path); if(index.intValue() >= children.size()) { log.warn(String.format("Index %s out of bound for %s", index, item)); return null; } return NSObjectPathReference.get(children.get(index.intValue())); }
@Override public NSInteger outlineView_numberOfChildrenOfItem(final NSOutlineView view, final NSObject item) { return new NSInteger(this.children(null == item ? null : cache.lookup(new NSObjectTransferItemReference(item))).size()); }
@Override public AttributedList<Path> put(final Path folder, final AttributedList<Path> encrypted) { final AttributedList<Path> list = new AttributedList<>(); // Swap with decrypted paths for(int i = 0; i < encrypted.size(); i++) { final Path f = encrypted.get(i); list.add(i, this.toDecrypted(f)); } return delegate.put(this.toDecrypted(folder), list); }
@Override public AttributedList<Path> get(final Path folder) { final AttributedList<Path> decrypted = delegate.get(this.toDecrypted(folder)); final AttributedList<Path> list = new AttributedList<>(); // Swap with encrypted paths for(int i = 0; i < decrypted.size(); i++) { final Path f = decrypted.get(i); list.add(i, this.toEncrypted(f)); } return list; }
@Override public void loadBundle() { final NSAlert alert = NSAlert.alert(); alert.setAlertStyle(NSAlert.NSInformationalAlertStyle); alert.setMessageText(MessageFormat.format(LocaleFactory.localizedString("Listing directory {0}", "Status"), StringUtils.EMPTY)); alert.setInformativeText(MessageFormat.format(LocaleFactory.localizedString("Continue listing directory with more than {0} files.", "Alert"), e.getChunk().size())); alert.addButtonWithTitle(LocaleFactory.localizedString("Continue", "Credentials")); alert.addButtonWithTitle(LocaleFactory.localizedString("Cancel")); alert.setShowsSuppressionButton(true); alert.suppressionButton().setTitle(LocaleFactory.localizedString("Always")); super.loadBundle(alert); } }