use of ch.cyberduck.binding.foundation.NSObject 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 ch.cyberduck.binding.foundation.NSObject in project cyberduck by iterate-ch.
the class AlertController method focus.
protected void focus(final NSAlert alert) {
NSEnumerator buttons = alert.buttons().objectEnumerator();
NSObject button;
while ((button = buttons.nextObject()) != null) {
final NSButton b = Rococoa.cast(button, NSButton.class);
b.setTarget(this.id());
b.setAction(Foundation.selector("closeSheet:"));
}
final NSView accessory = this.getAccessoryView(alert);
if (accessory != null) {
final NSRect frame = this.getFrame(alert, accessory);
accessory.setFrameSize(frame.size);
alert.setAccessoryView(accessory);
alert.window().makeFirstResponder(accessory);
}
// First call layout and then do any special positioning and sizing of the accessory view prior to running the alert
alert.layout();
alert.window().recalculateKeyViewLoop();
}
use of ch.cyberduck.binding.foundation.NSObject in project cyberduck by iterate-ch.
the class ToolbarWindowController method getContentRect.
/**
* @return Minimum size to fit content view of currently selected tab.
*/
private NSRect getContentRect() {
NSRect contentRect = new NSRect(0, 0);
final NSView view = tabView.selectedTabViewItem().view();
final NSEnumerator enumerator = view.subviews().objectEnumerator();
NSObject next;
while (null != (next = enumerator.nextObject())) {
final NSView subview = Rococoa.cast(next, NSView.class);
contentRect = FoundationKitFunctions.library.NSUnionRect(contentRect, subview.frame());
}
return contentRect;
}
use of ch.cyberduck.binding.foundation.NSObject in project cyberduck by iterate-ch.
the class UserDefaultsPreferences method toList.
/**
* Convert collection
*
* @param array List of properties
* @return Collection
*/
private List<String> toList(final NSArray array) {
if (null == array) {
return Collections.emptyList();
}
final List<String> list = new ArrayList<>();
NSEnumerator ordered = array.objectEnumerator();
NSObject next;
while (((next = ordered.nextObject()) != null)) {
list.add(next.toString());
}
return list;
}
use of ch.cyberduck.binding.foundation.NSObject in project cyberduck by iterate-ch.
the class PlistDeserializer method objectForKey.
@Override
public NSDictionary objectForKey(final String key) {
final NSObject value = dict.objectForKey(key);
if (null == value) {
return null;
}
if (value.isKindOfClass(NSDictionary.CLASS)) {
return Rococoa.cast(value, NSDictionary.class);
}
log.warn(String.format("Unexpected value type for serialized key %s", key));
return null;
}
Aggregations