当前位置: 首页>>代码示例>>Java>>正文


Java BeanInfo.getBeanDescriptor方法代码示例

本文整理汇总了Java中java.beans.BeanInfo.getBeanDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java BeanInfo.getBeanDescriptor方法的具体用法?Java BeanInfo.getBeanDescriptor怎么用?Java BeanInfo.getBeanDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.BeanInfo的用法示例。


在下文中一共展示了BeanInfo.getBeanDescriptor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findDisplayNameFor

import java.beans.BeanInfo; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ModelProperty.java

示例2: DatabaseObject

import java.beans.BeanInfo; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:17,代码来源:DatabaseObject.java

示例3: createProperties

import java.beans.BeanInfo; //导入方法依赖的package包/类
/** 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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:BeanNode.java

示例4: getCustomizerClass

import java.beans.BeanInfo; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:BreakpointCustomizeAction.java

示例5: updateHelpText

import java.beans.BeanInfo; //导入方法依赖的package包/类
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>");
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:30,代码来源:ObjectsExplorerComposite.java

示例6: test

import java.beans.BeanInfo; //导入方法依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TestSwingContainer.java

示例7: test

import java.beans.BeanInfo; //导入方法依赖的package包/类
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");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:TestJavaBean.java

示例8: instantiate

import java.beans.BeanInfo; //导入方法依赖的package包/类
@Override
protected BeanInfo instantiate(Class<?> type, String prefix, String name) {
    if (DEFAULT.equals(prefix)) {
        prefix = DEFAULT_NEW;
    }
    // this optimization will only use the BeanInfo search path
    // if is has changed from the original
    // or trying to get the ComponentBeanInfo
    BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name)
            ? super.instantiate(type, prefix, name)
            : null;

    if (info != null) {
        // make sure that the returned BeanInfo matches the class
        BeanDescriptor bd = info.getBeanDescriptor();
        if (bd != null) {
            if (type.equals(bd.getBeanClass())) {
                return info;
            }
        }
        else {
            PropertyDescriptor[] pds = info.getPropertyDescriptors();
            if (pds != null) {
                for (PropertyDescriptor pd : pds) {
                    Method method = pd.getReadMethod();
                    if (method == null) {
                        method = pd.getWriteMethod();
                    }
                    if (isValid(type, method)) {
                        return info;
                    }
                }
            }
            else {
                MethodDescriptor[] mds = info.getMethodDescriptors();
                if (mds != null) {
                    for (MethodDescriptor md : mds) {
                        if (isValid(type, md.getMethod())) {
                            return info;
                        }
                    }
                }
            }
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:BeanInfoFinder.java

示例9: main

import java.beans.BeanInfo; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        BeanInfo i = Introspector.getBeanInfo(TestClass.class, Object.class);
        BeanDescriptor bd = i.getBeanDescriptor();

        checkEq("description", bd.getShortDescription(), "user-defined-description");
        checkEq("default property index", i.getDefaultPropertyIndex(), 1);
        checkEq("default event index", i.getDefaultEventIndex(), 0);

        checkEq("isContainer", i.getBeanDescriptor().getValue("isContainer"), true);
        checkEq("containerDelegate",
            i.getBeanDescriptor().getValue("containerDelegate"), "user-defined-delegate");
        System.out.println("");

        PropertyDescriptor[] pds = i.getPropertyDescriptors();
        for (PropertyDescriptor pd: pds) {
            String name = pd.getName();
            switch (name) {
                case "value":
                    checkEq("\"value\" isBound",       pd.isBound(),       true);
                    checkEq("\"value\" isConstrained", pd.isConstrained(), true);
                    checkEq("\"value\" isExpert",      pd.isExpert(),      true);
                    checkEq("\"value\" isHidden",      pd.isHidden(),      true);
                    checkEq("\"value\" isPreferred",   pd.isPreferred(),   true);
                    checkEq("\"value\" required",      pd.getValue("required"),     true);
                    checkEq("\"value\" visualUpdate",  pd.getValue("visualUpdate"), true);

                    checkEq("\"value\" description",   pd.getShortDescription(), "user-defined-value");

                    checkEnumEq(pd.getName(), pd.getValue("enumerationValues"),
                        new Object[]{
                        "EAST", 3, "javax.swing.SwingConstants.EAST",
                        "WEST", 7, "javax.swing.SwingConstants.WEST"});
                    System.out.println("");
                    break;
                case "other":
                    checkEq("\"other\" isBound",       pd.isBound(),       false);
                    checkEq("\"other\" isConstrained", pd.isConstrained(), false);
                    checkEq("\"other\" isExpert",      pd.isExpert(),      false);
                    checkEq("\"other\" isHidden",      pd.isHidden(),      false);
                    checkEq("\"other\" isPreferred",   pd.isPreferred(),   false);
                    checkEq("\"other\" required",      pd.getValue("required"),     false);
                    checkEq("\"other\" visualUpdate",  pd.getValue("visualUpdate"), false);

                    checkEq("\"other\" description",   pd.getShortDescription(), "user-defined-other");

                    checkEnumEq(pd.getName(), pd.getValue("enumerationValues"),
                        new Object[]{"TOP", 1, "javax.swing.SwingConstants.TOP"});
                    System.out.println("");
                    break;
                default:
                    throw new Exception("invalid property descriptor: " + name);
            }
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:56,代码来源:TestBeanInfoPriority.java

示例10: main

import java.beans.BeanInfo; //导入方法依赖的package包/类
public static void main(String[] args)throws Exception {

         
        BeanInfo bi = Introspector.getBeanInfo( Bean21341Hidden.class );
        BeanDescriptor bd = bi.getBeanDescriptor();
        
        System.out.println("  shortDescription : " + bd.getShortDescription() );
        System.out.println("  helpID           : " + bd.getValue( "HelpID" ) );
        //junit.textui.TestRunner.run(new NbTestSuite(BeanNodeBug21285.class));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:BeanNodeBug21341.java


注:本文中的java.beans.BeanInfo.getBeanDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。