Refine search
@Override public BeanDescriptor getBeanDescriptor() { BeanDescriptor descriptor = new BeanDescriptor(getBeanClass()); try { // Attempt to load the displayName and shortDescription explicitly. String displayName = bundle.getString("displayName"); if (displayName != null) { descriptor.setDisplayName(displayName); } String shortDescription = bundle.getString("shortDescription"); if (shortDescription != null) { descriptor.setShortDescription(shortDescription); } // Add any other properties that are specified. Enumeration enumeration = bundle.getKeys(); while (enumeration.hasMoreElements()) { String key = (String)enumeration.nextElement(); String value = bundle.getString(key); if (value != null) { descriptor.setValue(key, value); } } } catch (Exception e) { // Ignore any exceptions. We may get some if we try to load a // a property that doesn't appear in the resource bundle. } return descriptor; }
/** Finds help context for a generic object. Right now checks * for HelpCtx.Provider and handles java.awt.Component in a * special way compatible with JavaHelp. * Also {@link BeanDescriptor}'s are checked for a string-valued attribute * <code>helpID</code>, as per the JavaHelp specification (but no help sets * will be loaded). * * @param instance to search help for * @return the help for the object or <code>HelpCtx.DEFAULT_HELP</code> if HelpCtx cannot be found * * @since 4.3 */ public static HelpCtx findHelp(Object instance) { if (instance instanceof java.awt.Component) { return findHelp((java.awt.Component) instance); } if (instance instanceof HelpCtx.Provider) { return ((HelpCtx.Provider) instance).getHelpCtx(); } try { BeanDescriptor d = Introspector.getBeanInfo(instance.getClass()).getBeanDescriptor(); String v = (String) d.getValue("helpID"); // NOI18N if (v != null) { return new HelpCtx(v); } } catch (IntrospectionException e) { err.log(Level.FINE, "findHelp on {0}: {1}", new Object[]{instance, e}); } return HelpCtx.DEFAULT_HELP; }
Class<?> getBeanClass() { return this.beanInfo.getBeanDescriptor().getBeanClass(); }
public CompositeDataBeanAdapter(Class<?> beanClass, String defaultPropertyValue) throws IntrospectionException, OpenDataException { this.beanClass = beanClass; this.defaultPropertyValue = defaultPropertyValue; BeanInfo beanInfo = Introspector.getBeanInfo(beanClass); BeanDescriptor beanDescriptor = beanInfo.getBeanDescriptor(); CompositeTypeFactory typeFactory = new CompositeTypeFactory(beanDescriptor.getName(), beanDescriptor.getDisplayName()); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor pd : propertyDescriptors) { if (isExposed(pd)) { typeFactory.defineItem(pd.getDisplayName(), SimpleType.STRING); } } compositeType = typeFactory.createCompositeType(); }
public TabBeanInfo() { super(); PropertyDescriptor[] descriptors = this.getPropertyDescriptors(); for (int i = 0; i < descriptors.length; i++) { if (descriptors[i].getName().equals("action")) //NOI18N descriptors[i].setHidden(true); } BeanDescriptor beanDescriptor = super.getBeanDescriptor(); beanDescriptor.setValue( Constants.BeanDescriptor.INLINE_EDITABLE_PROPERTIES, new String[] { "*text://span" }); // NOI18N }
/** Default human-presentable name of the service type. * In the default implementation, taken from the bean descriptor. * @return initial value of the human-presentable name * @see java.beans.FeatureDescriptor#getDisplayName */ protected String displayName() { try { return Introspector.getBeanInfo(getClass()).getBeanDescriptor().getDisplayName(); } catch (Exception e) { // Catching IntrospectionException, but also maybe NullPointerException...? Logger.getLogger(ServiceType.class.getName()).log(Level.WARNING, null, e); return getClass().getName(); } }
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(descriptor.getBeanClass()); if (propertyDescriptors != null && propertyDescriptors.size() > 0) { out.writeObject(propertyDescriptors.size()); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { out.writeObject(propertyDescriptor.getName()); out.writeObject(propertyDescriptor.getValue("type")); } } else { out.writeObject(0); } }
/** Sets/add the persistence delegates to be used for a class. * @param c The class to set the registered delegate for. * @param del The new delegate or <code>null</code> to erase to old one. */ static synchronized void setDelegate(Class<?> c, PersistenceDelegate del) { try { Introspector.getBeanInfo(c, Introspector.IGNORE_ALL_BEANINFO).getBeanDescriptor().setValue("persistenceDelegate", del); } catch (Exception ignored) { } }
public TestBeanGUI(Class<?> testBeanClass) { super(); log.debug("testing class: {}", testBeanClass); // A quick verification, just in case: if (!TestBean.class.isAssignableFrom(testBeanClass)) { Error e = new Error(); log.error("This should never happen!", e); throw e; // Programming error: bail out. } this.testBeanClass = testBeanClass; // Get the beanInfo: try { beanInfo = Introspector.getBeanInfo(testBeanClass); } catch (IntrospectionException e) { log.error("Can't get beanInfo for {}", testBeanClass, e); throw new Error(e); // Programming error. Don't continue. } customizerClass = beanInfo.getBeanDescriptor().getCustomizerClass(); // Creation of customizer and GUI initialization // is delayed until the first configure call. // It's not needed to find the static label, menu categories, etc. initialized = false; JMeterUtils.addLocaleChangeListener(this); }
public PropertyDescriptor[] getPropertyDescriptors() { try { PropertyDescriptor instruction = new PropertyDescriptor("instruction", getBeanDescriptor().getBeanClass()); instruction.setBound(true); instruction.setPropertyEditorClass(JTextFieldEditor.class); instruction.setDisplayName("<html><font color='green'>Question:"); instruction.setShortDescription("Question to present to the user in the workflow panel. "); PropertyDescriptor rv[] = { instruction }; return rv; } catch (IntrospectionException e) { throw new Error(e.toString()); } }
if (UIComponent.isCompositeComponent(parent)) { boolean tagApplied = false; if (parent instanceof ClientBehaviorHolder) { BeanInfo componentBeanInfo = (BeanInfo) parent.getAttributes().get(UIComponent.BEANINFO_KEY); if (null == componentBeanInfo) { throw new TagException(tag, "Composite component does not have BeanInfo attribute"); BeanDescriptor componentDescriptor = componentBeanInfo.getBeanDescriptor(); if (null == componentDescriptor) { throw new TagException(tag, "Composite component BeanInfo does not have BeanDescriptor"); List<AttachedObjectTarget> targetList = (List<AttachedObjectTarget>) componentDescriptor.getValue(AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY); if (null == targetList && !tagApplied) { throw new TagException(tag, "Composite component does not support behavior events");
(null == (parent = parent.getParent())) || !(ComponentHandler.isNew(parent))) { return; parent.getAttributes().get(UIComponent.BEANINFO_KEY); if (null == componentBeanInfo) { throw new TagException(this.tag, "Error: I have an EditableValueHolder tag, but no enclosing composite component"); BeanDescriptor componentDescriptor = componentBeanInfo.getBeanDescriptor(); if (null == componentDescriptor) { throw new TagException(this.tag, "Error: I have an EditableValueHolder tag, but no enclosing composite component"); componentDescriptor.getValue(AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY); AttachedObjectTargetImpl target = newAttachedObjectTargetImpl(); targetList.add(target);
BeanInfo info = (BeanInfo) composite.getAttributes().get(UIComponent.BEANINFO_KEY); List<AttachedObjectTarget> targets = (List<AttachedObjectTarget>) info.getBeanDescriptor() .getValue(AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY); throw new FacesException( "Cannot not resolve editableValueHolder target in composite component with id: \"" + composite.getClientId() + "\""); throw new FacesException( "Only a single editableValueHolder target is supported in composite component with id: \"" + composite.getClientId() + "\"");
/** Prepare node properties based on the bean, storing them into the current property sheet. * Called when the bean info is ready. * This implementation always creates a set for standard properties * and may create a set for expert ones if there are any. * @see #computeProperties * @param bean bean to compute properties for * @param info information about the bean */ protected void createProperties(T bean, BeanInfo info) { Descriptor d = computeProperties(bean, info); Sheet sets = getSheet(); Sheet.Set pset = Sheet.createPropertiesSet(); pset.put(d.property); BeanDescriptor bd = info.getBeanDescriptor(); if ((bd != null) && (bd.getValue("propertiesHelpID") != null)) { // NOI18N pset.setValue("helpID", bd.getValue("propertiesHelpID")); // NOI18N } sets.put(pset); if (d.expert.length != 0) { Sheet.Set eset = Sheet.createExpertSet(); eset.put(d.expert); if ((bd != null) && (bd.getValue("expertHelpID") != null)) { // NOI18N eset.setValue("helpID", bd.getValue("expertHelpID")); // NOI18N } sets.put(eset); } }
/** * Returns name of the bean. */ private String getNameForBean() { if (nameGetter != null) { try { String name = (String) nameGetter.invoke(bean); return (name != null) ? name : ""; // NOI18N } catch (Exception ex) { NodeOp.warning(ex); } } BeanDescriptor descriptor = beanInfo.getBeanDescriptor(); return descriptor.getDisplayName(); }
setNameSilently(getNameForBean()); BeanDescriptor descriptor = beanInfo.getBeanDescriptor(); String sd = descriptor.getShortDescription(); if (!Utilities.compareObjects(sd, descriptor.getDisplayName())) { setShortDescription(sd); EventSetDescriptor[] eventSetDescriptors = beanInfo.getEventSetDescriptors(); int i; int k = eventSetDescriptors.length; for (Enumeration e = beanInfo.getBeanDescriptor().attributeNames(); e.hasMoreElements();) { String aname = (String) e.nextElement(); setValue(aname, beanInfo.getBeanDescriptor().getValue(aname));
@Override public BeanDescriptor getBeanDescriptor() { BeanDescriptor descriptor = new BeanDescriptor( SwingMetawidget.class ); descriptor.setDisplayName( "Metawidget" ); descriptor.setShortDescription( "org.metawidget.swing.SwingMetawidget - http://metawidget.org" ); return descriptor; }
public void apply(FaceletContext ctx, UIComponent parent) throws IOException { UIComponent parentCompositeComponent = FaceletCompositionContext.getCurrentInstance(ctx).getCompositeComponentFromStack(); AbstractFaceletContext actx = (AbstractFaceletContext) ctx; if (actx.isBuildingCompositeComponentMetadata()) { CompositeComponentBeanInfo beanInfo = (CompositeComponentBeanInfo) parentCompositeComponent.getAttributes() .get(UIComponent.BEANINFO_KEY); if (beanInfo == null) { if (log.isLoggable(Level.SEVERE)) { log.severe("Cannot find composite bean descriptor UIComponent.BEANINFO_KEY "); } return; } beanInfo.getBeanDescriptor().setValue(INSERT_CHILDREN_USED, Boolean.TRUE); } else { actx.includeCompositeComponentDefinition(parent, null); //parentCompositeComponent.getAttributes().put(INSERT_CHILDREN_USED, Boolean.TRUE); } }
@Override public boolean hasCustomizer() { // true if we have already computed beanInfo and it has customizer class return beanInfo.getBeanDescriptor().getCustomizerClass() != null; }
private void checkFacetRequired(FaceletContext ctx, String name) { AbstractFaceletContext actx = (AbstractFaceletContext) ctx; FaceletCompositionContext fcc = actx.getFaceletCompositionContext(); UIComponent innerCompositeComponent = fcc.getCompositeComponentFromStack(); CompositeComponentBeanInfo beanInfo = (CompositeComponentBeanInfo) innerCompositeComponent.getAttributes() .get(UIComponent.BEANINFO_KEY); BeanDescriptor beanDescriptor = beanInfo.getBeanDescriptor(); Map<String, PropertyDescriptor> insertFacetPropertyDescriptorMap = (Map<String, PropertyDescriptor>) beanDescriptor.getValue(InsertFacetHandler.INSERT_FACET_KEYS); if (insertFacetPropertyDescriptorMap != null && insertFacetPropertyDescriptorMap.containsKey(name)) { ValueExpression requiredExpr = (ValueExpression) insertFacetPropertyDescriptorMap.get(name).getValue("required"); if (requiredExpr != null && Boolean.TRUE.equals(requiredExpr.getValue(ctx.getFacesContext().getELContext()))) { //Insert facet associated is required, but it was not applied. throw new TagException(this.tag, "Cannot find facet with name '"+name+"' in composite component"); } } }