Java 类java.beans.BeanDescriptor 实例源码

项目:incubator-netbeans    文件:HelpCtx.java   
/** 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;
}
项目:incubator-netbeans    文件:ModelProperty.java   
private static String findDisplayNameFor(Object o) {
    try {
        if (o == null) {
            return null;
        }

        if (o instanceof Node.Property) {
            return ((Node.Property) o).getDisplayName();
        }

        BeanInfo bi = Introspector.getBeanInfo(o.getClass());

        if (bi != null) {
            BeanDescriptor bd = bi.getBeanDescriptor();

            if (bd != null) {
                return bd.getDisplayName();
            }
        }
    } catch (Exception e) {
        //okay, we did our best
    }

    return null;
}
项目:incubator-netbeans    文件:BeanNode.java   
/**
* 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();
}
项目:incubator-netbeans    文件:BindingDesignSupportImpl.java   
@Override
public List<BindingDescriptor>[] getBindingDescriptors(RADComponent component) {
    BeanDescriptor beanDescriptor = component.getBeanInfo().getBeanDescriptor();
    List<BindingDescriptor>[] descs = getBindingDescriptors(null, beanDescriptor, false);
    Class<?> beanClass = component.getBeanClass();
    if (JTextComponent.class.isAssignableFrom(beanClass)) {
        // get rid of text_... descriptors
        descs[0] = filterDescriptors(descs[0], "text_"); // NOI18N
    } else if (JTable.class.isAssignableFrom(beanClass)
            || JList.class.isAssignableFrom(beanClass)
            || JComboBox.class.isAssignableFrom(beanClass)) {
        // get rid of selectedElement(s)_... descriptors
        descs[0] = filterDescriptors(descs[0], "selectedElement_"); // NOI18N
        descs[0] = filterDescriptors(descs[0], "selectedElements_"); // NOI18N
        // add elements descriptor
        BindingDescriptor desc = new BindingDescriptor("elements", List.class); // NOI18N
        descs[0].add(0, desc);
    } else if (JSlider.class.isAssignableFrom(beanClass)) {
        // get rid of value_... descriptor
        descs[0] = filterDescriptors(descs[0], "value_"); // NOI18N
    }
    return descs;
}
项目:incubator-netbeans    文件:SerialDataNode.java   
/** 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();
    }
}
项目:myfaces-trinidad    文件:JavaIntrospector.java   
BeanDescriptor __getTargetBeanDescriptor()
  throws IntrospectionException
{
  // Use explicit info, if available,
  if (_informant != null)
  {
    BeanDescriptor bd = _informant.getBeanDescriptor();

    if (bd != null)
    {
      return bd;
    }
  }

  // OK, fabricate a default BeanDescriptor.
  return (new BeanDescriptor(_beanClass));
}
项目:myfaces-trinidad    文件:JavaIntrospector.java   
@Override
public BeanDescriptor getBeanDescriptor()
{
  if (_beanDescriptor == null)
  {
    if (_introspector != null)
    {
      try
      {
        _beanDescriptor = _introspector.__getTargetBeanDescriptor();
      }
      catch (IntrospectionException e)
      {
        // do nothing
        ;
      }
    }
    else
    {
      _beanDescriptor =
                     _cloneBeanDescriptor(_oldBeanInfo.getBeanDescriptor());
    }
  }

  return _beanDescriptor;
}
项目:myfaces-trinidad    文件:JavaIntrospector.java   
private static BeanDescriptor _cloneBeanDescriptor(
  BeanDescriptor oldDescriptor
  )
{
  try
  {
    BeanDescriptor newDescriptor = new BeanDescriptor(
                                        oldDescriptor.getBeanClass(),
                                        oldDescriptor.getCustomizerClass());

    // copy the rest of the attributes
    _copyFeatureDescriptor(oldDescriptor, newDescriptor);

    return newDescriptor;
  }
  catch (Exception e)
  {
    _LOG.severe(e);
    return null;
  }
}
项目:convertigo-engine    文件:DboBeanData.java   
public String getHtmlDescription() {
    if (htmlDescription == null) {
        BeanDescriptor beanDescriptor = beanInfo.getBeanDescriptor();
        String beanDescription = beanDescriptor.getShortDescription();

        String[] beanDescriptions = beanDescription.split("\\|");

        String beanShortDescription = beanDescriptions.length >= 1 ? beanDescriptions[0] : "n/a";
        String beanLongDescription = beanDescriptions.length >= 2 ? beanDescriptions[1] : "n/a";
        beanShortDescription = BeansUtils.cleanDescription(beanShortDescription, true);
        beanLongDescription = BeansUtils.cleanDescription(beanLongDescription, true);

        htmlDescription = "<p>" +
                "<font size=\"4.5\"><u><b>" + getDisplayName() + "</b></u></font>" + "<br><br>" +
                "<i>" + beanShortDescription + "</i>" + "<br><br>" + beanLongDescription +
           "</p>";
    }

    return htmlDescription;
}
项目:convertigo-engine    文件:DatabaseObject.java   
public DatabaseObject() {
    try {
        BeanInfo bi = CachedIntrospector.getBeanInfo(getClass());
        BeanDescriptor bd = bi.getBeanDescriptor();
        setBeanName(StringUtils.normalize(bd.getDisplayName())); // normalize
                                                                    // bean
                                                                    // name
                                                                    // #283
        identity = getNewOrderValue();
        compilablePropertySourceValuesMap = new HashMap<String, Object>(5);
    } catch (Exception e) {
        name = getClass().getName();
        Engine.logBeans.error("Unable to set the default name; using the class name instead (\"" + name
                + "\").", e);
    }
}
项目:convertigo-engine    文件:MySimpleBeanInfo.java   
@Override
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor beanDescriptor = new BeanDescriptor(beanClass, null);
    beanDescriptor.setDisplayName(displayName);
    beanDescriptor.setShortDescription(shortDescription);
    if (iconNameC16 != null) {
        beanDescriptor.setValue("icon" + BeanInfo.ICON_COLOR_16x16, iconNameC16);
    }
    if (iconNameC32 != null) {
        beanDescriptor.setValue("icon" + BeanInfo.ICON_COLOR_32x32, iconNameC32);
    }
    if (iconNameM16 != null) {
        beanDescriptor.setValue("icon" + BeanInfo.ICON_MONO_16x16, iconNameM16);
    }
    if (iconNameM32 != null) {
        beanDescriptor.setValue("icon" + BeanInfo.ICON_MONO_32x32, iconNameM32);
    }
    return beanDescriptor;
}
项目:javify    文件:ExplicitBeanInfo.java   
public ExplicitBeanInfo(BeanDescriptor beanDescriptor,
                        BeanInfo[] additionalBeanInfo,
                        PropertyDescriptor[] propertyDescriptors,
                        int defaultPropertyIndex,
                        EventSetDescriptor[] eventSetDescriptors,
                        int defaultEventIndex,
                        MethodDescriptor[] methodDescriptors,
                        Image[] icons) {
        this.beanDescriptor = beanDescriptor;
        this.additionalBeanInfo = additionalBeanInfo;
        this.propertyDescriptors = propertyDescriptors;
        this.defaultPropertyIndex = defaultPropertyIndex;
        this.eventSetDescriptors = eventSetDescriptors;
        this.defaultEventIndex = defaultEventIndex;
        this.methodDescriptors = methodDescriptors;
        this.icons = icons;
}
项目:incubator-netbeans    文件:JPDABreakpointBeanInfo.java   
@Override
public BeanDescriptor getBeanDescriptor() {
    try {
        return new BeanDescriptor(
                JPDABreakpoint.class,
                Class.forName("org.netbeans.modules.debugger.jpda.ui.breakpoints.JPDABreakpointCustomizer", true, Lookup.getDefault().lookup(ClassLoader.class))); // NOI18N
    } catch (ClassNotFoundException ex) {
        Exceptions.printStackTrace(ex);
        return null;
    }
}
项目:incubator-netbeans    文件:MicrosoftEdgeBrowserBeanInfo.java   
@Override
   public BeanDescriptor getBeanDescriptor() {
       BeanDescriptor descr = new BeanDescriptor(MicrosoftEdgeBrowser.class);
       descr.setDisplayName(NbBundle.getMessage(MicrosoftEdgeBrowserBeanInfo.class, "CTL_MicrosoftEdgeBrowserName")); // NOI18N
       descr.setShortDescription(NbBundle.getMessage(MicrosoftEdgeBrowserBeanInfo.class, "HINT_MicrosoftEdgeBrowserName")); // NOI18N
       descr.setValue ("helpID", "org.netbeans.modules.extbrowser.ExtWebBrowser");  // NOI18N
return descr;
   }
项目:incubator-netbeans    文件:BeanNode.java   
/** 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);
    }
}
项目:incubator-netbeans    文件:SerialDataNode.java   
private Sheet.Set createExpertSet(BeanNode.Descriptor descr, BeanDescriptor bd) {
    Sheet.Set p = Sheet.createExpertSet();
    convertProps (p, descr.expert, this);
    if (bd != null) {
        Object helpID = bd.getValue("expertHelpID"); // NOI18N
        if (helpID != null && helpID instanceof String) {
            p.setValue("helpID", helpID); // NOI18N
        }
    }
    return p;
}
项目:incubator-netbeans    文件:SerialDataNode.java   
private Sheet.Set createPropertiesSet(BeanNode.Descriptor descr, BeanDescriptor bd) {
    Sheet.Set props;
    props = Sheet.createPropertiesSet();
    if (descr.property != null) {
        convertProps (props, descr.property, this);
    }
    if (bd != null) {
        // #29550: help from the beaninfo on property tabs
        Object helpID = bd.getValue("propertiesHelpID"); // NOI18N
        if (helpID != null && helpID instanceof String) {
            props.setValue("helpID", helpID); // NOI18N
        }
    }
    return props;
}
项目:incubator-netbeans    文件:BreakpointCustomizeAction.java   
private Class getCustomizerClass(Breakpoint b) {
    BeanInfo bi = findBeanInfo(b.getClass());
    if (bi == null) {
        try {
            bi = Introspector.getBeanInfo(b.getClass());
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
            return null;
        }
    }
    BeanDescriptor bd = bi.getBeanDescriptor();
    if (bd == null) return null;
    Class cc = bd.getCustomizerClass();
    return cc;
}
项目:incubator-netbeans    文件:JSLineBreakpointBeanInfo.java   
@Override
public BeanDescriptor getBeanDescriptor() {
    Class customizer = null;
    try {
        customizer = Class.forName("org.netbeans.modules.javascript2.debug.ui.breakpoints.JSLineBreakpointCustomizer",
                                   true, Lookup.getDefault().lookup(ClassLoader.class));
    } catch (ClassNotFoundException cnfex) {
        LOG.log(Level.WARNING, "No BP customizer", cnfex);
    }
    return new BeanDescriptor(
            JSLineBreakpoint.class,
            customizer);
}
项目:convertigo-eclipse    文件:ObjectsExplorerComposite.java   
private void updateHelpText(BeanInfo bi) {
    BeanDescriptor beanDescriptor = bi.getBeanDescriptor();
    boolean isDocumented = documentedDboList.contains(beanDescriptor.getBeanClass().getName());
    String beanDescription = isDocumented ? beanDescriptor.getShortDescription():"Not yet documented. |";
    String[] beanDescriptions = beanDescription.split("\\|");
    String beanDisplayName = beanDescriptor.getDisplayName();
    String beanShortDescription = beanDescriptions.length >= 1 ? beanDescriptions[0] : "n/a";
    String beanLongDescription = beanDescriptions.length >= 2 ? beanDescriptions[1] : "n/a";

    beanShortDescription = BeansUtils.cleanDescription(beanShortDescription, true);
    beanLongDescription = BeansUtils.cleanDescription(beanLongDescription, true);

    helpBrowser.setText("<html>" +
                            "<head>" +
                            "<script type=\"text/javascript\">"+
                                "document.oncontextmenu = new Function(\"return false\");"+
                            "</script>"+
                                    "<style type=\"text/css\">"+
                                          "body {"+
                                            "font-family: Courrier new, sans-serif;"+
                                            "font-size: 14px;"+
                                            "padding-left: 0.3em;"+
                                            "background-color: #ECEBEB }"+
                                    "</style>"+
                            "</head><p>" 
                        + "<font size=\"4.5\"><u><b>"+beanDisplayName+"</b></u></font>" + "<br><br>" 
                        + "<i>"+beanShortDescription+"</i>" + "<br><br>" 
                        + beanLongDescription + "</p></html>");
}
项目:jdk8u-jdk    文件:BeanUtils.java   
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
项目:openjdk-jdk10    文件:TestBeanInfoPriority.java   
@Override
public BeanDescriptor getBeanDescriptor() {

    BeanDescriptor bd = new BeanDescriptor(TestClass.class, null);
    bd.setShortDescription("user-defined-description");
    bd.setValue("isContainer", true);
    bd.setValue("containerDelegate", "user-defined-delegate");

    return bd;
}
项目:openjdk-jdk10    文件:TestSwingContainer.java   
private static void test(Class<?> type, Object iC, Object cD) throws Exception {
    System.out.println(type);
    BeanInfo info = Introspector.getBeanInfo(type);
    BeanDescriptor bd = info.getBeanDescriptor();
    test(bd, "isContainer", iC);
    test(bd, "containerDelegate", cD);
}
项目:openjdk-jdk10    文件:TestSwingContainer.java   
private static void test(BeanDescriptor bd, String name, Object expected) {
    Object value = bd.getValue(name);
    System.out.println("\t" + name + " = " + value);
    if (!Objects.equals(value, expected)) {
        throw new Error(name + ": expected = " + expected + "; actual = " + value);
    }
}
项目:openjdk-jdk10    文件:TestJavaBean.java   
private static void test(Class<?> type, String name, String descr,
                         String prop, String event) throws Exception {
    BeanInfo info = Introspector.getBeanInfo(type);
    BeanDescriptor bd = info.getBeanDescriptor();

    if (!bd.getName().equals(name)) {
        throw new Error("unexpected name of the bean");
    }

    if (!bd.getShortDescription().equals(descr)) {
        throw new Error("unexpected description of the bean");
    }

    int dp = info.getDefaultPropertyIndex();
    if (dp < 0 && prop != null) {
        throw new Error("unexpected index of the default property");
    }
    if (dp >= 0) {
        if (!info.getPropertyDescriptors()[dp].getName().equals(prop)) {
            throw new Error("unexpected default property");
        }
    }
    int des = info.getDefaultEventIndex();
    if (des < 0 && event != null) {
        throw new Error("unexpected index of the default event set");
    }
    if (des >= 0) {
        if (!info.getEventSetDescriptors()[des].getName().equals(event)) {
            throw new Error("unexpected default event set");
        }
    }
}
项目:openjdk-jdk10    文件:BeanUtils.java   
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
项目:openjdk9    文件:TestBeanInfoPriority.java   
@Override
public BeanDescriptor getBeanDescriptor() {

    BeanDescriptor bd = new BeanDescriptor(TestClass.class, null);
    bd.setShortDescription("user-defined-description");
    bd.setValue("isContainer", true);
    bd.setValue("containerDelegate", "user-defined-delegate");

    return bd;
}
项目:openjdk9    文件:TestSwingContainer.java   
private static void test(Class<?> type, Object iC, Object cD) throws Exception {
    System.out.println(type);
    BeanInfo info = Introspector.getBeanInfo(type);
    BeanDescriptor bd = info.getBeanDescriptor();
    test(bd, "isContainer", iC);
    test(bd, "containerDelegate", cD);
}
项目:openjdk9    文件:TestSwingContainer.java   
private static void test(BeanDescriptor bd, String name, Object expected) {
    Object value = bd.getValue(name);
    System.out.println("\t" + name + " = " + value);
    if (!Objects.equals(value, expected)) {
        throw new Error(name + ": expected = " + expected + "; actual = " + value);
    }
}
项目:openjdk9    文件:TestJavaBean.java   
private static void test(Class<?> type, String name, String descr,
                         String prop, String event) throws Exception {
    BeanInfo info = Introspector.getBeanInfo(type);
    BeanDescriptor bd = info.getBeanDescriptor();

    if (!bd.getName().equals(name)) {
        throw new Error("unexpected name of the bean");
    }

    if (!bd.getShortDescription().equals(descr)) {
        throw new Error("unexpected description of the bean");
    }

    int dp = info.getDefaultPropertyIndex();
    if (dp < 0 && prop != null) {
        throw new Error("unexpected index of the default property");
    }
    if (dp >= 0) {
        if (!info.getPropertyDescriptors()[dp].getName().equals(prop)) {
            throw new Error("unexpected default property");
        }
    }
    int des = info.getDefaultEventIndex();
    if (des < 0 && event != null) {
        throw new Error("unexpected index of the default event set");
    }
    if (des >= 0) {
        if (!info.getEventSetDescriptors()[des].getName().equals(event)) {
            throw new Error("unexpected default event set");
        }
    }
}
项目:openjdk9    文件:BeanUtils.java   
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
项目:jdk8u_jdk    文件:BeanUtils.java   
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:BeanUtils.java   
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
项目:repo.kmeanspp.silhouette_score    文件:WekaClassifierEvaluationHadoopJobBeanInfo.java   
/**
 * Get the bean descriptor for this bean
 * 
 * @return a <code>BeanDescriptor</code> value
 */
@Override
public BeanDescriptor getBeanDescriptor() {
  return new BeanDescriptor(
    weka.gui.beans.WekaClassifierEvaluationHadoopJob.class,
    HadoopJobCustomizer.class);
}
项目:repo.kmeanspp.silhouette_score    文件:ClassifierPerformanceEvaluatorBeanInfo.java   
/**
 * Get the bean descriptor for this bean
 * 
 * @return a <code>BeanDescriptor</code> value
 */
@Override
public BeanDescriptor getBeanDescriptor() {
  return new BeanDescriptor(
      weka.gui.beans.ClassifierPerformanceEvaluator.class,
      ClassifierPerformanceEvaluatorCustomizer.class);
}
项目:repo.kmeanspp.silhouette_score    文件:AddUserFieldsBeanInfo.java   
/**
 * Get the bean descriptor for this bean
 * 
 * @return a <code>BeanDescriptor</code> value
 */
@Override
public BeanDescriptor getBeanDescriptor() {
  return new BeanDescriptor(
      weka.filters.unsupervised.attribute.AddUserFields.class,
      weka.gui.filters.AddUserFieldsCustomizer.class);
}
项目:incubator-netbeans    文件:DerbyOptionsBeanInfo.java   
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor descriptor = new BeanDescriptor(DerbyOptions.class);
    descriptor.setName(NbBundle.getMessage(DerbyOptionsBeanInfo.class, "LBL_DerbyOptions"));
    return descriptor;
}
项目:incubator-netbeans    文件:OverlayLayoutBeanInfo.java   
@Override
public BeanDescriptor getBeanDescriptor() {
    return new BeanDescriptor(javax.swing.OverlayLayout.class);
}
项目:incubator-netbeans    文件:ComponentBreakpointBeanInfo.java   
@Override
public BeanDescriptor getBeanDescriptor() {
    return new BeanDescriptor(
            ComponentBreakpoint.class,
            ComponentBreakpointCustomizer.class);
}
项目:lams    文件:ExtendedBeanInfo.java   
@Override
public BeanDescriptor getBeanDescriptor() {
    return this.delegate.getBeanDescriptor();
}