@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 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 NSObject outlineView_child_ofItem(final NSOutlineView view, final NSInteger index, final NSObject item) { final AttributedList<TransferItem> children = this.get(null == item ? null : cache.lookup(new NSObjectTransferItemReference(item))); return NSObjectPathReference.get(children.get(index.intValue()).remote); }
@Override public NSObject comboBox_objectValueForItemAtIndex(final NSComboBox sender, final NSInteger row) { return NSString.stringWithString(cache.get(workdir) .filter(comparator, filter).get(row.intValue()).getName()); } }
/** * @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 void tableView_setObjectValue_forTableColumn_row(final NSTableView view, final NSObject value, final NSTableColumn column, final NSInteger row) { super.setObjectValueForItem(this.get(controller.workdir()).get(row.intValue()), value, column.identifier()); }
@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 NSObject tableView_objectValueForTableColumn_row(final NSTableView view, final NSTableColumn column, final NSInteger row) { if(controller.isMounted()) { final AttributedList<Path> children = this.get(controller.workdir()); return super.objectValueForItem(children.get(row.intValue()), column.identifier()); } return null; }
public String tableView_toolTipForCell_rect_tableColumn_row_mouseLocation(NSTableView t, NSCell cell, ID rect, NSTableColumn c, NSInteger row, NSPoint mouseLocation) { return this.tooltip(browserListModel.get(workdir()).get(row.intValue()), BrowserColumn.valueOf(c.identifier())); }
/** * Invoked by view after it has been determined that a drag should begin, but before the drag has been started. * The drag image and other drag-related information will be set up and provided by the table view once this call * returns with true. * * @param rowIndexes is the list of row numbers that will be participating in the drag. * @return To refuse the drag, return false. To start a drag, return true and place the drag data onto pboard (data, owner, and so on). */ @Override public boolean tableView_writeRowsWithIndexes_toPasteboard(final NSTableView view, final NSIndexSet rowIndexes, final NSPasteboard pboard) { if(controller.isMounted()) { final AttributedList<Path> children = this.get(controller.workdir()); final List<Path> selected = new ArrayList<Path>(); for(NSUInteger index = rowIndexes.firstIndex(); !index.equals(NSIndexSet.NSNotFound); index = rowIndexes.indexGreaterThanIndex(index)) { selected.add(children.get(index.intValue())); } return super.writeItemsToPasteBoard(view, selected, pboard); } return false; }
@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 tableView_willDisplayCell_forTableColumn_row(final NSTableView view, final NSTextFieldCell cell, final NSTableColumn tableColumn, final NSInteger row) { final Path file = browserListModel.get(BrowserController.this.workdir()).get(row.intValue()); if(cell.isKindOfClass(Foundation.getClass(NSTextFieldCell.class.getSimpleName()))) { if(!BrowserController.this.isConnected() || !SearchFilterFactory.HIDDEN_FILTER.accept(file)) { cell.setTextColor(NSColor.disabledControlTextColor()); } else { cell.setTextColor(NSColor.controlTextColor()); } } }
@Override public boolean tableView_acceptDrop_row_dropOperation(final NSTableView view, final NSDraggingInfo draggingInfo, final NSInteger row, final NSUInteger operation) { if(controller.isMounted()) { Path destination = controller.workdir(); if(row.intValue() != -1) { destination = this.get(controller.workdir()).get(row.intValue()); } return super.acceptDrop(view, destination, draggingInfo); } return super.acceptDrop(view, null, draggingInfo); }
@Override public NSUInteger tableView_validateDrop_proposedRow_proposedDropOperation(final NSTableView view, final NSDraggingInfo draggingInfo, final NSInteger row, final NSUInteger operation) { if(controller.isMounted()) { Path destination = controller.workdir(); if(row.intValue() < this.numberOfRowsInTableView(view).intValue()) { int draggingColumn = view.columnAtPoint(draggingInfo.draggingLocation()).intValue(); if(-1 == draggingColumn || 0 == draggingColumn || 1 == draggingColumn) { // Allow drags to icon and filename column if(row.intValue() != -1) { Path p = this.get(controller.workdir()).get(row.intValue()); if(p.isDirectory()) { destination = p; } } } return super.validateDrop(view, destination, row, draggingInfo); } // Draging to empty area in browser return super.validateDrop(view, destination, row, draggingInfo); } // Passing to super to look for URLs to mount return super.validateDrop(view, null, row, draggingInfo); }
@Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } try { if(session.getClient().hasFeature(FTPCmd.MLST.getCommand())) { if(!FTPReply.isPositiveCompletion(session.getClient().sendCommand(FTPCmd.MLST, file.getAbsolute()))) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } final FTPDataResponseReader reader = new FTPMlsdListResponseReader(); final AttributedList<Path> attributes = reader.read(file.getParent(), Arrays.asList(session.getClient().getReplyStrings()), new DisabledListProgressListener()); if(attributes.contains(file)) { return attributes.get(attributes.indexOf(file)).attributes(); } } throw new InteroperabilityException("No support for MLST in reply to FEAT"); } catch(IOException e) { throw new FTPExceptionMappingService().map("Failure to read attributes of {0}", e, file); } } }