public void run () { NSURL url = NSURL.URLWithString (NSString.stringWith (CookieUrl)); NSMutableDictionary headers = NSMutableDictionary.dictionaryWithCapacity (1); headers.setValue (NSString.stringWith (CookieValue), NSString.stringWith (HEADER_SETCOOKIE)); NSArray cookies = NSHTTPCookie.cookiesWithResponseHeaderFields (headers, url); if (cookies.count () == 0) return; NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage (); NSHTTPCookie cookie = new NSHTTPCookie (cookies.objectAtIndex (0)); storage.setCookie (cookie); CookieResult = true; } };
public String getText() { WebFrame mainFrame = webView.mainFrame(); WebDataSource dataSource = mainFrame.dataSource(); if (dataSource == null) return ""; //$NON-NLS-1$ WebDocumentRepresentation representation = dataSource.representation(); if (representation == null) return ""; //$NON-NLS-1$ NSString source = representation.documentSource(); if (source == null) return ""; //$NON-NLS-1$ return source.getString(); }
int getCharCount() { NSString str; if ((style & SWT.READ_ONLY) != 0) { str = ((NSPopUpButton)view).titleOfSelectedItem(); } else { str = new NSCell(((NSComboBox)view).cell()).title(); } if (str == null) return 0; return (int)/*64*/str.length(); }
void updateCursorRects (boolean enabled, NSView widget) { if (enabled) { widget.resetCursorRects (); widget.updateTrackingAreas (); } else { widget.discardCursorRects (); NSArray areas = widget.trackingAreas (); for (int i = 0; i < areas.count(); i++) { widget.removeTrackingArea (new NSTrackingArea (areas.objectAtIndex (i))); } } }
long /*int*/ webView_resource_willSendRequest_redirectResponse_fromDataSource(long /*int*/ sender, long /*int*/ identifier, long /*int*/ request, long /*int*/ redirectResponse, long /*int*/ dataSource) { NSURLRequest nsRequest = new NSURLRequest (request); NSURL url = nsRequest.URL (); if (url.isFileURL ()) { NSMutableURLRequest newRequest = new NSMutableURLRequest (nsRequest.mutableCopy ()); newRequest.autorelease (); newRequest.setCachePolicy (OS.NSURLRequestReloadIgnoringLocalCacheData); return newRequest.id; } return request; }
boolean hasDefaultButton () { NSArray windows = application.windows(); long /*int*/ count = windows.count(); for (int i = 0; i < count; i++) { NSWindow window = new NSWindow(windows.objectAtIndex(i)); if (window.defaultButtonCell() != null) { return true; } } return false; }
void removePool () { NSAutoreleasePool pool = pools [poolCount - 1]; pools [--poolCount] = null; if (poolCount == 0) { NSMutableDictionary dictionary = NSThread.currentThread().threadDictionary(); dictionary.removeObjectForKey(NSString.stringWith("SWT_NSAutoreleasePool")); } pool.release (); }
boolean isBundled () { NSBundle mainBundle = NSBundle.mainBundle(); if (mainBundle != null) { NSDictionary info = mainBundle.infoDictionary(); if (info != null) { return NSString.stringWith("APPL").isEqual(info.objectForKey(NSString.stringWith("CFBundlePackageType"))); //$NON-NLS-1$ $NON-NLS-2$ } } return false; }
public SWTMacHack () { NSArray screens = NSScreen.screens(); NSScreen screen = new NSScreen(screens.objectAtIndex(0)); this.screenScale = (float)screen.backingScaleFactor(); }
NSRect titleRectForBounds (long /*int*/ id, long /*int*/ sel, NSRect cellFrame) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); NSRect result = new NSRect(); OS.objc_msgSendSuper_stret(result, super_struct, sel, cellFrame); return result; }
public void run() { NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage(); NSArray cookies = storage.cookies(); int count = (int)/*64*/cookies.count (); for (int i = 0; i < count; i++) { NSHTTPCookie cookie = new NSHTTPCookie(cookies.objectAtIndex(i)); if (cookie.isSessionOnly()) { storage.deleteCookie(cookie); } } } };
void webView_windowScriptObjectAvailable (long /*int*/ webView, long /*int*/ windowScriptObject) { NSObject scriptObject = new NSObject (windowScriptObject); NSString key = NSString.stringWith ("external"); //$NON-NLS-1$ scriptObject.setValue (delegate, key); }
public NSSize contentViewMargins() { NSSize result = new NSSize(); OS.objc_msgSend_stret(result, this.id, OS.sel_contentViewMargins); return result; }
public NSPoint transformPoint(NSPoint aPoint) { NSPoint result = new NSPoint(); OS.objc_msgSend_stret(result, this.id, OS.sel_transformPoint_, aPoint); return result; }
id accessibleHandle(Accessible accessible) { if (accessible.delegate != null) return accessible.delegate; if (accessible.control != null) { NSView view = accessible.control.view; long /*int*/ handle = OS.objc_msgSend(view.id, OS.sel_accessibleHandle); return new id(handle); } return null; }
public NSRect imageRectForBounds(NSRect theRect) { NSRect result = new NSRect(); OS.objc_msgSend_stret(result, this.id, OS.sel_imageRectForBounds_, theRect); return result; }
int getLastEventTime () { NSEvent event = application.currentEvent(); if (event == null) return 0; double timestamp = event.timestamp() * 1000; while (timestamp > 0x7FFFFFFF) { timestamp -= 0x7FFFFFFF; } return (int)timestamp; }
void addTraits(NSMutableDictionary dict) { if ((extraTraits & OS.NSBoldFontMask) != 0) { dict.setObject(NSNumber.numberWithDouble(SYNTHETIC_BOLD), OS.NSStrokeWidthAttributeName); } if ((extraTraits & OS.NSItalicFontMask) != 0) { dict.setObject(NSNumber.numberWithDouble(SYNTHETIC_ITALIC), OS.NSObliquenessAttributeName); } }
NSRange textView_willChangeSelectionFromCharacterRange_toCharacterRange (long /*int*/ id, long /*int*/ sel, long /*int*/ aTextView, long /*int*/ oldSelectedCharRange, long /*int*/ newSelectedCharRange) { /* * If the selection is changing as a result of the receiver getting focus * then return the receiver's last selection range, otherwise the full * text will be automatically selected. */ if (receivingFocus && selectionRange != null) return selectionRange; /* allow the selection change to proceed */ NSRange result = new NSRange (); OS.memmove(result, newSelectedCharRange, NSRange.sizeof); return result; }
NSRect expansionFrameWithFrame_inView(long /*int*/ id, long /*int*/ sel, NSRect cellRect, long /*int*/ view) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); NSRect result = new NSRect(); OS.objc_msgSendSuper_stret(result, super_struct, sel, cellRect, view); return result; }