Widget widget = null;
String widgetClass = widgetNode.getAttribute("class");
String widgetName = widgetNode.getAttribute("name");
String widgetPreset = widgetNode.getAttribute("preset");
boolean hasPreset = !widgetPreset.equals("");
Constructor widgetConstructor = (Constructor) constructorCache.get(widgetClass + (hasPreset ? "_P" : ""));
NodeList childNodes = widgetNode.getChildNodes();
try {
try {
if (widgetConstructor == null) {
String classAttribute = widgetNode.getAttribute("class");
String className = DEFAULT_PREFIX + classAttribute;
if (classAttribute.indexOf('.') != -1)
className = classAttribute;
Class wClass = Class.forName(className);
if (hasPreset)
widgetConstructor = wClass.getConstructor(new Class[] { Widget.class, String.class, String.class });
else
widgetConstructor = wClass.getConstructor(new Class[] { Widget.class, String.class });
constructorCache.put(widgetClass + (hasPreset ? "_P" : ""), widgetConstructor);
}
if (hasPreset)
widget =
(Widget) widgetConstructor.newInstance(
new Object[] { parentWidget, widgetName.equals("") ? null : widgetName, widgetPreset });
else
widget =
(Widget) widgetConstructor.newInstance(
new Object[] { parentWidget, widgetName.equals("") ? null : widgetName });
} catch (ClassNotFoundException e) {
throw new GUIException("Unknown widget class [" + widgetNode.getAttribute("class") + "]");
} catch (NoSuchMethodException e) {
throw new GUIException("Widget constructor not found", e);