use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class SunFontManager method getCreatedFonts.
public Font[] getCreatedFonts() {
Hashtable<String, Font2D> nameTable;
if (fontsAreRegistered) {
nameTable = createdByFullName;
} else if (fontsAreRegisteredPerAppContext) {
AppContext appContext = AppContext.getAppContext();
nameTable = (Hashtable<String, Font2D>) appContext.get(regFullNameKey);
} else {
return null;
}
Locale l = getSystemStartupLocale();
synchronized (nameTable) {
Font[] fonts = new Font[nameTable.size()];
int i = 0;
for (Font2D font2D : nameTable.values()) {
fonts[i++] = new Font(font2D.getFontName(l), Font.PLAIN, 1);
}
return fonts;
}
}
use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class WindowsRadioButtonUI method createUI.
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
WindowsRadioButtonUI windowsRadioButtonUI = (WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY);
if (windowsRadioButtonUI == null) {
windowsRadioButtonUI = new WindowsRadioButtonUI();
appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI);
}
return windowsRadioButtonUI;
}
use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class WindowsButtonUI method createUI.
// ********************************
// Create PLAF
// ********************************
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
WindowsButtonUI windowsButtonUI = (WindowsButtonUI) appContext.get(WINDOWS_BUTTON_UI_KEY);
if (windowsButtonUI == null) {
windowsButtonUI = new WindowsButtonUI();
appContext.put(WINDOWS_BUTTON_UI_KEY, windowsButtonUI);
}
return windowsButtonUI;
}
use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class Component method dispatchEventImpl.
@SuppressWarnings("deprecation")
void dispatchEventImpl(AWTEvent e) {
int id = e.getID();
// Check that this component belongs to this app-context
AppContext compContext = appContext;
if (compContext != null && !compContext.equals(AppContext.getAppContext())) {
if (eventLog.isLoggable(PlatformLogger.Level.FINE)) {
eventLog.fine("Event " + e + " is being dispatched on the wrong AppContext");
}
}
if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
eventLog.finest("{0}", e);
}
/*
* 0. Set timestamp and modifiers of current event.
*/
if (!(e instanceof KeyEvent)) {
// Timestamp of a key event is set later in DKFM.preDispatchKeyEvent(KeyEvent).
EventQueue.setCurrentEventAndMostRecentTime(e);
}
if (e instanceof SunDropTargetEvent) {
((SunDropTargetEvent) e).dispatch();
return;
}
if (!e.focusManagerIsDispatching) {
// lightweight Component support
if (e.isPosted) {
e = KeyboardFocusManager.retargetFocusEvent(e);
e.isPosted = true;
}
// and dispatching function
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().dispatchEvent(e)) {
return;
}
}
if ((e instanceof FocusEvent) && focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
focusLog.finest("" + e);
}
// stops.
if (id == MouseEvent.MOUSE_WHEEL && (!eventTypeEnabled(id)) && (peer != null && !peer.handlesWheelScrolling()) && (dispatchMouseWheelToAncestor((MouseWheelEvent) e))) {
return;
}
/*
* 2. Allow the Toolkit to pass this to AWTEventListeners.
*/
Toolkit toolkit = Toolkit.getDefaultToolkit();
toolkit.notifyAWTEventListeners(e);
/*
* 3. If no one has consumed a key event, allow the
* KeyboardFocusManager to process it.
*/
if (!e.isConsumed()) {
if (e instanceof java.awt.event.KeyEvent) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().processKeyEvent(this, (KeyEvent) e);
if (e.isConsumed()) {
return;
}
}
}
/*
* 4. Allow input methods to process the event
*/
if (areInputMethodsEnabled()) {
// and the input context also handles the Java composition window
if (((e instanceof InputMethodEvent) && !(this instanceof CompositionArea)) || // c) isConsumed() is always true for semantic events.
(e instanceof InputEvent) || (e instanceof FocusEvent)) {
InputContext inputContext = getInputContext();
if (inputContext != null) {
inputContext.dispatchEvent(e);
if (e.isConsumed()) {
if ((e instanceof FocusEvent) && focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
focusLog.finest("3579: Skipping " + e);
}
return;
}
}
}
} else {
// the active/passive/peered clients loose focus.
if (id == FocusEvent.FOCUS_GAINED) {
InputContext inputContext = getInputContext();
if (inputContext != null && inputContext instanceof sun.awt.im.InputContext) {
((sun.awt.im.InputContext) inputContext).disableNativeIM();
}
}
}
/*
* 5. Pre-process any special events before delivery
*/
switch(id) {
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
Container p = (Container) ((this instanceof Container) ? this : parent);
if (p != null) {
p.preProcessKeyEvent((KeyEvent) e);
if (e.isConsumed()) {
if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
focusLog.finest("Pre-process consumed event");
}
return;
}
}
break;
case WindowEvent.WINDOW_CLOSING:
if (toolkit instanceof WindowClosingListener) {
windowClosingException = ((WindowClosingListener) toolkit).windowClosingNotify((WindowEvent) e);
if (checkWindowClosingException()) {
return;
}
}
break;
default:
break;
}
/*
* 6. Deliver event for normal processing
*/
if (newEventsOnly) {
//
if (eventEnabled(e)) {
processEvent(e);
}
} else if (id == MouseEvent.MOUSE_WHEEL) {
// newEventsOnly will be false for a listenerless ScrollPane, but
// MouseWheelEvents still need to be dispatched to it so scrolling
// can be done.
autoProcessMouseWheel((MouseWheelEvent) e);
} else if (!(e instanceof MouseEvent && !postsOldMouseEvents())) {
//
// backward compatibility
//
Event olde = e.convertToOld();
if (olde != null) {
int key = olde.key;
int modifiers = olde.modifiers;
postEvent(olde);
if (olde.isConsumed()) {
e.consume();
}
//
switch(olde.id) {
case Event.KEY_PRESS:
case Event.KEY_RELEASE:
case Event.KEY_ACTION:
case Event.KEY_ACTION_RELEASE:
if (olde.key != key) {
((KeyEvent) e).setKeyChar(olde.getKeyEventChar());
}
if (olde.modifiers != modifiers) {
((KeyEvent) e).setModifiers(olde.modifiers);
}
break;
default:
break;
}
}
}
/*
* 8. Special handling for 4061116 : Hook for browser to close modal
* dialogs.
*/
if (id == WindowEvent.WINDOW_CLOSING && !e.isConsumed()) {
if (toolkit instanceof WindowClosingListener) {
windowClosingException = ((WindowClosingListener) toolkit).windowClosingDelivered((WindowEvent) e);
if (checkWindowClosingException()) {
return;
}
}
}
/*
* 9. Allow the peer to process the event.
* Except KeyEvents, they will be processed by peer after
* all KeyEventPostProcessors
* (see DefaultKeyboardFocusManager.dispatchKeyEvent())
*/
if (!(e instanceof KeyEvent)) {
ComponentPeer tpeer = peer;
if (e instanceof FocusEvent && (tpeer == null || tpeer instanceof LightweightPeer)) {
// if focus owner is lightweight then its native container
// processes event
Component source = (Component) e.getSource();
if (source != null) {
Container target = source.getNativeContainer();
if (target != null) {
tpeer = target.getPeer();
}
}
}
if (tpeer != null) {
tpeer.handleEvent(e);
}
}
}
use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class Dialog method show.
/**
* Makes the {@code Dialog} visible. If the dialog and/or its owner
* are not yet displayable, both are made displayable. The
* dialog will be validated prior to being made visible.
* If the dialog is already visible, this will bring the dialog
* to the front.
* <p>
* If the dialog is modal and is not already visible, this call
* will not return until the dialog is hidden by calling hide or
* dispose. It is permissible to show modal dialogs from the event
* dispatching thread because the toolkit will ensure that another
* event pump runs while the one which invoked this method is blocked.
* @see Component#hide
* @see Component#isDisplayable
* @see Component#validate
* @see #isModal
* @see Window#setVisible(boolean)
* @deprecated As of JDK version 1.5, replaced by
* {@link #setVisible(boolean) setVisible(boolean)}.
*/
@Deprecated
public void show() {
if (!initialized) {
throw new IllegalStateException("The dialog component " + "has not been initialized properly");
}
beforeFirstShow = false;
if (!isModal()) {
conditionalShow(null, null);
} else {
AppContext showAppContext = AppContext.getAppContext();
AtomicLong time = new AtomicLong();
Component predictedFocusOwner = null;
try {
predictedFocusOwner = getMostRecentFocusOwner();
if (conditionalShow(predictedFocusOwner, time)) {
modalFilter = ModalEventFilter.createFilterForDialog(this);
final Conditional cond = new Conditional() {
@Override
public boolean evaluate() {
return windowClosingException == null;
}
};
// to all EDTs (for all AppContexts)
if (modalityType == ModalityType.TOOLKIT_MODAL) {
Iterator<AppContext> it = AppContext.getAppContexts().iterator();
while (it.hasNext()) {
AppContext appContext = it.next();
if (appContext == showAppContext) {
continue;
}
EventQueue eventQueue = (EventQueue) appContext.get(AppContext.EVENT_QUEUE_KEY);
// it may occur that EDT for appContext hasn't been started yet, so
// we post an empty invocation event to trigger EDT initialization
Runnable createEDT = new Runnable() {
public void run() {
}
;
};
eventQueue.postEvent(new InvocationEvent(this, createEDT));
EventDispatchThread edt = eventQueue.getDispatchThread();
edt.addEventFilter(modalFilter);
}
}
modalityPushed();
try {
final EventQueue eventQueue = AccessController.doPrivileged(new PrivilegedAction<EventQueue>() {
public EventQueue run() {
return Toolkit.getDefaultToolkit().getSystemEventQueue();
}
});
secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
if (!secondaryLoop.enter()) {
secondaryLoop = null;
}
} finally {
modalityPopped();
}
// from all EDTs (for all AppContexts)
if (modalityType == ModalityType.TOOLKIT_MODAL) {
Iterator<AppContext> it = AppContext.getAppContexts().iterator();
while (it.hasNext()) {
AppContext appContext = it.next();
if (appContext == showAppContext) {
continue;
}
EventQueue eventQueue = (EventQueue) appContext.get(AppContext.EVENT_QUEUE_KEY);
EventDispatchThread edt = eventQueue.getDispatchThread();
edt.removeEventFilter(modalFilter);
}
}
if (windowClosingException != null) {
windowClosingException.fillInStackTrace();
throw windowClosingException;
}
}
} finally {
if (predictedFocusOwner != null) {
// Restore normal key event dispatching
KeyboardFocusManager.getCurrentKeyboardFocusManager().dequeueKeyEvents(time.get(), predictedFocusOwner);
}
}
}
}
Aggregations