use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.
the class HyperlinkAttributedStringFactory method create.
/**
* @param value Existing attributes
* @param hyperlink URL
* @return Clickable and underlined string to put into text field.
*/
private static NSAttributedString create(final NSMutableAttributedString value, final String hyperlink) {
final NSRange range = NSRange.NSMakeRange(new NSUInteger(0), value.length());
value.beginEditing();
value.addAttributeInRange(NSMutableAttributedString.LinkAttributeName, hyperlink, range);
// make the text appear in blue
value.addAttributeInRange(NSMutableAttributedString.ForegroundColorAttributeName, NSColor.blueColor(), range);
// system font
value.addAttributeInRange(NSMutableAttributedString.FontAttributeName, NSFont.systemFontOfSize(NSFont.smallSystemFontSize()), range);
// next make the text appear with an underline
value.addAttributeInRange(NSMutableAttributedString.UnderlineStyleAttributeName, NSNumber.numberWithInt(NSMutableAttributedString.SingleUnderlineStyle), range);
value.endEditing();
return value;
}
use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.
the class ApplicationSupportDirectoryFinder method find.
@Override
public Local find() {
final NSArray directories = FoundationKitFunctions.library.NSSearchPathForDirectoriesInDomains(FoundationKitFunctions.NSSearchPathDirectory.NSApplicationSupportDirectory, FoundationKitFunctions.NSSearchPathDomainMask.NSUserDomainMask, true);
final String application = preferences.getProperty("application.name");
if (directories.count().intValue() == 0) {
log.error("Failed searching for application support directory");
return new FinderLocal("~/Library/Application Support", application);
} else {
final String directory = directories.objectAtIndex(new NSUInteger(0)).toString();
if (log.isInfoEnabled()) {
log.info(String.format("Found application support directory in %s", directory));
}
final Local folder = new FinderLocal(directory, application);
if (log.isDebugEnabled()) {
log.debug(String.format("Use folder %s for application support directory", folder));
}
return folder;
}
}
use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.
the class LibraryLogDirectoryFinder method find.
@Override
public Local find() {
final NSArray directories = FoundationKitFunctions.library.NSSearchPathForDirectoriesInDomains(FoundationKitFunctions.NSSearchPathDirectory.NSLibraryDirectory, FoundationKitFunctions.NSSearchPathDomainMask.NSUserDomainMask, true);
final String application = preferences.getProperty("application.name");
if (directories.count().intValue() == 0) {
log.error("Failed searching for library directory");
return new FinderLocal("~/Library/Logs", application);
} else {
final String directory = directories.objectAtIndex(new NSUInteger(0)).toString();
if (log.isInfoEnabled()) {
log.info(String.format("Found library directory in %s", directory));
}
final Local folder = new FinderLocal(new FinderLocal(directory, "Logs"), application);
if (log.isDebugEnabled()) {
log.debug(String.format("Use folder %s for log directory", folder));
}
return folder;
}
}
use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.
the class KeychainCertificateStore method toDEREncodedCertificates.
public static NSArray toDEREncodedCertificates(final List<X509Certificate> certificates) {
// Prepare the certificate chain
try {
final Object[] encoded = new DEREncoder().encode(certificates);
} catch (CertificateException e) {
log.error(String.format("Failure %s DER encoding certificates %s", e, certificates));
return NSArray.array();
}
final NSMutableArray certs = NSMutableArray.arrayWithCapacity(new NSUInteger(certificates.size()));
for (X509Certificate certificate : certificates) {
try {
final SecCertificateRef certificateRef = SecurityFunctions.library.SecCertificateCreateWithData(null, NSData.dataWithBase64EncodedString(Base64.encodeBase64String(certificate.getEncoded())));
if (null == certificateRef) {
log.error(String.format("Error creating converting from ASN.1 DER encoded certificate %s", certificate));
continue;
}
certs.addObject(certificateRef);
} catch (CertificateEncodingException e) {
log.error(String.format("Failure %s retrieving encoded certificate", e));
}
}
return certs;
}
use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.
the class MainController method serviceUploadFileUrl_.
/**
* NSService implementation
*/
@Action
public void serviceUploadFileUrl_(final NSPasteboard pboard, final String userData) {
if (log.isDebugEnabled()) {
log.debug(String.format("serviceUploadFileUrl_: with user data %s", userData));
}
if (pboard.availableTypeFromArray(NSArray.arrayWithObject(NSPasteboard.FilenamesPboardType)) != null) {
NSObject o = pboard.propertyListForType(NSPasteboard.FilenamesPboardType);
if (o != null) {
if (o.isKindOfClass(NSArray.CLASS)) {
final NSArray elements = Rococoa.cast(o, NSArray.class);
List<Local> files = new ArrayList<Local>();
for (int i = 0; i < elements.count().intValue(); i++) {
files.add(LocalFactory.get(elements.objectAtIndex(new NSUInteger(i)).toString()));
}
this.upload(files);
}
}
}
}
Aggregations