Java Code Examples for java.beans.BeanDescriptor#getShortDescription()
The following examples show how to use
java.beans.BeanDescriptor#getShortDescription() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SerialDataNode.java From netbeans with Apache License 2.0 | 6 votes |
/** Gets the short description of this feature. */ public String getShortDescription() { if (noBeanInfo) return super.getShortDescription(); try { InstanceCookie ic = ic(); if (ic == null) { // it must be unrecognized instance return getDataObject().getPrimaryFile().toString(); } Class<?> clazz = ic.instanceClass(); BeanDescriptor bd = Utilities.getBeanInfo(clazz).getBeanDescriptor(); String desc = bd.getShortDescription(); return (desc.equals(bd.getDisplayName()))? getDisplayName(): desc; } catch (Exception ex) { return super.getShortDescription(); } }
Example 2
Source File: BeanNode.java From netbeans with Apache License 2.0 | 4 votes |
/** Performs initialization of the node */ private void initialization(boolean hasLookup) throws IntrospectionException { setIconBaseWithExtension(ICON_BASE); setSynchronizeName(true); // Find the first public superclass of the actual class. // Should not introspect on a private class, because then the method objects // used for the property descriptors will not be callable without an // IllegalAccessException, even if overriding a public method from a public superclass. Class<?> clazz = bean.getClass(); while (!Modifier.isPublic(clazz.getModifiers()) && !hasExplicitBeanInfo(clazz)) { clazz = clazz.getSuperclass(); if (clazz == null) { clazz = Object.class; // in case it was an interface } } beanInfo = Utilities.getBeanInfo(clazz); // resolving the name of this bean registerName(); setNameSilently(getNameForBean()); BeanDescriptor descriptor = beanInfo.getBeanDescriptor(); String sd = descriptor.getShortDescription(); if (!Utilities.compareObjects(sd, descriptor.getDisplayName())) { setShortDescription(sd); } // add propertyChangeListener EventSetDescriptor[] eventSetDescriptors = beanInfo.getEventSetDescriptors(); int i; int k = eventSetDescriptors.length; Method method = null; for (i = 0; i < k; i++) { method = eventSetDescriptors[i].getAddListenerMethod(); if ( (method != null) && method.getName().equals("addPropertyChangeListener") && // NOI18N Modifier.isPublic(method.getModifiers()) ) { break; } } if (i != k) { try { Object o = Beans.getInstanceOf(bean, method.getDeclaringClass()); propertyChangeListener = new PropL(); method.invoke(o, new Object[] { WeakListeners.propertyChange(propertyChangeListener, o) }); removePCLMethod = eventSetDescriptors[i].getRemoveListenerMethod(); } catch (Exception e) { // Warning, not info: likely to call e.g. getters or other things used // during startup of the bean, so it is not good to swallow errors here // (e.g. SharedClassObject.initialize throws RuntimeException -> it is // caught here and probably someone wants to know). Exceptions.attachMessage(e, "Trying to invoke " + method + " where introspected class is " + clazz.getName()); // NOI18N NodeOp.warning(e); } } createProperties(bean, beanInfo); for (Enumeration e = beanInfo.getBeanDescriptor().attributeNames(); e.hasMoreElements();) { String aname = (String) e.nextElement(); setValue(aname, beanInfo.getBeanDescriptor().getValue(aname)); } if (!hasLookup) { Node.Cookie instanceCookie = TMUtil.createInstanceCookie(bean); if (instanceCookie != null) { getCookieSet().add(instanceCookie); } } }