public static NSMutableAttributedString create(String str) { if(null == str) { str = ""; } return Rococoa.cast(CLASS.alloc().initWithString(str), NSMutableAttributedString.class); }
@Override public NSDictionary objectForKey(final String key) { final NSObject value = dict.objectForKey(key); if(null == value) { return null; } if(value.isKindOfClass(Rococoa.createClass("NSDictionary", NSDictionary._Class.class))) { return Rococoa.cast(value, NSDictionary.class); } log.warn(String.format("Unexpected value type for serialized key %s", key)); return null; }
/** Get the status of the synthesizer * @return the current status of the synthesizer */ public NSSpeechStatus getStatus() { return new NSSpeechStatus(Rococoa.cast(getProperty(SpeechProperty.StatusProperty), NSMutableDictionary.class)); }
/** Get identifying information about this synthesizer * @return information that identifies this synthesizer */ public NSSpeechSynthesizerInfo getSynthesizerInfo() { return new NSSpeechSynthesizerInfo(Rococoa.cast(getProperty(SpeechProperty.SynthesizerInfoProperty), NSMutableDictionary.class)); }
public static NSMutableAttributedString create(String str, NSDictionary attrs) { if(null == str) { str = ""; } return Rococoa.cast(CLASS.alloc().initWithString_attributes(str, attrs), NSMutableAttributedString.class); }
/** Get the value associated with the given key as coercing it to the given type. * @param key the key whose associated value will be returned * @param type the subclass of <code>NSObject</code> that the value associated with <code>key</code> will be coerced to * @return the value associated with the key coerced as into <code>type</code> * @param <R> the type to return */ public <R extends NSObject> R getValueAsType(E key, Class<R> type) { NSObject result = data.objectForKey(key.getNativeValue()); return result == null ? null : Rococoa.cast(result, type); }
/** Get the latest error that occurred in the synthesizer * @return the latest error to occur */ public NSSpeechError getError() { return new NSSpeechError(Rococoa.cast(getProperty(SpeechProperty.ErrorsProperty), NSMutableDictionary.class)); }
public List<Entry> getAbbreviations() { NSMutableArray abbreviations = getValueAsType(Abbreviations, NSMutableArray.class); List<Entry> result = new ArrayList<Entry>(abbreviations.count()); for (int i=0; i < abbreviations.count(); i++) { result.add(new Entry(Rococoa.cast(abbreviations.objectAtIndex(i), NSMutableDictionary.class))); } return Collections.unmodifiableList(result); }
public List<Entry> getPronunciations() { NSMutableArray pronounciations = getValueAsType(Pronunciations, NSMutableArray.class); List<Entry> result = new ArrayList<Entry>(pronounciations.count()); for (int i=0; i < pronounciations.count(); i++) { result.add(new Entry(Rococoa.cast(pronounciations.objectAtIndex(i), NSMutableDictionary.class))); } return Collections.unmodifiableList(result); }
public static void setAllowsAutomaticWindowTabbing(boolean automatic) { if(Rococoa.cast(CLASS, NSObject.class).respondsToSelector( Foundation.selector("setAllowsAutomaticWindowTabbing:"))) { CLASS.setAllowsAutomaticWindowTabbing(automatic); } }
@Override public boolean validate(final Transfer transfer) { final NSPopUpButton popup = Rococoa.cast(item.view(), NSPopUpButton.class); popup.selectItemAtIndex(popup.indexOfItemWithRepresentedObject(String.valueOf((int) transfer.getBandwidth().getRate()))); return true; } });
public static NSColor systemGrayColor() { if(Rococoa.cast(CLASS, NSObject.class).respondsToSelector(Foundation.selector("systemGrayColor"))) { return CLASS.systemGrayColor(); } return NSColor.darkGrayColor(); }
@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); }
@Override public void outlineView_setObjectValue_forTableColumn_byItem(final NSOutlineView outlineView, final NSObject value, final NSTableColumn tableColumn, final NSObject item) { final String identifier = tableColumn.identifier(); if(identifier.equals(Column.include.name())) { final TransferItem file = cache.lookup(new NSObjectTransferItemReference(item)); final int state = Rococoa.cast(value, NSNumber.class).intValue(); this.setSelected(file, state == NSCell.NSOnState); } }
public static NSFont monospacedDigitSystemFontOfSize(double fontSize) { if(Rococoa.cast(CLASS, NSObject.class).respondsToSelector( Foundation.selector("monospacedDigitSystemFontOfSize:weight:"))) { return CLASS.monospacedDigitSystemFontOfSize_weight(new CGFloat(fontSize), new CGFloat(NSFontWeightRegular)); } return systemFontOfSize(fontSize); }
public void outlineViewColumnDidResize(final NSNotification notification) { final NSTableColumn column = Rococoa.cast(notification.userInfo().objectForKey("NSTableColumn"), NSTableColumn.class); this.columnDidResize(column.identifier(), column.width().floatValue()); }
/** * */ private void reload() { while(table.subviews().count().intValue() > 0) { (Rococoa.cast(table.subviews().lastObject(), NSView.class)).removeFromSuperviewWithoutNeedingDisplay(); } table.reloadData(); }
private void reload() { while(transferTable.subviews().count().intValue() > 0) { (Rococoa.cast(transferTable.subviews().lastObject(), NSView.class)).removeFromSuperviewWithoutNeedingDisplay(); } transferTable.reloadData(); this.updateHighlight(); this.updateSelection(); }
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; }
@Action public void setNavigationButton(NSSegmentedControl navigationButton) { this.navigationButton = navigationButton; this.navigationButton.setTarget(this.id()); this.navigationButton.setAction(Foundation.selector("navigationButtonClicked:")); final NSSegmentedCell cell = Rococoa.cast(this.navigationButton.cell(), NSSegmentedCell.class); this.navigationButton.setImage_forSegment(IconCacheFactory.<NSImage>get().iconNamed("nav-backward.tiff"), NavigationSegment.back.position()); this.navigationButton.imageForSegment(NavigationSegment.back.position()).setTemplate(true); cell.setToolTip_forSegment(LocaleFactory.localizedString("Back", "Main"), NavigationSegment.back.position()); this.navigationButton.setImage_forSegment(IconCacheFactory.<NSImage>get().iconNamed("nav-forward.tiff"), NavigationSegment.forward.position()); this.navigationButton.imageForSegment(NavigationSegment.forward.position()).setTemplate(true); cell.setToolTip_forSegment(LocaleFactory.localizedString("Forward", "Main"), NavigationSegment.forward.position()); }