/** * Get an icon which has previously been registered for this class object. * * @param elementClass * the class object which we want to get an icon for * * @return the associated icon, or null if this class or its superclass has * not been registered */ public static ImageIcon getIcon(Class<?> elementClass) { return getIcon(elementClass, true); }
/** * Get icon/disabledicon which has previously been registered for this class * object. * * @param elementClass * the class object which we want to get an icon for * @param enabled - * is icon enabled * * @return the associated icon, or null if this class or its superclass has * not been registered */ public static ImageIcon getIcon(Class<?> elementClass, boolean enabled) { String key = elementClass.getName(); ImageIcon icon = enabled ? ICON_MAP.get(key) : DISABLED_ICON_MAP.get(key); if (icon != null) { return icon; } if (elementClass.getSuperclass() != null) { return getIcon(elementClass.getSuperclass(), enabled); } return null; }
public ImageIcon getIcon(boolean enabled) { TestElement testElement = getTestElement(); try { if (testElement instanceof TestBean) { Class<?> testClass = testElement.getClass(); try { Image img = Introspector.getBeanInfo(testClass).getIcon(BeanInfo.ICON_COLOR_16x16); // If icon has not been defined, then use GUI_CLASS property if (img == null) { Object clazz = Introspector.getBeanInfo(testClass).getBeanDescriptor() .getValue(TestElement.GUI_CLASS); if (clazz == null) { log.warn("getIcon(): Can't obtain GUI class from {}", testClass); return null; } return GUIFactory.getIcon(Class.forName((String) clazz), enabled); } return new ImageIcon(img); } catch (IntrospectionException e1) { log.error("Can't obtain icon for class {}", testElement, e1); throw new org.apache.jorphan.util.JMeterError(e1); } } return GUIFactory.getIcon(Class.forName(testElement.getPropertyAsString(TestElement.GUI_CLASS)), enabled); } catch (ClassNotFoundException e) { log.warn("Can't get icon for class {}", testElement, e); return null; } }