/** * This implementation of <code>nativeToJava</code> converts a platform specific * representation of HTML text to a java <code>String</code>. * * @param transferData the platform specific representation of the data to be converted * @return a java <code>String</code> containing HTML text if the conversion was successful; * otherwise null * * @see Transfer#javaToNative */ public Object nativeToJava(TransferData transferData){ if (!isSupportedType(transferData) || transferData.data == null) return null; NSString string = (NSString) transferData.data; return string.getString(); }
/** * This implementation of <code>nativeToJava</code> converts a platform specific * representation of plain text to a java <code>String</code>. * * @param transferData the platform specific representation of the data to be converted * @return a java <code>String</code> containing text if the conversion was successful; otherwise null * * @see Transfer#javaToNative */ public Object nativeToJava(TransferData transferData){ if (!isSupportedType(transferData) || transferData.data == null) return null; NSString string = (NSString) transferData.data; return string.getString(); }
/** * This implementation of <code>nativeToJava</code> converts a platform specific * representation of RTF text to a java <code>String</code>. * * @param transferData the platform specific representation of the data to be converted * @return a java <code>String</code> containing RTF text if the conversion was successful; * otherwise null * * @see Transfer#javaToNative */ public Object nativeToJava(TransferData transferData){ if (!isSupportedType(transferData) || transferData.data == null) return null; NSString string = (NSString) transferData.data; return string.getString(); }
String getClipboardText () { NSPasteboard pasteboard = NSPasteboard.generalPasteboard (); if (pasteboard == null) return ""; NSString string = pasteboard.stringForType (OS.NSStringPboardType); return string != null ? string.getString () : null; }
boolean webView_runBeforeUnloadConfirmPanelWithMessage_initiatedByFrame(long /*int*/ sender, long /*int*/ messageID, long /*int*/ frame) { NSString message = new NSString(messageID); StringBuffer text = new StringBuffer(Compatibility.getMessage("SWT_OnBeforeUnload_Message1")); //$NON-NLS-1$ text.append("\n\n"); //$NON-NLS-1$ text.append(message.getString()); text.append("\n\n"); //$NON-NLS-1$ text.append(Compatibility.getMessage("SWT_OnBeforeUnload_Message2")); //$NON-NLS-1$ MessageBox messageBox = new MessageBox(browser.getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION | SWT.SHEET); messageBox.setMessage(text.toString()); return messageBox.open() == SWT.OK; }
/** * This implementation of <code>nativeToJava</code> converts a platform * specific representation of a URL to a java <code>String</code>. * * @param transferData the platform specific representation of the data to be converted * @return a java <code>String</code> containing a URL if the conversion was successful; * otherwise null * * @see Transfer#javaToNative */ public Object nativeToJava(TransferData transferData){ if (!isSupportedType(transferData) || transferData.data == null) return null; NSURL nsUrl = (NSURL) transferData.data; NSString nsString = nsUrl.absoluteString(); nsString = nsString.stringByReplacingPercentEscapesUsingEncoding(OS.NSUTF8StringEncoding); return nsString.getString(); }
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(); }
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$ }
void webView_setStatusText(long /*int*/ sender, long /*int*/ textID) { NSString text = new NSString(textID); int length = (int)/*64*/text.length(); if (length == 0) return; StatusTextEvent statusText = new StatusTextEvent(browser); statusText.display = browser.getDisplay(); statusText.widget = browser; statusText.text = text.getString(); for (int i = 0; i < statusTextListeners.length; i++) { statusTextListeners[i].changed(statusText); } }
/** * Returns a string containing a copy of the contents of the * receiver's text field, or an empty string if there are no * contents. * * @return the receiver's text * * @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> * * @since 3.4 */ public String getText () { checkWidget (); NSString str = new NSTextFieldCell (textView.cell ()).title (); return str.getString (); }
void webView_didReceiveTitle_forFrame(long /*int*/ sender, long /*int*/ titleID, long /*int*/ frameID) { if (frameID == webView.mainFrame().id) { NSString title = new NSString(titleID); String newTitle = title.getString(); TitleEvent newEvent = new TitleEvent(browser); newEvent.display = browser.getDisplay(); newEvent.widget = browser; newEvent.title = newTitle; for (int i = 0; i < titleListeners.length; i++) { titleListeners[i].changed(newEvent); } } }
int webView_runJavaScriptConfirmPanelWithMessage(long /*int*/ sender, long /*int*/ messageID) { NSString message = new NSString(messageID); String text = message.getString(); MessageBox messageBox = new MessageBox(browser.getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION); messageBox.setText("Javascript"); //$NON-NLS-1$ messageBox.setMessage(text); return messageBox.open() == SWT.OK ? 1 : 0; }
void webView_runJavaScriptAlertPanelWithMessage(long /*int*/ sender, long /*int*/ messageID) { NSString message = new NSString(messageID); String text = message.getString(); MessageBox messageBox = new MessageBox(browser.getShell(), SWT.OK | SWT.ICON_WARNING); messageBox.setText("Javascript"); //$NON-NLS-1$ messageBox.setMessage(text); messageBox.open(); }
boolean textView_clickOnLink_atIndex(long /*int*/ id, long /*int*/ sel, long /*int*/ textView, long /*int*/ link, long /*int*/ charIndex) { NSString str = new NSString (link); Event event = new Event (); event.text = str.getString(); sendSelectionEvent (SWT.Selection, event, true); // Widget may be disposed at this point. if (isDisposed()) return true; for (int i = 0; i < offsets.length; i++) { if ((charIndex >= offsets[i].x) && (charIndex <= offsets[i].y)) { focusIndex = i; break; } } redrawWidget(view, false); ignoreNextMouseUp = true; return true; }
void comboBoxSelectionDidChange(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) { NSComboBox widget = (NSComboBox)view; long /*int*/ tableSelection = widget.indexOfSelectedItem(); widget.selectItemAtIndex(tableSelection); NSAttributedString attStr = new NSAttributedString (widget.itemObjectValueAtIndex(tableSelection)); NSString nsString = attStr.string(); if (nsString != null) setText(nsString.getString(), true); if (!ignoreSelection) sendSelectionEvent (SWT.Selection, null, display.trackingControl != this); }
void createPanelDidEnd(long /*int*/ sheet, long /*int*/ returnCode, long /*int*/ contextInfo) { NSURL failingURL = new NSURL(contextInfo); failingURL.autorelease(); if (returnCode != OS.NSFileHandlingPanelOKButton) return; /* nothing more to do */ long /*int*/ method = OS.class_getClassMethod(OS.class_NSURLRequest, OS.sel_setAllowsAnyHTTPSCertificate); if (method != 0) { OS.objc_msgSend(OS.class_NSURLRequest, OS.sel_setAllowsAnyHTTPSCertificate, 1, failingURL.host().id); setUrl(failingURL.absoluteString().getString(), null, null); } }
void setSelectedTextAttribute(id value, int childId) { NSString newText = new NSString(value.id); int rangeStart = 0; id charsValue = getNumberOfCharactersAttribute(childId); int rangeEnd = new NSNumber(charsValue).intValue(); id rangeObj = getSelectedTextRangeAttribute(childId); if (rangeObj != null) { NSRange range = new NSValue(rangeObj).rangeValue(); rangeStart = (int)/*64*/range.location; rangeEnd = (int)/*64*/(range.location + range.length); } if (accessibleEditableTextListenersSize() > 0) { AccessibleEditableTextEvent event = new AccessibleEditableTextEvent(this); event.start = rangeStart; event.end = rangeEnd; event.string = newText.getString(); for (int i = 0; i < accessibleEditableTextListenersSize(); i++) { AccessibleEditableTextListener listener = (AccessibleEditableTextListener) accessibleEditableTextListeners.elementAt(i); listener.replaceText(event); } } }
/** * Returns a <code>PrinterData</code> object representing * the default printer or <code>null</code> if there is no * default printer. * * @return the default printer data or null * * @since 2.1 */ public static PrinterData getDefaultPrinterData() { NSAutoreleasePool pool = null; if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); try { NSPrinter printer = NSPrintInfo.defaultPrinter(); if (printer == null) return null; NSString str = printer.name(); return new PrinterData(DRIVER, str.getString()); } finally { if (pool != null) pool.release(); } }
void download_decideDestinationWithSuggestedFilename(long /*int*/ downloadId, long /*int*/ filename) { NSString string = new NSString(filename); String name = string.getString(); FileDialog dialog = new FileDialog(browser.getShell(), SWT.SAVE); dialog.setText(SWT.getMessage ("SWT_FileDownload")); //$NON-NLS-1$ dialog.setFileName(name); String path = dialog.open(); NSURLDownload download = new NSURLDownload(downloadId); if (path == null) { /* cancel pressed */ download.cancel(); return; } download.setDestination(NSString.stringWith(path), true); }
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; } } } };