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);
}
}
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;
}
}
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);
}
}
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;
}
}
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;
}
Aggregations