Search in sources :

Example 26 with AppContext

use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.

the class SunClipboard method lostOwnershipNow.

protected void lostOwnershipNow(final AppContext disposedContext) {
    final SunClipboard sunClipboard = SunClipboard.this;
    ClipboardOwner owner = null;
    Transferable contents = null;
    synchronized (sunClipboard) {
        final AppContext context = sunClipboard.contentsContext;
        if (context == null) {
            return;
        }
        if (disposedContext == null || context == disposedContext) {
            owner = sunClipboard.owner;
            contents = sunClipboard.contents;
            sunClipboard.contentsContext = null;
            sunClipboard.owner = null;
            sunClipboard.contents = null;
            sunClipboard.clearNativeContext();
            context.removePropertyChangeListener(AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
        } else {
            return;
        }
    }
    if (owner != null) {
        owner.lostOwnership(sunClipboard, contents);
    }
}
Also used : AppContext(sun.awt.AppContext) Transferable(java.awt.datatransfer.Transferable) ClipboardOwner(java.awt.datatransfer.ClipboardOwner)

Example 27 with AppContext

use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.

the class SunClipboard method removeFlavorListener.

public synchronized void removeFlavorListener(FlavorListener listener) {
    if (listener == null) {
        return;
    }
    AppContext appContext = AppContext.getAppContext();
    EventListenerAggregate contextFlavorListeners = (EventListenerAggregate) appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
    if (contextFlavorListeners == null) {
        //else we throw NullPointerException, but it is forbidden
        return;
    }
    if (contextFlavorListeners.remove(listener) && --numberOfFlavorListeners == 0) {
        unregisterClipboardViewerChecked();
        currentFormats = null;
    }
}
Also used : EventListenerAggregate(sun.awt.EventListenerAggregate) AppContext(sun.awt.AppContext)

Example 28 with AppContext

use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.

the class ExecutableInputMethodManager method showInputMethodMenuOnRequesterEDT.

// Shows Input Method Menu on the EDT of requester component
// to avoid side effects. See 6544309.
private void showInputMethodMenuOnRequesterEDT(Component requester) throws InterruptedException, InvocationTargetException {
    if (requester == null) {
        return;
    }
    class AWTInvocationLock {
    }
    Object lock = new AWTInvocationLock();
    InvocationEvent event = new InvocationEvent(requester, new Runnable() {

        public void run() {
            showInputMethodMenu();
        }
    }, lock, true);
    AppContext requesterAppContext = SunToolkit.targetToAppContext(requester);
    synchronized (lock) {
        SunToolkit.postEvent(requesterAppContext, event);
        while (!event.isDispatched()) {
            lock.wait();
        }
    }
    Throwable eventThrowable = event.getThrowable();
    if (eventThrowable != null) {
        throw new InvocationTargetException(eventThrowable);
    }
}
Also used : InvocationEvent(java.awt.event.InvocationEvent) AppContext(sun.awt.AppContext) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 29 with AppContext

use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.

the class SunDropTargetContextPeer method postDropTargetEvent.

protected int postDropTargetEvent(final Component component, final int x, final int y, final int dropAction, final int actions, final long[] formats, final long nativeCtxt, final int eventID, final boolean dispatchType) {
    AppContext appContext = SunToolkit.targetToAppContext(component);
    EventDispatcher dispatcher = new EventDispatcher(this, dropAction, actions, formats, nativeCtxt, dispatchType);
    SunDropTargetEvent event = new SunDropTargetEvent(component, eventID, x, y, dispatcher);
    if (dispatchType == SunDropTargetContextPeer.DISPATCH_SYNC) {
        DataTransferer.getInstance().getToolkitThreadBlockedHandler().lock();
    }
    // schedule callback
    SunToolkit.postEvent(appContext, event);
    eventPosted(event);
    if (dispatchType == SunDropTargetContextPeer.DISPATCH_SYNC) {
        while (!dispatcher.isDone()) {
            DataTransferer.getInstance().getToolkitThreadBlockedHandler().enter();
        }
        DataTransferer.getInstance().getToolkitThreadBlockedHandler().unlock();
        // return target's response
        return dispatcher.getReturnValue();
    } else {
        return 0;
    }
}
Also used : AppContext(sun.awt.AppContext)

Example 30 with AppContext

use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.

the class FetcherInfo method createFetchers.

/**
      * Create and start ImageFetcher threads in the appropriate ThreadGroup.
      */
private static void createFetchers(final FetcherInfo info) {
    // We need to instantiate a new ImageFetcher thread.
    // First, figure out which ThreadGroup we'll put the
    // new ImageFetcher into
    final AppContext appContext = AppContext.getAppContext();
    ThreadGroup threadGroup = appContext.getThreadGroup();
    ThreadGroup fetcherThreadGroup;
    try {
        if (threadGroup.getParent() != null) {
            // threadGroup is not the root, so we proceed
            fetcherThreadGroup = threadGroup;
        } else {
            // threadGroup is the root ("system") ThreadGroup.
            // We instead want to use its child: the "main"
            // ThreadGroup.  Thus, we start with the current
            // ThreadGroup, and go up the tree until
            // threadGroup.getParent().getParent() == null.
            threadGroup = Thread.currentThread().getThreadGroup();
            ThreadGroup parent = threadGroup.getParent();
            while ((parent != null) && (parent.getParent() != null)) {
                threadGroup = parent;
                parent = threadGroup.getParent();
            }
            fetcherThreadGroup = threadGroup;
        }
    } catch (SecurityException e) {
        // Not allowed access to parent ThreadGroup -- just use
        // the AppContext's ThreadGroup
        fetcherThreadGroup = appContext.getThreadGroup();
    }
    final ThreadGroup fetcherGroup = fetcherThreadGroup;
    java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {

        public Object run() {
            for (int i = 0; i < info.fetchers.length; i++) {
                if (info.fetchers[i] == null) {
                    ImageFetcher f = new ImageFetcher(fetcherGroup, i);
                    try {
                        f.start();
                        info.fetchers[i] = f;
                        info.numFetchers++;
                        break;
                    } catch (Error e) {
                    }
                }
            }
            return null;
        }
    });
    return;
}
Also used : AppContext(sun.awt.AppContext)

Aggregations

AppContext (sun.awt.AppContext)74 HashMap (java.util.HashMap)3 Hashtable (java.util.Hashtable)3 Locale (java.util.Locale)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 EventListenerAggregate (sun.awt.EventListenerAggregate)3 FlavorListener (java.awt.datatransfer.FlavorListener)2 WeakReference (java.lang.ref.WeakReference)2 Map (java.util.Map)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 LookAndFeel (javax.swing.LookAndFeel)2 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)2 MetalTheme (javax.swing.plaf.metal.MetalTheme)2 ValueNamePair (org.compiere.util.ValueNamePair)2 PeerEvent (sun.awt.PeerEvent)2 AccumulativeRunnable (sun.swing.AccumulativeRunnable)2 Container (java.awt.Container)1 EventQueue (java.awt.EventQueue)1 Font (java.awt.Font)1 Rectangle (java.awt.Rectangle)1