/** * 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); }
private void installPlugin(JMeterPlugin plugin) { String[][] icons = plugin.getIconMappings(); ClassLoader classloader = plugin.getClass().getClassLoader(); for (String[] icon : icons) { URL resource = classloader.getResource(icon[1].trim()); if (resource == null) { log.warn("Can't find icon for {} - {}", icon[0], icon[1]); } else { GUIFactory.registerIcon(icon[0], new ImageIcon(resource)); if (icon.length > 2 && icon[2] != null) { URL resource2 = classloader.getResource(icon[2].trim()); if (resource2 == null) { log.info("Can't find disabled icon for {} - {}", icon[0], icon[2]); } else { GUIFactory.registerDisabledIcon(icon[0], new ImageIcon(resource2)); } } } } } }
/** * Get a component instance which has previously been registered for this * class object. * * @param elementClass * the class object which we want to get an instance of * * @return an instance of the class, or null if this class or its superclass * has not been registered */ public static JComponent getGUI(Class<?> elementClass) { // TODO: This method doesn't appear to be used. String key = elementClass.getName(); JComponent gui = (JComponent) GUI_MAP.get(key); if (gui != null) { return gui; } if (elementClass.getSuperclass() != null) { return getGUI(elementClass.getSuperclass()); } return null; }
/** * 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; } }