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