Search in sources :

Example 1 with TransferTableDataSource

use of ch.cyberduck.ui.cocoa.datasource.TransferTableDataSource in project cyberduck by iterate-ch.

the class TransferController method setQueueTable.

public void setQueueTable(NSTableView view) {
    this.transferTable = view;
    this.transferTable.setRowHeight(new CGFloat(82));
    {
        NSTableColumn c = tableColumnsFactory.create(TransferColumn.progress.name());
        c.setMinWidth(80f);
        c.setWidth(300f);
        c.setResizingMask(NSTableColumn.NSTableColumnAutoresizingMask);
        this.transferTable.addTableColumn(c);
    }
    this.transferTable.setDataSource((transferTableModel = new TransferTableDataSource()).id());
    this.transferTable.setDelegate((transferTableDelegate = new AbstractTableDelegate<Transfer, TransferColumn>(transferTable.tableColumnWithIdentifier(TransferColumn.progress.name())) {

        @Override
        public String tooltip(final Transfer t, final TransferColumn column) {
            return t.getName();
        }

        @Override
        public void enterKeyPressed(final ID sender) {
            this.tableRowDoubleClicked(sender);
        }

        @Override
        public void deleteKeyPressed(final ID sender) {
            deleteButtonClicked(sender);
        }

        @Override
        public void tableColumnClicked(NSTableView view, NSTableColumn tableColumn) {
        // 
        }

        @Override
        public void tableRowDoubleClicked(final ID sender) {
            reloadButtonClicked(sender);
        }

        @Override
        public void selectionIsChanging(final NSNotification notification) {
            updateHighlight();
        }

        @Override
        public void selectionDidChange(final NSNotification notification) {
            updateHighlight();
            updateSelection();
            transferTable.noteHeightOfRowsWithIndexesChanged(NSIndexSet.indexSetWithIndexesInRange(NSRange.NSMakeRange(new NSUInteger(0), new NSUInteger(transferTable.numberOfRows()))));
        }

        public NSView tableView_viewForTableColumn_row(final NSTableView view, final NSTableColumn column, final NSInteger row) {
            final ProgressController controller = transferTableModel.getController(row.intValue());
            return controller.view();
        }

        @Override
        public boolean isTypeSelectSupported() {
            return true;
        }

        public String tableView_typeSelectStringForTableColumn_row(final NSTableView view, final NSTableColumn column, final NSInteger row) {
            return transferTableModel.getSource().get(row.intValue()).getName();
        }
    }).id());
    // receive drag events from types
    // in fact we are not interested in file promises, but because the browser model can only initiate
    // a drag with tableView.dragPromisedFilesOfTypes(), we listens for those events
    // and then use the private pasteboard instead.
    this.transferTable.registerForDraggedTypes(NSArray.arrayWithObjects(NSPasteboard.StringPboardType, // Accept file promises made myself
    NSPasteboard.FilesPromisePboardType));
    // No grid lines until list is loaded
    this.transferTable.setGridStyleMask(NSTableView.NSTableViewGridNone);
    // Set sselection properties
    this.transferTable.setAllowsMultipleSelection(true);
    this.transferTable.setAllowsEmptySelection(true);
    this.transferTable.setAllowsColumnReordering(false);
    this.transferTable.sizeToFit();
}
Also used : NSInteger(org.rococoa.cocoa.foundation.NSInteger) NSNotification(ch.cyberduck.binding.foundation.NSNotification) TransferTableDataSource(ch.cyberduck.ui.cocoa.datasource.TransferTableDataSource) DownloadTransfer(ch.cyberduck.core.transfer.DownloadTransfer) Transfer(ch.cyberduck.core.transfer.Transfer) AbstractTableDelegate(ch.cyberduck.binding.AbstractTableDelegate) ID(org.rococoa.ID) NSUInteger(org.rococoa.cocoa.foundation.NSUInteger) CGFloat(org.rococoa.cocoa.CGFloat)

Aggregations

AbstractTableDelegate (ch.cyberduck.binding.AbstractTableDelegate)1 NSNotification (ch.cyberduck.binding.foundation.NSNotification)1 DownloadTransfer (ch.cyberduck.core.transfer.DownloadTransfer)1 Transfer (ch.cyberduck.core.transfer.Transfer)1 TransferTableDataSource (ch.cyberduck.ui.cocoa.datasource.TransferTableDataSource)1 ID (org.rococoa.ID)1 CGFloat (org.rococoa.cocoa.CGFloat)1 NSInteger (org.rococoa.cocoa.foundation.NSInteger)1 NSUInteger (org.rococoa.cocoa.foundation.NSUInteger)1