use of org.rococoa.cocoa.CGFloat in project cyberduck by iterate-ch.
the class AlertController method getFrame.
protected NSRect getFrame(final NSAlert alert, final NSView accessory) {
final NSRect frame = new NSRect(alert.window().frame().size.width.doubleValue(), accessory.frame().size.height.doubleValue());
final NSEnumerator enumerator = accessory.subviews().objectEnumerator();
NSObject next;
while (null != (next = enumerator.nextObject())) {
final NSView subview = Rococoa.cast(next, NSView.class);
frame.size.height = new CGFloat(frame.size.height.doubleValue() + subview.frame().size.height.doubleValue() + SUBVIEWS_VERTICAL_SPACE * 2);
}
return frame;
}
use of org.rococoa.cocoa.CGFloat 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();
}
use of org.rococoa.cocoa.CGFloat in project cyberduck by iterate-ch.
the class BrowserController method setBookmarkTable.
// ----------------------------------------------------------
// Manage Bookmarks
// ----------------------------------------------------------
@Action
public void setBookmarkTable(NSTableView view) {
bookmarkTable = view;
bookmarkTable.setSelectionHighlightStyle(NSTableView.NSTableViewSelectionHighlightStyleSourceList);
bookmarkTable.setDataSource((this.bookmarkModel = new BookmarkTableDataSource(this)).id());
{
NSTableColumn c = bookmarkTableColumnFactory.create(BookmarkColumn.icon.name());
c.headerCell().setStringValue(StringUtils.EMPTY);
c.setResizingMask(NSTableColumn.NSTableColumnNoResizing);
c.setDataCell(imageCellPrototype);
bookmarkTable.addTableColumn(c);
}
{
NSTableColumn c = bookmarkTableColumnFactory.create(BookmarkColumn.bookmark.name());
c.headerCell().setStringValue(LocaleFactory.localizedString("Bookmarks", "Browser"));
c.setMinWidth(150);
c.setResizingMask(NSTableColumn.NSTableColumnAutoresizingMask);
c.setDataCell(BookmarkCell.bookmarkCell());
bookmarkTable.addTableColumn(c);
}
{
NSTableColumn c = bookmarkTableColumnFactory.create(BookmarkColumn.status.name());
c.headerCell().setStringValue(StringUtils.EMPTY);
c.setMinWidth(40);
c.setWidth(40);
c.setMaxWidth(40);
c.setResizingMask(NSTableColumn.NSTableColumnAutoresizingMask);
c.setDataCell(imageCellPrototype);
c.dataCell().setAlignment(TEXT_ALIGNMENT_CENTER);
bookmarkTable.addTableColumn(c);
}
bookmarkTable.setDelegate((bookmarkTableDelegate = new AbstractTableDelegate<Host, BookmarkColumn>(bookmarkTable.tableColumnWithIdentifier(BookmarkColumn.bookmark.name())) {
private static final double kSwipeGestureLeft = 1.000000;
private static final double kSwipeGestureRight = -1.000000;
private static final double kSwipeGestureUp = 1.000000;
private static final double kSwipeGestureDown = -1.000000;
@Override
public String tooltip(Host bookmark, final BookmarkColumn column) {
return new HostUrlProvider().get(bookmark);
}
@Override
public void tableRowDoubleClicked(final ID sender) {
BrowserController.this.connectBookmarkButtonClicked(sender);
}
@Override
public void enterKeyPressed(final ID sender) {
this.tableRowDoubleClicked(sender);
}
@Override
public void deleteKeyPressed(final ID sender) {
if (bookmarkModel.getSource().allowsDelete()) {
BrowserController.this.deleteBookmarkButtonClicked(sender);
}
}
@Override
public void tableColumnClicked(NSTableView view, NSTableColumn tableColumn) {
}
@Override
public void selectionDidChange(final NSNotification notification) {
addBookmarkButton.setEnabled(bookmarkModel.getSource().allowsAdd());
final int selected = bookmarkTable.numberOfSelectedRows().intValue();
editBookmarkButton.setEnabled(bookmarkModel.getSource().allowsEdit() && selected == 1);
deleteBookmarkButton.setEnabled(bookmarkModel.getSource().allowsDelete() && selected > 0);
}
@Action
public CGFloat tableView_heightOfRow(NSTableView view, NSInteger row) {
final int size = preferences.getInteger("bookmark.icon.size");
if (BookmarkCell.SMALL_BOOKMARK_SIZE == size) {
return new CGFloat(18);
}
if (BookmarkCell.MEDIUM_BOOKMARK_SIZE == size) {
return new CGFloat(45);
}
return new CGFloat(70);
}
@Override
public boolean isTypeSelectSupported() {
return true;
}
@Action
public String tableView_typeSelectStringForTableColumn_row(NSTableView view, NSTableColumn tableColumn, NSInteger row) {
return BookmarkNameProvider.toString(bookmarkModel.getSource().get(row.intValue()));
}
@Action
public boolean tableView_isGroupRow(NSTableView view, NSInteger row) {
return false;
}
/**
* Available in Mac OS X v10.6 and later.
*
* @param event Swipe event
*/
@Action
public void swipeWithEvent(NSEvent event) {
if (event.deltaY().doubleValue() == kSwipeGestureUp) {
NSInteger row = bookmarkTable.selectedRow();
NSInteger next;
if (-1 == row.intValue()) {
// No current selection
next = new NSInteger(0);
} else {
next = new NSInteger(row.longValue() - 1);
}
bookmarkTable.selectRowIndexes(NSIndexSet.indexSetWithIndex(next), false);
} else if (event.deltaY().doubleValue() == kSwipeGestureDown) {
NSInteger row = bookmarkTable.selectedRow();
NSInteger next;
if (-1 == row.intValue()) {
// No current selection
next = new NSInteger(0);
} else {
next = new NSInteger(row.longValue() + 1);
}
bookmarkTable.selectRowIndexes(NSIndexSet.indexSetWithIndex(next), false);
}
}
}).id());
// receive drag events from types
bookmarkTable.registerForDraggedTypes(NSArray.arrayWithObjects(NSPasteboard.URLPboardType, NSPasteboard.StringPboardType, // Accept bookmark files dragged from the Finder
NSPasteboard.FilenamesPboardType, // Accept file promises made myself
NSPasteboard.FilesPromisePboardType));
this._updateBookmarkCell();
final int size = preferences.getInteger("bookmark.icon.size");
if (BookmarkCell.SMALL_BOOKMARK_SIZE == size) {
bookmarkTable.setRowHeight(new CGFloat(18));
} else if (BookmarkCell.MEDIUM_BOOKMARK_SIZE == size) {
bookmarkTable.setRowHeight(new CGFloat(45));
} else {
bookmarkTable.setRowHeight(new CGFloat(70));
}
// setting appearance attributes()
bookmarkTable.setUsesAlternatingRowBackgroundColors(preferences.getBoolean("browser.alternatingRows"));
bookmarkTable.setGridStyleMask(NSTableView.NSTableViewGridNone);
// selection properties
bookmarkTable.setAllowsMultipleSelection(true);
bookmarkTable.setAllowsEmptySelection(true);
bookmarkTable.setAllowsColumnResizing(false);
bookmarkTable.setAllowsColumnSelection(false);
bookmarkTable.setAllowsColumnReordering(false);
bookmarkTable.sizeToFit();
}
use of org.rococoa.cocoa.CGFloat in project cyberduck by iterate-ch.
the class BrowserController method setBrowserOutlineView.
@Action
public void setBrowserOutlineView(NSOutlineView view) {
browserOutlineView = view;
// receive drag events from types
browserOutlineView.registerForDraggedTypes(NSArray.arrayWithObjects(NSPasteboard.URLPboardType, // Accept files dragged from the Finder for uploading
NSPasteboard.FilenamesPboardType, // Accept file promises made myself
NSPasteboard.FilesPromisePboardType));
// setting appearance attributes()
this._updateBrowserAttributes(browserOutlineView);
// selection properties
browserOutlineView.setAllowsMultipleSelection(true);
browserOutlineView.setAllowsEmptySelection(true);
browserOutlineView.setAllowsColumnResizing(true);
browserOutlineView.setAllowsColumnSelection(false);
browserOutlineView.setAllowsColumnReordering(true);
browserOutlineView.setRowHeight(new CGFloat(layoutManager.defaultLineHeightForFont(NSFont.systemFontOfSize(preferences.getFloat("browser.font.size"))).intValue() + 2));
{
NSTableColumn c = browserOutlineColumnsFactory.create(BrowserColumn.filename.name());
c.headerCell().setStringValue(LocaleFactory.localizedString("Filename"));
c.setMinWidth(new CGFloat(100));
c.setWidth(preferences.getFloat(String.format("browser.column.%s.width", BrowserColumn.filename.name())));
c.setMaxWidth(new CGFloat(1000));
c.setResizingMask(NSTableColumn.NSTableColumnAutoresizingMask | NSTableColumn.NSTableColumnUserResizingMask);
outlineCellPrototype.setEditable(true);
c.setDataCell(outlineCellPrototype);
browserOutlineView.addTableColumn(c);
browserOutlineView.setOutlineTableColumn(c);
}
browserOutlineView.setDataSource((browserOutlineModel = new BrowserOutlineViewDataSource(this, cache)).id());
browserOutlineView.setDelegate((browserOutlineViewDelegate = new AbstractBrowserOutlineViewDelegate(browserOutlineView.tableColumnWithIdentifier(BrowserColumn.filename.name())) {
@Override
public void enterKeyPressed(final ID sender) {
if (preferences.getBoolean("browser.enterkey.rename")) {
if (browserOutlineView.numberOfSelectedRows().intValue() == 1) {
if (browserOutlineViewDelegate.isColumnRowEditable(NSTableColumn.tableColumnWithIdentifier(BrowserColumn.filename.name()), browserOutlineView.selectedRow())) {
renameFileButtonClicked(sender);
}
}
} else {
this.tableRowDoubleClicked(sender);
}
}
/**
* @see NSOutlineView.Delegate
*/
@Override
public void outlineView_willDisplayCell_forTableColumn_item(final NSOutlineView view, final NSTextFieldCell cell, final NSTableColumn tableColumn, final NSObject item) {
if (null == item) {
return;
}
final Path file = cache.lookup(new NSObjectPathReference(item));
if (null == file) {
return;
}
if (tableColumn.identifier().equals(BrowserColumn.filename.name())) {
(Rococoa.cast(cell, OutlineCell.class)).setIcon(browserOutlineModel.iconForPath(file));
}
if (!BrowserController.this.isConnected() || !SearchFilterFactory.HIDDEN_FILTER.accept(file)) {
cell.setTextColor(NSColor.disabledControlTextColor());
} else {
cell.setTextColor(NSColor.controlTextColor());
}
}
/**
* @see NSOutlineView.Delegate
*/
@Override
public boolean outlineView_shouldExpandItem(final NSOutlineView view, final NSObject item) {
NSEvent event = NSApplication.sharedApplication().currentEvent();
if (event != null) {
if (NSEvent.NSLeftMouseDragged == event.type()) {
if (!preferences.getBoolean("browser.view.autoexpand")) {
if (log.isDebugEnabled()) {
log.debug("Returning false to #outlineViewShouldExpandItem while dragging because browser.view.autoexpand == false");
}
// See tickets #98 and #633
return false;
}
final NSInteger draggingColumn = view.columnAtPoint(view.convertPoint_fromView(event.locationInWindow(), null));
if (draggingColumn.intValue() != 0) {
if (log.isDebugEnabled()) {
log.debug(String.format("Returning false to #outlineViewShouldExpandItem for column %s", draggingColumn));
}
// See ticket #60
return false;
}
}
}
return true;
}
@Override
public boolean outlineView_isGroupItem(final NSOutlineView view, final NSObject item) {
return false;
}
@Override
public void outlineViewItemWillExpand(final NSNotification notification) {
final NSObject object = Rococoa.cast(notification.userInfo(), NSDictionary.class).objectForKey("NSObject");
final NSObjectPathReference reference = new NSObjectPathReference(object);
final Path directory = cache.lookup(reference);
if (null == directory) {
return;
}
reload(workdir, Collections.singleton(directory), getSelectedPaths(), false);
}
/**
* @see NSOutlineView.Delegate
*/
@Override
public void outlineViewItemDidExpand(final NSNotification notification) {
setStatus();
}
@Override
public void outlineViewItemWillCollapse(final NSNotification notification) {
//
}
/**
* @see NSOutlineView.Delegate
*/
@Override
public void outlineViewItemDidCollapse(final NSNotification notification) {
setStatus();
}
@Override
protected boolean isTypeSelectSupported() {
return true;
}
}).id());
}
use of org.rococoa.cocoa.CGFloat in project cyberduck by iterate-ch.
the class BrowserController method setBrowserListView.
@Action
public void setBrowserListView(NSTableView view) {
browserListView = view;
// receive drag events from types
browserListView.registerForDraggedTypes(NSArray.arrayWithObjects(NSPasteboard.URLPboardType, // Accept files dragged from the Finder for uploading
NSPasteboard.FilenamesPboardType, // Accept file promises made myself
NSPasteboard.FilesPromisePboardType));
// setting appearance attributes()
this._updateBrowserAttributes(browserListView);
// selection properties
browserListView.setAllowsMultipleSelection(true);
browserListView.setAllowsEmptySelection(true);
browserListView.setAllowsColumnResizing(true);
browserListView.setAllowsColumnSelection(false);
browserListView.setAllowsColumnReordering(true);
browserListView.setRowHeight(new CGFloat(layoutManager.defaultLineHeightForFont(NSFont.systemFontOfSize(preferences.getFloat("browser.font.size"))).intValue() + 2));
{
NSTableColumn c = browserListColumnsFactory.create(BrowserColumn.icon.name());
c.headerCell().setStringValue(StringUtils.EMPTY);
c.setMinWidth((20));
c.setWidth(preferences.getFloat(String.format("browser.column.%s.width", BrowserColumn.icon.name())));
c.setMaxWidth((20));
c.setResizingMask(NSTableColumn.NSTableColumnAutoresizingMask);
c.setDataCell(imageCellPrototype);
c.dataCell().setAlignment(TEXT_ALIGNMENT_CENTER);
browserListView.addTableColumn(c);
}
{
NSTableColumn c = browserListColumnsFactory.create(BrowserColumn.filename.name());
c.headerCell().setStringValue(BrowserColumn.filename.toString());
c.setMinWidth((100));
c.setWidth(preferences.getFloat(String.format("browser.column.%s.width", BrowserColumn.filename.name())));
c.setMaxWidth((1000));
c.setResizingMask(NSTableColumn.NSTableColumnAutoresizingMask | NSTableColumn.NSTableColumnUserResizingMask);
filenameCellPrototype.setEditable(true);
c.setDataCell(filenameCellPrototype);
this.browserListView.addTableColumn(c);
}
browserListView.setDataSource((browserListModel = new BrowserListViewDataSource(this, cache)).id());
browserListView.setDelegate((browserListViewDelegate = new AbstractBrowserListViewDelegate<Path>(browserListView.tableColumnWithIdentifier(BrowserColumn.filename.name())) {
@Override
public void enterKeyPressed(final ID sender) {
if (preferences.getBoolean("browser.enterkey.rename")) {
if (browserListView.numberOfSelectedRows().intValue() == 1) {
if (browserListViewDelegate.isColumnRowEditable(NSTableColumn.tableColumnWithIdentifier(BrowserColumn.filename.name()), browserListView.selectedRow())) {
renameFileButtonClicked(sender);
}
}
} else {
this.tableRowDoubleClicked(sender);
}
}
@Override
public void tableView_willDisplayCell_forTableColumn_row(final NSTableView view, final NSTextFieldCell cell, final NSTableColumn tableColumn, final NSInteger row) {
final Path file = browserListModel.get(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
protected boolean isTypeSelectSupported() {
return true;
}
}).id());
}
Aggregations