/** 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; }
.getValue(AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY);
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");
/** 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; }
/** 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); } }
setValue(aname, beanInfo.getBeanDescriptor().getValue(aname));
/** * Get the cleanup method name for this bean if it has one * @return the cleanup method name */ public String getCleanupMethod() { Object cleanupO = beanInfo.getBeanDescriptor().getValue(Constants.BeanDescriptor.CLEANUP_METHOD); if (cleanupO instanceof String) return (String)cleanupO; return null; }
/** * @return true iff a bean defined by beanInfo is capable of having children. */ private static boolean isParentCapableBean(BeanInfo beanInfo) { // XXX #139640 BeanDescriptor can be null (according to javadoc). BeanDescriptor beanDescriptor = beanInfo.getBeanDescriptor(); if (beanDescriptor == null) { return false; } Object ico = beanDescriptor.getValue("isContainer"); return !(ico instanceof Boolean) || ((Boolean)ico).booleanValue(); }
/** * Obtain a group's display name */ private String groupDisplayName(String group) { ResourceBundle b = (ResourceBundle) beanInfo.getBeanDescriptor().getValue(RESOURCE_BUNDLE); if (b == null) { return group; } String key = group + ".displayName"; if (b.containsKey(key)) { return b.getString(key); } else { return group; } }
/** * Get a given BeanDescriptor value by name from a BeanInfo * * @param bi * @param name * @return */ public static final String getBeanDescriptorValue(BeanInfo bi, String name) { BeanDescriptor bd = bi.getBeanDescriptor(); if (bd != null) { Object value = bd.getValue(name); if (value instanceof String) return (String)value; } return null; }
/** * Obtain a group's order. * * @param group * group name * @return the group's order (zero by default) */ private Integer groupOrder(String group) { Integer order = (Integer) beanInfo.getBeanDescriptor().getValue(ORDER(group)); if (order == null) { order = Integer.valueOf(0); } return order; }
static Object getConfig(Component component, String name) { BeanInfo info = (BeanInfo) component.getAttributes().get(UIComponent.BEANINFO_KEY); if (info != null) { TagValueExpression ve = (TagValueExpression) info.getBeanDescriptor().getValue(name); if (ve != null) { return ve.getValue(FacesContext.getCurrentInstance().getELContext()); } } return null; }
static Object getConfig(Component component, String name) { BeanInfo info = (BeanInfo) component.getAttributes().get(UIComponent.BEANINFO_KEY); if (info != null) { TagValueExpression ve = (TagValueExpression) info.getBeanDescriptor().getValue(name); if (ve != null) { return ve.getValue(FacesContext.getCurrentInstance().getELContext()); } } return null; }
public void applyMetadata(FaceletContext ctx, Object instance) { ValueExpression ve = attr.getValueExpression(ctx, type); UIComponent cc = (UIComponent) instance; assert (UIComponent.isCompositeComponent(cc)); Map<String, Object> attrs = cc.getAttributes(); BeanInfo componentMetadata = (BeanInfo) attrs.get(UIComponent.BEANINFO_KEY); BeanDescriptor desc = componentMetadata.getBeanDescriptor(); Collection<String> attributesWithDeclaredDefaultValues = (Collection<String>) desc.getValue(UIComponent.ATTRS_WITH_DECLARED_DEFAULT_VALUES); if (null != attributesWithDeclaredDefaultValues && attributesWithDeclaredDefaultValues.contains(name) && attrs.containsKey(name)) { // It is necessary to remove the value from the attribute // map because the ELexpression transparancy doesn't know // about the value's existence. attrs.remove(name); } cc.setValueExpression(name, ve); }
@Override public void applyMetadata(FaceletContext ctx, Object instance) { ValueExpression ve = attr.getValueExpression(ctx, type); UIComponent cc = (UIComponent) instance; assert (UIComponent.isCompositeComponent(cc)); Map<String, Object> attrs = cc.getAttributes(); BeanInfo componentMetadata = (BeanInfo) attrs.get(UIComponent.BEANINFO_KEY); BeanDescriptor desc = componentMetadata.getBeanDescriptor(); Collection<String> attributesWithDeclaredDefaultValues = (Collection<String>) desc.getValue(UIComponent.ATTRS_WITH_DECLARED_DEFAULT_VALUES); if (null != attributesWithDeclaredDefaultValues && attributesWithDeclaredDefaultValues.contains(name) && attrs.containsKey(name)) { // It is necessary to remove the value from the attribute // map because the ELexpression transparancy doesn't know // about the value's existence. attrs.remove(name); } cc.setValueExpression(name, ve); }
@Override public void applyMetadata(FaceletContext ctx, Object instance) { ValueExpression ve = attr.getValueExpression(ctx, type); UIComponent cc = (UIComponent) instance; assert (UIComponent.isCompositeComponent(cc)); Map<String, Object> attrs = cc.getAttributes(); BeanInfo componentMetadata = (BeanInfo) attrs.get(UIComponent.BEANINFO_KEY); BeanDescriptor desc = componentMetadata.getBeanDescriptor(); Collection<String> attributesWithDeclaredDefaultValues = (Collection<String>) desc.getValue(UIComponent.ATTRS_WITH_DECLARED_DEFAULT_VALUES); if (null != attributesWithDeclaredDefaultValues && attributesWithDeclaredDefaultValues.contains(name) && attrs.containsKey(name)) { // It is necessary to remove the value from the attribute // map because the ELexpression transparancy doesn't know // about the value's existence. attrs.remove(name); } cc.setValueExpression(name, ve); }
/** Constructor for the JDirectoryChooserBeanInfo object */ public JDirectoryChooserBeanInfo() throws java.beans.IntrospectionException { // setup bean descriptor in constructor. bd.setName("JDirectoryChooser"); bd.setShortDescription("JDirectoryChooser allows " + "to select one or more directories."); BeanInfo info = Introspector.getBeanInfo(getBeanDescriptor().getBeanClass() .getSuperclass()); String order = info.getBeanDescriptor().getValue("propertyorder") == null?"" :(String)info.getBeanDescriptor().getValue("propertyorder"); PropertyDescriptor[] pd = getPropertyDescriptors(); for (int i = 0; i != pd.length; i++) { if (order.indexOf(pd[i].getName()) == -1) { order = order + (order.length() == 0?"":":") + pd[i].getName(); } } getBeanDescriptor().setValue("propertyorder", order); }
/** Constructor for the JCollapsiblePaneBeanInfo object */ public JCollapsiblePaneBeanInfo() throws java.beans.IntrospectionException { // setup bean descriptor in constructor. bd.setName("JCollapsiblePane"); bd.setShortDescription("A pane which hides its content with an animation."); bd.setValue("isContainer", Boolean.TRUE); bd.setValue("containerDelegate", "getContentPane"); BeanInfo info = Introspector.getBeanInfo(getBeanDescriptor().getBeanClass() .getSuperclass()); String order = info.getBeanDescriptor().getValue("propertyorder") == null?"" :(String)info.getBeanDescriptor().getValue("propertyorder"); PropertyDescriptor[] pd = getPropertyDescriptors(); for (int i = 0; i != pd.length; i++) { if (order.indexOf(pd[i].getName()) == -1) { order = order + (order.length() == 0?"":":") + pd[i].getName(); } } getBeanDescriptor().setValue("propertyorder", order); }
private void initHelpCtx() { helpKey = (String)liveBean.getBeanInfo().getBeanDescriptor().getValue(Constants.BeanDescriptor.HELP_KEY); propertiesHelpKey = (String)liveBean.getBeanInfo().getBeanDescriptor().getValue(Constants.BeanDescriptor.PROPERTIES_HELP_KEY); // #6472652 Fallback for the markup beans. if (liveBean instanceof MarkupDesignBean || Util.isPageRootContainerDesignBean(liveBean)) { // XXX This is not wanted for the fix. // if (helpKey == null) { // helpKey = "projrave_ui_elements_page"; // NOI18N // } if (propertiesHelpKey == null) { propertiesHelpKey = "projrave_ui_elements_propsheets_page_props"; // NOI18N } } if (propertiesHelpKey != null) { setValue("propertiesHelpID", propertiesHelpKey); // NOI18N } }
/** * Get the property descriptor for the property of the given name. * Sets the GUITYPE to the provided enum. * * @param name * property name * @param enumClass the enum class that is to be used by the editor * @return descriptor for a property of that name, or null if there's none */ protected PropertyDescriptor property(final String name, final Class<? extends Enum<?>> enumClass) { PropertyDescriptor property = property(name); if (property != null) { property.setValue(GenericTestBeanCustomizer.GUITYPE, enumClass); // we also provide the resource bundle property.setValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE, getBeanDescriptor().getValue(RESOURCE_BUNDLE)); } return property; }