List of usage examples for java.beans PropertyDescriptor setShortDescription
public void setShortDescription(String text)
From source file:net.sourceforge.vulcan.dto.PluginConfigDto.java
protected final void addProperty(List<PropertyDescriptor> pds, String name, String labelKey, String shortDescriptionKey, Locale locale, Map<String, ? extends Object> attrs) { try {/*from w w w. jav a 2 s. c om*/ final PropertyDescriptor pd = new PropertyDescriptor(name, getClass()); pd.setDisplayName(applicationContext.getMessage(labelKey, null, locale)); pd.setShortDescription(applicationContext.getMessage(shortDescriptionKey, null, locale)); if (attrs != null) { for (String key : attrs.keySet()) { pd.setValue(key, attrs.get(key)); } } pds.add(pd); } catch (IntrospectionException e) { throw new RuntimeException(e); } }
From source file:com.twinsoft.convertigo.beans.core.MySimpleBeanInfo.java
protected PropertyDescriptor getPropertyDescriptor(String name) throws IntrospectionException { checkAdditionalProperties();/*from www . jav a 2s .c o m*/ for (int i = 0; i < properties.length; i++) { PropertyDescriptor property = properties[i]; if (name.equals(property.getName())) { PropertyDescriptor clone = new PropertyDescriptor(name, property.getReadMethod(), property.getWriteMethod()); clone.setDisplayName(property.getDisplayName()); clone.setShortDescription(property.getShortDescription()); clone.setPropertyEditorClass(property.getPropertyEditorClass()); clone.setBound(property.isBound()); clone.setConstrained(property.isConstrained()); clone.setExpert(property.isExpert()); clone.setHidden(property.isHidden()); clone.setPreferred(property.isPreferred()); for (String attributeName : Collections.list(property.attributeNames())) { clone.setValue(attributeName, property.getValue(attributeName)); } return properties[i] = clone; } } return null; }
From source file:net.sourceforge.vulcan.web.struts.forms.PluginConfigForm.java
public void introspect(HttpServletRequest request) throws IntrospectionException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException { Class<?> cls = null;//from ww w. j a va 2s.co m if ("pluginConfig".equals(focus)) { cls = pluginConfig.getClass(); this.breadCrumbs.clear(); this.breadCrumbs.add("Setup"); if (isProjectPlugin()) { this.breadCrumbs.add("Projects"); this.breadCrumbs.add(projectName); this.breadCrumbs.add(this.pluginConfig.getPluginName()); } else { this.breadCrumbs.add("Plugins"); this.breadCrumbs.add(this.pluginConfig.getPluginName()); } } else { cls = PropertyUtils.getPropertyType(this, focus); if (cls.isArray()) { cls = cls.getComponentType(); } } final String prefix = focus + "."; final PropertyDescriptor[] pds; if (PluginConfigDto.class.isAssignableFrom(cls)) { final PluginConfigDto pluginConfig = (PluginConfigDto) getFocusObject(); final List<PropertyDescriptor> tmp = pluginConfig.getPropertyDescriptors(request.getLocale()); pds = tmp.toArray(new PropertyDescriptor[tmp.size()]); if (pluginConfig instanceof PluginProfileDto) { ((PluginProfileDto) pluginConfig).checkPoint(); } } else { final BeanInfo beanInfo = Introspector.getBeanInfo(cls); Introspector.flushFromCaches(cls); pds = beanInfo.getPropertyDescriptors(); } if (isNested()) { for (PropertyDescriptor pd : propertyDescriptors) { if (focus.startsWith(pd.getName())) { breadCrumbs.add(pd.getDisplayName()); } } } types.clear(); choices.clear(); propertyDescriptors.clear(); hiddenPasswords.clear(); for (PropertyDescriptor pd : pds) { final String name = prefix + pd.getName(); final PropertyDescriptor cp = new PropertyDescriptor(pd.getName(), pd.getReadMethod(), pd.getWriteMethod()); cp.setShortDescription(pd.getShortDescription()); cp.setDisplayName(pd.getDisplayName()); cp.setName(name); propertyDescriptors.add(cp); types.put(name, getTypeAndPrepare(name, pd)); } putBreadCrumbsInRequest(request); }
From source file:org.apache.openjpa.lib.conf.ConfigurationImpl.java
/** * Create a property descriptor for the given value. *///from w w w .j av a2 s.c o m private PropertyDescriptor getPropertyDescriptor(Value val) throws IntrospectionException { String prop = val.getProperty(); prop = prop.substring(prop.lastIndexOf('.') + 1); // set up property descriptor PropertyDescriptor pd; try { pd = new PropertyDescriptor(Introspector.decapitalize(prop), getClass()); } catch (IntrospectionException ie) { // if there aren't any methods for this value(i.e., if it's a // dynamically-added value), then an IntrospectionException will // be thrown. Try to create a PD with no read or write methods. pd = new PropertyDescriptor(Introspector.decapitalize(prop), (Method) null, (Method) null); } pd.setDisplayName(findLocalized(prop + "-name", true, val.getScope())); pd.setShortDescription(findLocalized(prop + "-desc", true, val.getScope())); pd.setExpert("true".equals(findLocalized(prop + "-expert", false, val.getScope()))); try { pd.setReadMethod(getClass().getMethod("get" + StringUtils.capitalize(prop), (Class[]) null)); pd.setWriteMethod(getClass().getMethod("set" + StringUtils.capitalize(prop), new Class[] { pd.getReadMethod().getReturnType() })); } catch (Throwable t) { // if an error occurs, it might be because the value is a // dynamic property. } String type = findLocalized(prop + "-type", true, val.getScope()); if (type != null) pd.setValue(ATTRIBUTE_TYPE, type); String cat = findLocalized(prop + "-cat", false, val.getScope()); if (cat != null) pd.setValue(ATTRIBUTE_CATEGORY, cat); pd.setValue(ATTRIBUTE_XML, toXMLName(prop)); String order = findLocalized(prop + "-displayorder", false, val.getScope()); if (order != null) pd.setValue(ATTRIBUTE_ORDER, order); // collect allowed values from alias keys, listed values, and // interface implementors Collection<String> allowed = new TreeSet<String>(); List<String> aliases = Collections.emptyList(); if (val.getAliases() != null) { aliases = Arrays.asList(val.getAliases()); for (int i = 0; i < aliases.size(); i += 2) allowed.add(aliases.get(i)); } String[] vals = Strings.split(findLocalized(prop + "-values", false, val.getScope()), ",", 0); for (int i = 0; i < vals.length; i++) if (!aliases.contains(vals[i])) allowed.add(vals[i]); try { Class<?> intf = Class.forName(findLocalized(prop + "-interface", true, val.getScope()), false, getClass().getClassLoader()); pd.setValue(ATTRIBUTE_INTERFACE, intf.getName()); String[] impls = Services.getImplementors(intf); for (int i = 0; i < impls.length; i++) if (!aliases.contains(impls[i])) allowed.add(impls[i]); } catch (Throwable t) { } if (!allowed.isEmpty()) pd.setValue(ATTRIBUTE_ALLOWED_VALUES, (String[]) allowed.toArray(new String[allowed.size()])); return pd; }