/** * This implementation of <code>nativeToJava</code> converts a platform specific * representation of a list of file names to a java <code>String[]</code>. * Each String in the array contains the absolute path for a single file or directory. * * @param transferData the platform specific representation of the data to be converted * @return a java <code>String[]</code> containing a list of file names if the conversion * was successful; otherwise null * * @see Transfer#javaToNative */ public Object nativeToJava(TransferData transferData) { if (!isSupportedType(transferData) || transferData.data == null) return null; NSArray array = (NSArray) transferData.data; if (array.count() == 0) return null; int count = (int)/*64*/array.count(); String[] fileNames = new String[count]; for (int i=0; i<count; i++) { NSString string = new NSString(array.objectAtIndex(i)); fileNames[i] = string.getString(); } return fileNames; }
Control [] _getChildren () { NSArray views = contentView().subviews(); int count = (int)/*64*/views.count(); Control [] children = new Control [count]; if (count == 0) return children; int j = 0; for (int i=0; i<count; i++){ Widget widget = display.getWidget (views.objectAtIndex (count - i - 1).id); if (widget != null && widget != this && widget instanceof Control) { children [j++] = (Control) widget; } } if (j == count) return children; Control [] newChildren = new Control [j]; System.arraycopy (children, 0, newChildren, 0, j); return newChildren; }
boolean acceptsFirstResponder (long /*int*/ id, long /*int*/ sel) { if ((state & CANVAS) != 0) { if ((style & SWT.NO_FOCUS) == 0 && hooksKeys ()) { if (contentView().subviews().count() == 0) return true; } return false; } return super.acceptsFirstResponder (id, sel); }
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; }
static String getCacheParentPath () { if (OS.VERSION >= 0x1060) { NSArray array = NSFileManager.defaultManager ().URLsForDirectory (OS.NSCachesDirectory, OS.NSUserDomainMask); if (array.count () > 0) { NSURL url = new NSURL (array.objectAtIndex (0)); return url.path ().getString () + Mozilla.SEPARATOR_OS + "eclipse"; //$NON-NLS-1$ } } String baseDir = System.getProperty ("user.home"); //$NON-NLS-1$ return baseDir + "/Library/Caches/eclipse"; //$NON-NLS-1$ }
NSTouch findTouchWithId(NSArray touches, NSObject identity) { long /*int*/ count = touches.count(); for (long /*int*/ i = 0; i < count; i++) { NSTouch aTouch = new NSTouch(touches.objectAtIndex(i).id); NSObject currIdentity = new NSObject(OS.objc_msgSend(aTouch.id, OS.sel_identity)); if (currIdentity.isEqual(identity)) return aTouch; } return null; }
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 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*/ accessibilityAttributeNames(long /*int*/ id, long /*int*/ sel) { long /*int*/ returnValue = super.accessibilityAttributeNames(id, sel); if (id == accessibleHandle()) { if ((style & (SWT.CHECK|SWT.RADIO)) !=0) { NSArray baseArray = new NSArray(returnValue); NSMutableArray ourNames = NSMutableArray.arrayWithCapacity(baseArray.count() + 1); ourNames.addObjectsFromArray(baseArray); ourNames.addObject(OS.NSAccessibilityValueAttribute); returnValue = ourNames.id; } else if ((style & SWT.DROP_DOWN) != 0) { NSArray baseArray = new NSArray(returnValue); NSMutableArray ourNames = NSMutableArray.arrayWithCapacity(baseArray.count() + 1); ourNames.addObjectsFromArray(baseArray); ourNames.addObject(OS.NSAccessibilityChildrenAttribute); returnValue = ourNames.id; } } else { returnValue = super.accessibilityAttributeNames(id, sel); } return returnValue; }
long /*int*/ accessibilityActionNames(long /*int*/ id, long /*int*/ sel) { long /*int*/ returnValue = super.accessibilityActionNames(id, sel); if (id == accessibleHandle()) { if ((style & SWT.DROP_DOWN) != 0) { NSArray baseArray = new NSArray(returnValue); NSMutableArray ourNames = NSMutableArray.arrayWithCapacity(baseArray.count() + 1); ourNames.addObjectsFromArray(baseArray); ourNames.addObject(OS.NSAccessibilityShowMenuAction); returnValue = ourNames.id; } } else { returnValue = super.accessibilityActionNames(id, sel); } return returnValue; }
id getCellForColumnAndRowParameter(id parameter, int childID) { id returnValue = null; NSArray parameterObject = new NSArray(parameter.id); if (parameterObject.count() == 2) { AccessibleTableEvent event = new AccessibleTableEvent(this); event.column = new NSNumber(parameterObject.objectAtIndex(0)).intValue(); event.row = new NSNumber(parameterObject.objectAtIndex(1)).intValue(); for (int i = 0; i < accessibleTableListenersSize(); i++) { AccessibleTableListener listener = (AccessibleTableListener)accessibleTableListeners.elementAt(i); listener.getCell(event); returnValue = event.accessible.delegate; } } return returnValue; }
/** * Returns the number of lines. * * @return the number of lines in the widget * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public int getLineCount () { checkWidget (); if ((style & SWT.SINGLE) != 0) return 1; NSTextStorage storage = ((NSTextView) view).textStorage (); int count = (int)/*64*/storage.paragraphs ().count (); NSString string = storage.string(); long /*int*/ length = string.length(), c; if (length == 0 || (c = string.characterAtIndex(length - 1)) == '\n' || c == '\r') { count++; } return count; }
long /*int*/ accessibilityActionNames(long /*int*/ id, long /*int*/ sel) { long /*int*/ returnValue = super.accessibilityActionNames(id, sel); if (handleIsAccessible(id)) { if (accessible != null) { NSArray baseArray = accessible.internal_accessibilityActionNames(ACC.CHILDID_SELF); if (baseArray != null) returnValue = baseArray.id; } if (hooks(SWT.MenuDetect) || (menu != null && !menu.isDisposed())) { NSArray baseArray = new NSArray(returnValue); NSMutableArray ourNames = NSMutableArray.arrayWithCapacity(baseArray.count() + 1); ourNames.addObjectsFromArray(baseArray); ourNames.addObject(OS.NSAccessibilityShowMenuAction); returnValue = ourNames.id; } } return returnValue; }
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; } };
void setFrameSize(long /*int*/ id, long /*int*/ sel, NSSize size) { super.setFrameSize (id, sel, size); /* * Bug in Cocoa. When a search field is resized while having * focus, its editor is not properly positioned within the * widget. The fix is to reposition the editor. */ if ((style & SWT.SEARCH) != 0) { NSSearchField widget = (NSSearchField)view; NSText editor = widget.currentEditor (); if (editor != null) { NSArray subviews = widget.subviews (); if (subviews.count () > 0) { NSRect rect = widget.cell ().drawingRectForBounds (widget.bounds ()); new NSView (subviews.objectAtIndex (0)).setFrame (rect); } } } }
Rectangle getBounds (NSArray screens) { NSScreen screen = new NSScreen(screens.objectAtIndex(0)); NSRect primaryFrame = convertRect(screen, screen.frame()); double /*float*/ minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE; double /*float*/ minY = Float.MAX_VALUE, maxY = Float.MIN_VALUE; long /*int*/ count = screens.count(); for (int i = 0; i < count; i++) { screen = new NSScreen(screens.objectAtIndex(i)); NSRect frame = convertRect(screen, screen.frame()); double /*float*/ x1 = frame.x, x2 = frame.x + frame.width; double /*float*/ y1 = primaryFrame.height - frame.y, y2 = primaryFrame.height - (frame.y + frame.height); if (x1 < minX) minX = x1; if (x2 < minX) minX = x2; if (x1 > maxX) maxX = x1; if (x2 > maxX) maxX = x2; if (y1 < minY) minY = y1; if (y2 < minY) minY = y2; if (y1 > maxY) maxY = y1; if (y2 > maxY) maxY = y2; } return new Rectangle ((int)minX, (int)minY, (int)(maxX - minX), (int)(maxY - minY)); }
long /*int*/ accessibilityAttributeValue(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { long /*int*/ returnValue = 0; NSString attributeName = new NSString(arg0); // If the check column is visible, don't report it back as a column for accessibility purposes. // The check column is meant to appear as a part of the first column. if (attributeName.isEqualToString (OS.NSAccessibilityColumnsAttribute) || attributeName.isEqualToString(OS.NSAccessibilityVisibleColumnsAttribute)) { if ((style & SWT.CHECK) != 0) { long /*int*/ superValue = super.accessibilityAttributeValue(id, sel, arg0); if (superValue != 0) { NSArray columns = new NSArray(superValue); NSMutableArray columnsWithoutCheck = NSMutableArray.arrayWithCapacity(columns.count() - 1); columnsWithoutCheck.addObjectsFromArray(columns); columnsWithoutCheck.removeObjectAtIndex(0); returnValue = columnsWithoutCheck.id; } } } if (returnValue != 0) { return returnValue; } else { return super.accessibilityAttributeValue(id, sel, arg0); } }
long /*int*/ accessibilityAttributeValue(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { long /*int*/ returnValue = 0; NSString attributeName = new NSString(arg0); // If the check column is visible, don't report it back as a column for accessibility purposes. // The check column is meant to appear as a part of the first column. if (attributeName.isEqualToString (OS.NSAccessibilityColumnsAttribute) || attributeName.isEqualToString(OS.NSAccessibilityVisibleColumnsAttribute)) { if ((style & SWT.CHECK) != 0) { long /*int*/ superValue = super.accessibilityAttributeValue(id, sel, arg0); if (superValue != 0) { NSArray columns = new NSArray(superValue); NSMutableArray columnsWithoutCheck = NSMutableArray.arrayWithCapacity(columns.count() - 1); columnsWithoutCheck.addObjectsFromArray(columns); columnsWithoutCheck.removeObjectAtIndex(0); returnValue = columnsWithoutCheck.id; } } } if (returnValue != 0) { return returnValue; } else { return super.accessibilityAttributeValue(id, sel, arg0); } }
public void run () { NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage (); NSURL url = NSURL.URLWithString (NSString.stringWith (CookieUrl)); NSArray cookies = storage.cookiesForURL (url); int count = (int)/*64*/cookies.count (); if (count == 0) return; NSString name = NSString.stringWith (CookieName); for (int i = 0; i < count; i++) { NSHTTPCookie current = new NSHTTPCookie (cookies.objectAtIndex (i)); if (current.name ().compare (name) == OS.NSOrderedSame) { CookieValue = current.value ().getString (); return; } } } };
/** * Returns a rectangle which describes the area of the * receiver which is capable of displaying data. * * @return the client area * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #getBounds */ public Rectangle getClientArea () { checkDevice (); NSArray screens = NSScreen.screens(); if (screens.count() != 1) return getBounds (screens); NSScreen screen = new NSScreen(screens.objectAtIndex(0)); NSRect frame = convertRect(screen, screen.frame());; NSRect visibleFrame = convertRect(screen, screen.visibleFrame()); double /*float*/ y = frame.height - (visibleFrame.y + visibleFrame.height); return new Rectangle((int)visibleFrame.x, (int)y, (int)visibleFrame.width, (int)visibleFrame.height); }