/** 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;
}
java类java.beans.BeanDescriptor的实例源码
HelpCtx.java 文件源码
项目:incubator-netbeans
阅读 21
收藏 0
点赞 0
评论 0
ModelProperty.java 文件源码
项目:incubator-netbeans
阅读 59
收藏 0
点赞 0
评论 0
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;
}
BeanNode.java 文件源码
项目:incubator-netbeans
阅读 20
收藏 0
点赞 0
评论 0
/**
* 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();
}
BindingDesignSupportImpl.java 文件源码
项目:incubator-netbeans
阅读 19
收藏 0
点赞 0
评论 0
@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;
}
SerialDataNode.java 文件源码
项目:incubator-netbeans
阅读 22
收藏 0
点赞 0
评论 0
/** 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();
}
}
JavaIntrospector.java 文件源码
项目:myfaces-trinidad
阅读 21
收藏 0
点赞 0
评论 0
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));
}
JavaIntrospector.java 文件源码
项目:myfaces-trinidad
阅读 22
收藏 0
点赞 0
评论 0
@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;
}
JavaIntrospector.java 文件源码
项目:myfaces-trinidad
阅读 28
收藏 0
点赞 0
评论 0
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;
}
}
DboBeanData.java 文件源码
项目:convertigo-engine
阅读 25
收藏 0
点赞 0
评论 0
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;
}
DatabaseObject.java 文件源码
项目:convertigo-engine
阅读 20
收藏 0
点赞 0
评论 0
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);
}
}
MySimpleBeanInfo.java 文件源码
项目:convertigo-engine
阅读 17
收藏 0
点赞 0
评论 0
@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;
}
ExplicitBeanInfo.java 文件源码
项目:javify
阅读 25
收藏 0
点赞 0
评论 0
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;
}
JPDABreakpointBeanInfo.java 文件源码
项目:incubator-netbeans
阅读 18
收藏 0
点赞 0
评论 0
@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;
}
}
MicrosoftEdgeBrowserBeanInfo.java 文件源码
项目:incubator-netbeans
阅读 15
收藏 0
点赞 0
评论 0
@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;
}
BeanNode.java 文件源码
项目:incubator-netbeans
阅读 24
收藏 0
点赞 0
评论 0
/** 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);
}
}
SerialDataNode.java 文件源码
项目:incubator-netbeans
阅读 24
收藏 0
点赞 0
评论 0
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;
}
SerialDataNode.java 文件源码
项目:incubator-netbeans
阅读 28
收藏 0
点赞 0
评论 0
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;
}
BreakpointCustomizeAction.java 文件源码
项目:incubator-netbeans
阅读 22
收藏 0
点赞 0
评论 0
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;
}
JSLineBreakpointBeanInfo.java 文件源码
项目:incubator-netbeans
阅读 16
收藏 0
点赞 0
评论 0
@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);
}
ObjectsExplorerComposite.java 文件源码
项目:convertigo-eclipse
阅读 21
收藏 0
点赞 0
评论 0
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>");
}
BeanUtils.java 文件源码
项目:jdk8u-jdk
阅读 28
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
TestBeanInfoPriority.java 文件源码
项目:openjdk-jdk10
阅读 21
收藏 0
点赞 0
评论 0
@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;
}
TestSwingContainer.java 文件源码
项目:openjdk-jdk10
阅读 20
收藏 0
点赞 0
评论 0
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);
}
TestSwingContainer.java 文件源码
项目:openjdk-jdk10
阅读 40
收藏 0
点赞 0
评论 0
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);
}
}
TestJavaBean.java 文件源码
项目:openjdk-jdk10
阅读 25
收藏 0
点赞 0
评论 0
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");
}
}
}
BeanUtils.java 文件源码
项目:openjdk-jdk10
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
TestBeanInfoPriority.java 文件源码
项目:openjdk9
阅读 23
收藏 0
点赞 0
评论 0
@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;
}
TestSwingContainer.java 文件源码
项目:openjdk9
阅读 20
收藏 0
点赞 0
评论 0
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);
}
TestSwingContainer.java 文件源码
项目:openjdk9
阅读 17
收藏 0
点赞 0
评论 0
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);
}
}
TestJavaBean.java 文件源码
项目:openjdk9
阅读 20
收藏 0
点赞 0
评论 0
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");
}
}
}