/// <summary> /// Copies all private data from this event into that. /// Space is allocated for the copied data that will be /// freed when the that is finalized. Upon completion, /// this event is not changed. /// </summary> internal virtual void CopyPrivateDataInto(AWTEvent that) { that.Bdata = this.Bdata; // Copy canAccessSystemClipboard value from this into that. if (this is InputEvent && that is InputEvent) { Field field = Get_InputEvent_CanAccessSystemClipboard(); if (field != null) { try { bool b = field.getBoolean(this); field.setBoolean(that, b); } catch (IllegalAccessException e) { if (Log.isLoggable(PlatformLogger.Level.FINE)) { Log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e); } } } } that.IsSystemGenerated = this.IsSystemGenerated; }
private bool CanAccessSystemClipboard() { bool b = false; if (!GraphicsEnvironment.Headless) { SecurityManager sm = System.SecurityManager; if (sm != null) { try { sm.CheckPermission(SecurityConstants.AWT.ACCESS_CLIPBOARD_PERMISSION); b = true; } catch (SecurityException se) { if (Logger.isLoggable(PlatformLogger.Level.FINE)) { Logger.fine("InputEvent.canAccessSystemClipboard() got SecurityException ", se); } } } else { b = true; } } return(b); }
private static void Info(String message, Throwable t) { PlatformLogger logger = PlatformLogger.getLogger("java.util.Currency"); if (logger.isLoggable(PlatformLogger.Level.INFO)) { if (t != null) { logger.info(message, t); } else { logger.info(message); } } }
/// <summary> /// {@inheritDoc} /// </summary> public virtual bool Enter() { if (Log.isLoggable(PlatformLogger.Level.FINE)) { Log.fine("enter(): blockingEDT=" + KeepBlockingEDT.Get() + ", blockingCT=" + KeepBlockingCT.Get()); } if (!KeepBlockingEDT.CompareAndSet(false, true)) { Log.fine("The secondary loop is already running, aborting"); return(false); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Runnable run = new Runnable() Runnable run = new RunnableAnonymousInnerClassHelper(this); // We have two mechanisms for blocking: if we're on the // dispatch thread, start a new event pump; if we're // on any other thread, call wait() on the treelock Thread currentThread = Thread.CurrentThread; if (currentThread == DispatchThread) { if (Log.isLoggable(PlatformLogger.Level.FINEST)) { Log.finest("On dispatch thread: " + DispatchThread); } if (Interval != 0) { if (Log.isLoggable(PlatformLogger.Level.FINEST)) { Log.finest("scheduling the timer for " + Interval + " ms"); } Timer.Schedule(TimerTask = new TimerTaskAnonymousInnerClassHelper(this), Interval); } // Dispose SequencedEvent we are dispatching on the the current // AppContext, to prevent us from hang - see 4531693 for details SequencedEvent currentSE = KeyboardFocusManager.CurrentKeyboardFocusManager.CurrentSequencedEvent; if (currentSE != null) { if (Log.isLoggable(PlatformLogger.Level.FINE)) { Log.fine("Dispose current SequencedEvent: " + currentSE); } currentSE.Dispose(); } // In case the exit() method is called before starting // new event pump it will post the waking event to EDT. // The event will be handled after the the new event pump // starts. Thus, the enter() method will not hang. // // Event pump should be privileged. See 6300270. AccessController.doPrivileged(new PrivilegedActionAnonymousInnerClassHelper(this, run)); } else { if (Log.isLoggable(PlatformLogger.Level.FINEST)) { Log.finest("On non-dispatch thread: " + currentThread); } lock (TreeLock) { if (Filter != null) { DispatchThread.AddEventFilter(Filter); } try { EventQueue eq = DispatchThread.EventQueue; eq.PostEvent(new PeerEvent(this, run, PeerEvent.PRIORITY_EVENT)); KeepBlockingCT.Set(true); if (Interval > 0) { long currTime = DateTimeHelperClass.CurrentUnixTimeMillis(); while (KeepBlockingCT.Get() && ((ExtCondition != null) ? ExtCondition.Evaluate() : true) && (currTime + Interval > DateTimeHelperClass.CurrentUnixTimeMillis())) { Monitor.Wait(TreeLock, TimeSpan.FromMilliseconds(Interval)); } } else { while (KeepBlockingCT.Get() && ((ExtCondition != null) ? ExtCondition.Evaluate() : true)) { TreeLock.Wait(); } } if (Log.isLoggable(PlatformLogger.Level.FINE)) { Log.fine("waitDone " + KeepBlockingEDT.Get() + " " + KeepBlockingCT.Get()); } } catch (InterruptedException e) { if (Log.isLoggable(PlatformLogger.Level.FINE)) { Log.fine("Exception caught while waiting: " + e); } } finally { if (Filter != null) { DispatchThread.RemoveEventFilter(Filter); } } // If the waiting process has been stopped because of the // time interval passed or an exception occurred, the state // should be changed KeepBlockingEDT.Set(false); KeepBlockingCT.Set(false); } } return(true); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void put(URI uri, java.util.Map<String, java.util.List<String>> responseHeaders) throws java.io.IOException public override void Put(URI uri, IDictionary <String, IList <String> > responseHeaders) { // pre-condition check if (uri == null || responseHeaders == null) { throw new IllegalArgumentException("Argument is null"); } // if there's no default CookieStore, no need to remember any cookie if (CookieJar == null) { return; } PlatformLogger logger = PlatformLogger.getLogger("java.net.CookieManager"); foreach (String headerKey in responseHeaders.Keys) { // RFC 2965 3.2.2, key must be 'Set-Cookie2' // we also accept 'Set-Cookie' here for backward compatibility if (headerKey == null || !(headerKey.EqualsIgnoreCase("Set-Cookie2") || headerKey.EqualsIgnoreCase("Set-Cookie"))) { continue; } foreach (String headerValue in responseHeaders[headerKey]) { try { IList <HttpCookie> cookies; try { cookies = HttpCookie.Parse(headerValue); } catch (IllegalArgumentException) { // Bogus header, make an empty list and log the error cookies = Collections.EmptyList(); if (logger.isLoggable(PlatformLogger.Level.SEVERE)) { logger.severe("Invalid cookie for " + uri + ": " + headerValue); } } foreach (HttpCookie cookie in cookies) { if (cookie.Path == null) { // If no path is specified, then by default // the path is the directory of the page/doc String path = uri.Path; if (!path.EndsWith("/")) { int i = path.LastIndexOf("/"); if (i > 0) { path = path.Substring(0, i + 1); } else { path = "/"; } } cookie.Path = path; } // As per RFC 2965, section 3.3.1: // Domain Defaults to the effective request-host. (Note that because // there is no dot at the beginning of effective request-host, // the default Domain can only domain-match itself.) if (cookie.Domain == null) { String host = uri.Host; if (host != null && !host.Contains(".")) { host += ".local"; } cookie.Domain = host; } String ports = cookie.Portlist; if (ports != null) { int port = uri.Port; if (port == -1) { port = "https".Equals(uri.Scheme) ? 443 : 80; } if (ports.Empty) { // Empty port list means this should be restricted // to the incoming URI port cookie.Portlist = "" + port; if (ShouldAcceptInternal(uri, cookie)) { CookieJar.Add(uri, cookie); } } else { // Only store cookies with a port list // IF the URI port is in that list, as per // RFC 2965 section 3.3.2 if (IsInPortList(ports, port) && ShouldAcceptInternal(uri, cookie)) { CookieJar.Add(uri, cookie); } } } else { if (ShouldAcceptInternal(uri, cookie)) { CookieJar.Add(uri, cookie); } } } } catch (IllegalArgumentException) { // invalid set-cookie header string // no-op } } } }
public static Cursor GetSystemCustomCursor(String name) { GraphicsEnvironment.CheckHeadless(); Cursor cursor = SystemCustomCursors[name]; if (cursor == null) { lock (SystemCustomCursors) { if (SystemCustomCursorProperties == null) { LoadSystemCustomCursorProperties(); } } String prefix = CursorDotPrefix + name; String key = prefix + DotFileSuffix; if (!SystemCustomCursorProperties.ContainsKey(key)) { if (Log.isLoggable(PlatformLogger.Level.FINER)) { Log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null"); } return(null); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String fileName = systemCustomCursorProperties.getProperty(key); String fileName = SystemCustomCursorProperties.GetProperty(key); String localized = SystemCustomCursorProperties.GetProperty(prefix + DotNameSuffix); if (localized == null) { localized = name; } String hotspot = SystemCustomCursorProperties.GetProperty(prefix + DotHotspotSuffix); if (hotspot == null) { throw new AWTException("no hotspot property defined for cursor: " + name); } StringTokenizer st = new StringTokenizer(hotspot, ","); if (st.CountTokens() != 2) { throw new AWTException("failed to parse hotspot property for cursor: " + name); } int x = 0; int y = 0; try { x = Convert.ToInt32(st.NextToken()); y = Convert.ToInt32(st.NextToken()); } catch (NumberFormatException) { throw new AWTException("failed to parse hotspot property for cursor: " + name); } try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int fx = x; int fx = x; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int fy = y; int fy = y; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String flocalized = localized; String flocalized = localized; cursor = AccessController.doPrivileged <Cursor>(new PrivilegedExceptionActionAnonymousInnerClassHelper(fileName, fx, fy, flocalized)); } catch (Exception e) { throw new AWTException("Exception: " + e.GetType() + " " + e.Message + " occurred while creating cursor " + name); } if (cursor == null) { if (Log.isLoggable(PlatformLogger.Level.FINER)) { Log.finer("Cursor.getSystemCustomCursor(" + name + ") returned null"); } } else { SystemCustomCursors[name] = cursor; } } return(cursor); }
/* * Checks if a new focus cycle takes place and returns a Component to traverse focus to. * @param comp a possible focus cycle root or policy provider * @param traversalDirection the direction of the traversal * @return a Component to traverse focus to if {@code comp} is a root or provider * and implicit down-cycle is set, otherwise {@code null} */ private Component GetComponentDownCycle(Component comp, int traversalDirection) { Component retComp = null; if (comp is Container) { Container cont = (Container)comp; if (cont.FocusCycleRoot) { if (ImplicitDownCycleTraversal) { retComp = cont.FocusTraversalPolicy.GetDefaultComponent(cont); if (retComp != null && Log.isLoggable(PlatformLogger.Level.FINE)) { Log.fine("### Transfered focus down-cycle to " + retComp + " in the focus cycle root " + cont); } } else { return(null); } } else if (cont.FocusTraversalPolicyProvider) { retComp = (traversalDirection == FORWARD_TRAVERSAL ? cont.FocusTraversalPolicy.GetDefaultComponent(cont) : cont.FocusTraversalPolicy.GetLastComponent(cont)); if (retComp != null && Log.isLoggable(PlatformLogger.Level.FINE)) { Log.fine("### Transfered focus to " + retComp + " in the FTP provider " + cont); } } } return(retComp); }