Search in sources :

Example 71 with AppContext

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

the class MetalToggleButtonUI method createUI.

// ********************************
//        Create PLAF
// ********************************
public static ComponentUI createUI(JComponent b) {
    AppContext appContext = AppContext.getAppContext();
    MetalToggleButtonUI metalToggleButtonUI = (MetalToggleButtonUI) appContext.get(METAL_TOGGLE_BUTTON_UI_KEY);
    if (metalToggleButtonUI == null) {
        metalToggleButtonUI = new MetalToggleButtonUI();
        appContext.put(METAL_TOGGLE_BUTTON_UI_KEY, metalToggleButtonUI);
    }
    return metalToggleButtonUI;
}
Also used : AppContext(sun.awt.AppContext)

Example 72 with AppContext

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

the class CreatedFontTracker method getCS.

/**
     * Returns an AppContext-specific counting semaphore.
     */
private static synchronized Semaphore getCS() {
    final AppContext appContext = AppContext.getAppContext();
    Semaphore cs = (Semaphore) appContext.get(CreatedFontTracker.class);
    if (cs == null) {
        // Make a semaphore with 5 permits that obeys the first-in first-out
        // granting of permits.
        cs = new Semaphore(5, true);
        appContext.put(CreatedFontTracker.class, cs);
    }
    return cs;
}
Also used : AppContext(sun.awt.AppContext) Semaphore(java.util.concurrent.Semaphore)

Example 73 with AppContext

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

the class bug6938813 method validate.

private static void validate() throws Exception {
    AppContext appContext = AppContext.getAppContext();
    assertTrue(DTD.getDTD(DTD_KEY).getName().equals(DTD_KEY), "DTD.getDTD() mixed AppContexts");
    // Spoil hash value
    DTD invalidDtd = DTD.getDTD("invalid DTD");
    DTD.putDTDHash(DTD_KEY, invalidDtd);
    assertTrue(DTD.getDTD(DTD_KEY) == invalidDtd, "Something wrong with DTD.getDTD()");
    Object dtdKey = getParserDelegator_DTD_KEY();
    assertTrue(appContext.get(dtdKey) == null, "ParserDelegator mixed AppContexts");
    // Init default DTD
    new ParserDelegator();
    Object dtdValue = appContext.get(dtdKey);
    assertTrue(dtdValue != null, "ParserDelegator.defaultDTD isn't initialized");
    // Try reinit default DTD
    new ParserDelegator();
    assertTrue(dtdValue == appContext.get(dtdKey), "ParserDelegator.defaultDTD created a duplicate");
    HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
    if (styleSheet == null) {
        // First AppContext
        styleSheet = htmlEditorKit.getStyleSheet();
        assertTrue(styleSheet != null, "htmlEditorKit.getStyleSheet() returns null");
        assertTrue(htmlEditorKit.getStyleSheet() == styleSheet, "Something wrong with htmlEditorKit.getStyleSheet()");
    } else {
        assertTrue(htmlEditorKit.getStyleSheet() != styleSheet, "HtmlEditorKit.getStyleSheet() mixed AppContexts");
    }
}
Also used : ParserDelegator(javax.swing.text.html.parser.ParserDelegator) DTD(javax.swing.text.html.parser.DTD) AppContext(sun.awt.AppContext) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit)

Example 74 with AppContext

use of sun.awt.AppContext in project adempiere by adempiere.

the class PLAFEditor method setLFSelection.

//  dynInit
/**
	 *  Set Picks From Environment
	 */
private void setLFSelection() {
    m_setting = true;
    //  Search for PLAF
    ValueNamePair plaf = null;
    LookAndFeel lookFeel = UIManager.getLookAndFeel();
    String look = lookFeel.getClass().getName();
    for (int i = 0; i < AdempierePLAF.getPLAFs().length; i++) {
        ValueNamePair vp = AdempierePLAF.getPLAFs()[i];
        if (vp.getValue().equals(look)) {
            plaf = vp;
            break;
        }
    }
    if (plaf != null)
        lfField.setSelectedItem(plaf);
    //  Search for Theme
    MetalTheme metalTheme = null;
    ValueNamePair theme = null;
    boolean metal = UIManager.getLookAndFeel() instanceof MetalLookAndFeel;
    themeField.setModel(new DefaultComboBoxModel(AdempierePLAF.getThemes()));
    if (metal) {
        theme = null;
        AppContext context = AppContext.getAppContext();
        metalTheme = (MetalTheme) context.get("currentMetalTheme");
        if (metalTheme != null) {
            String lookTheme = metalTheme.getName();
            for (int i = 0; i < AdempierePLAF.getThemes().length; i++) {
                ValueNamePair vp = AdempierePLAF.getThemes()[i];
                if (vp.getName().equals(lookTheme)) {
                    theme = vp;
                    break;
                }
            }
        }
        if (theme != null)
            themeField.setSelectedItem(theme);
    }
    m_setting = false;
    log.info(lookFeel + " - " + metalTheme);
}
Also used : MetalTheme(javax.swing.plaf.metal.MetalTheme) AppContext(sun.awt.AppContext) ValueNamePair(org.compiere.util.ValueNamePair) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) LookAndFeel(javax.swing.LookAndFeel) CompiereLookAndFeel(org.compiere.plaf.CompiereLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel)

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