Пример #1
0
 /// <summary>
 /// Waits until all events currently on the event queue have been processed. </summary>
 /// <exception cref="IllegalThreadStateException"> if called on the AWT event dispatching thread </exception>
 public virtual void WaitForIdle()
 {
     lock (this)
     {
         CheckNotDispatchThread();
         // post a dummy event to the queue so we know when
         // all the events before it have been processed
         try
         {
             SunToolkit.flushPendingEvents();
             EventQueue.InvokeAndWait(new RunnableAnonymousInnerClassHelper(this));
         }
         catch (InterruptedException ite)
         {
             System.Console.Error.WriteLine("Robot.waitForIdle, non-fatal exception caught:");
             Console.WriteLine(ite.ToString());
             Console.Write(ite.StackTrace);
         }
         catch (InvocationTargetException ine)
         {
             System.Console.Error.WriteLine("Robot.waitForIdle, non-fatal exception caught:");
             Console.WriteLine(ine.ToString());
             Console.Write(ine.StackTrace);
         }
     }
 }
Пример #2
0
 internal void Dispose()
 {
     Dispatched = true;
     if (ToNotify != null)
     {
         SunToolkit.postEvent(ToNotify, new SentEvent());
     }
     lock (this)
     {
         Monitor.PulseAll(this);
     }
 }
Пример #3
0
        /// <summary>
        /// Get the most recent event time in the {@code EventQueue} which the {@code source}
        /// belongs to.
        /// </summary>
        /// <param name="source"> the source of the event </param>
        /// <exception cref="IllegalArgumentException">  if source is null. </exception>
        /// <returns> most recent event time in the {@code EventQueue} </returns>
        private static long GetMostRecentEventTimeForSource(Object source)
        {
            if (source == null)
            {
                // throw the IllegalArgumentException to conform to EventObject spec
                throw new IllegalArgumentException("null source");
            }
            AppContext appContext = SunToolkit.targetToAppContext(source);
            EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext);

            return(AWTAccessor.EventQueueAccessor.getMostRecentEventTime(eventQueue));
        }
Пример #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private TrayIcon() throws UnsupportedOperationException, HeadlessException, SecurityException
        private TrayIcon()
        {
            SystemTray.CheckSystemTrayAllowed();
            if (GraphicsEnvironment.Headless)
            {
                throw new HeadlessException();
            }
            if (!SystemTray.Supported)
            {
                throw new UnsupportedOperationException();
            }
            SunToolkit.insertTargetMapping(this, AppContext.AppContext);
        }
Пример #5
0
        /// <summary>
        /// Disposes of this instance. This method is invoked once the nested event
        /// has been dispatched and handled, or when the peer of the target of the
        /// nested event has been disposed with a call to Component.removeNotify.
        ///
        /// NOTE: Locking protocol.  Since SunToolkit.postEvent can get EventQueue lock,
        /// it shall never be called while holding the lock on the list,
        /// as EventQueue lock is held during dispatching and dispatch() will get
        /// lock on the list. The locks should be acquired in the same order.
        /// </summary>
        internal void Dispose()
        {
            lock (typeof(SequencedEvent))
            {
                if (Disposed)
                {
                    return;
                }
                if (KeyboardFocusManager.CurrentKeyboardFocusManager.CurrentSequencedEvent == this)
                {
                    KeyboardFocusManager.CurrentKeyboardFocusManager.CurrentSequencedEvent = null;
                }
                Disposed = true;
            }
            // Wake myself up
            if (AppContext != null)
            {
                SunToolkit.postEvent(AppContext, new SentEvent());
            }

            SequencedEvent next = null;

            lock (typeof(SequencedEvent))
            {
                Monitor.PulseAll(typeof(SequencedEvent));

                if (List.First == this)
                {
                    List.RemoveFirst();

                    if (!List.Empty)
                    {
                        next = (SequencedEvent)List.First;
                    }
                }
                else
                {
                    List.Remove(this);
                }
            }
            // Wake up waiting threads
            if (next != null && next.AppContext != null)
            {
                SunToolkit.postEvent(next.AppContext, new SentEvent());
            }
        }
Пример #6
0
 public virtual void Dispatch()
 {
     try
     {
         if (Nested != null)
         {
             Toolkit.EventQueue.DispatchEvent(Nested);
         }
     }
     finally
     {
         Dispatched = true;
         if (ToNotify != null)
         {
             SunToolkit.postEvent(ToNotify, new SentEvent());
         }
         lock (this)
         {
             Monitor.PulseAll(this);
         }
     }
 }
Пример #7
0
        /// <summary>
        /// Adds the specified component to this scroll pane container.
        /// If the scroll pane has an existing child component, that
        /// component is removed and the new one is added. </summary>
        /// <param name="comp"> the component to be added </param>
        /// <param name="constraints">  not applicable </param>
        /// <param name="index"> position of child component (must be &lt;= 0) </param>
        protected internal sealed override void AddImpl(Component comp, Object constraints, int index)
        {
            lock (TreeLock)
            {
                if (ComponentCount > 0)
                {
                    Remove(0);
                }
                if (index > 0)
                {
                    throw new IllegalArgumentException("position greater than 0");
                }

                if (!SunToolkit.isLightweightOrUnknown(comp))
                {
                    base.AddImpl(comp, constraints, index);
                }
                else
                {
                    AddToPanel(comp, constraints, index);
                }
            }
        }