/// <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); }
/// <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); }
/* * 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); }