Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* @(#)UIManagerLookup.java 4/5/2007
*
* Copyright 2002 - 2007 JIDE Software Inc. All rights reserved.
*/
package com.jidesoft.plaf;
import com.jidesoft.converter.ObjectConverterManager;
import sun.reflect.Reflection;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* This class simply uses UIManager's get method to lookup the UIDefaults. We used this everywhere in our code so that
* we have one central place to find out which UIDefaults we are using. Another good thing is you can use {@link
* #setTrace(boolean)} and {@link #setDebug(boolean)} to turn on the trace so that it will print out which UIDefaults we
* are trying to get.
*/
public class UIDefaultsLookup {
private static boolean _debug = false;
private static boolean _trace = false;
/**
* Sets the debug mode. If debug mode is on, we will print out any UIDefaults that the value is null.
*
* @param debug true or false.
*/
public static void setDebug(boolean debug) {
_debug = debug;
}
/**
* Sets the trace mode. If trace mode is on, we will print out any UIDefaults we are trying to get and its current
* value.
*
* @param trace true or false.
*/
public static void setTrace(boolean trace) {
_trace = trace;
}
public static void put(UIDefaults table, String key, Object value) {
Object v = table.get(key);
if (v == null || !(v instanceof Map)) {
v = new HashMap();
table.put(key, v);
}
Object cl = UIManager.get("ClassLoader");
if (!(cl instanceof ClassLoader)) {
cl = value.getClass().getClassLoader();
}
((Map) v).put(cl, value);
}
// Returns the invoker's class loader, or null if none.
// NOTE: This must always be invoked when there is exactly one intervening
// frame from the core libraries on the stack between this method's
// invocation and the desired invoker.
static ClassLoader getCallerClassLoader() {
Object cl = UIManager.get("ClassLoader");
if (cl instanceof ClassLoader) {
return (ClassLoader) cl;
}
// NOTE use of more generic Reflection.getCallerClass()
Class caller = Reflection.getCallerClass(3);
// This can be null if the VM is requesting it
if (caller == null) {
return null;
}
// Circumvent security check since this is package-private
return caller.getClassLoader();
}
public static Object get(Object key) {
Object value = UIManager.get(key);
log(value, key, null);
if (value instanceof Map && "Theme.painter".equals(key)) {
Map map = (Map) value;
try {
ClassLoader classLoader = getCallerClassLoader();
Object o = map.get(classLoader);
while (o == null && classLoader.getParent() != null) {
classLoader = classLoader.getParent();
o = map.get(classLoader);
}
if (o == null && map.size() >= 1) {
Collection