在本文中,我们将带你了解java.beans.IndexedPropertyDescriptor的实例源码在这篇文章中,我们将为您详细介绍java.beans.IndexedPropertyDescr
在本文中,我们将带你了解java.beans.IndexedPropertyDescriptor的实例源码在这篇文章中,我们将为您详细介绍java.beans.IndexedPropertyDescriptor的实例源码的方方面面,并解答java.beans.introspection常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的hudson.model.JobPropertyDescriptor的实例源码、java.beans.BeanDescriptor的实例源码、java.beans.EventSetDescriptor的实例源码、java.beans.FeatureDescriptor的实例源码。
本文目录一览:- java.beans.IndexedPropertyDescriptor的实例源码(java.beans.introspection)
- hudson.model.JobPropertyDescriptor的实例源码
- java.beans.BeanDescriptor的实例源码
- java.beans.EventSetDescriptor的实例源码
- java.beans.FeatureDescriptor的实例源码
java.beans.IndexedPropertyDescriptor的实例源码(java.beans.introspection)
public static void main(String[] args)throws Exception { BeanInfo bi = Introspector.getBeanInfo( BadBeanHidden.class ); PropertyDescriptor[] ps = bi.getPropertyDescriptors(); for ( int i = 0; i < ps.length; i++ ) { System.out.println( i + " : " + ps[i]); System.out.println(" Read : " + ps[i].getReadMethod() ); System.out.println(" Write : " + ps[i].getWriteMethod() ); System.out.println(" TYPE " + ps[i].getPropertyType() ); if ( ps[i] instanceof IndexedPropertyDescriptor ) { System.out.println(" I Read : " + ((IndexedPropertyDescriptor)ps[i]).getIndexedReadMethod() ); System.out.println(" I Write : " +((IndexedPropertyDescriptor)ps[i]).getIndexedWriteMethod() ); System.out.println(" TYPE " + ((IndexedPropertyDescriptor)ps[i]).getIndexedPropertyType() ); } } }
private static IndexedPropertyDescriptor _cloneIndexedPropertyDescriptor( IndexedPropertyDescriptor oldDescriptor ) { try { IndexedPropertyDescriptor newDescriptor = new IndexedPropertyDescriptor( oldDescriptor.getName(),oldDescriptor.getReadMethod(),oldDescriptor.getWriteMethod(),oldDescriptor.getIndexedReadMethod(),oldDescriptor.getIndexedWriteMethod()); // copy the rest of the attributes _copyPropertyDescriptor(oldDescriptor,newDescriptor); return newDescriptor; } catch (Exception e) { _LOG.severe(e); return null; } }
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName,Class<?> propertyType) { for (PropertyDescriptor pd : this.propertyDescriptors) { final Class<?> candidateType; final String candidateName = pd.getName(); if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; candidateType = ipd.getIndexedPropertyType(); if (candidateName.equals(propertyName) && (candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) { return pd; } } else { candidateType = pd.getPropertyType(); if (candidateName.equals(propertyName) && (candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) { return pd; } } } return null; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj != null && obj instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor other = (IndexedPropertyDescriptor) obj; if (!compareMethods(getIndexedReadMethod(),other.getIndexedReadMethod())) { return false; } if (!compareMethods(getIndexedWriteMethod(),other.getIndexedWriteMethod())) { return false; } if (getIndexedPropertyType() != other.getIndexedPropertyType()) { return false; } return PropertyDescriptorUtils.equals(this,obj); } return false; }
private static Property makeProperty(Object o,PropertyDescriptor propertyDescriptor) { Class propertyType = propertyDescriptor.getPropertyType(); if (propertyType != null && Vector.class.isAssignableFrom(propertyType)) { return new VectorProperty(o,propertyDescriptor); } if (propertyType != null && IAtomList.class.isAssignableFrom(propertyType)) { return new AtomListProperty(o,propertyDescriptor); } if (propertyType != null && IMoleculeList.class.isAssignableFrom(propertyType)) { return new MoleculeListProperty(o,propertyDescriptor); } if (!(propertyDescriptor instanceof IndexedPropertyDescriptor) && propertyType.isArray() && !(propertyType.getComponentType().isPrimitive() || propertyType.getComponentType().equals(String.class))) { return new ArrayProperty(o,propertyDescriptor); } return new InstanceProperty(o,propertyDescriptor); }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),ipd.getReadMethod(),ipd.getWriteMethod(),ipd.getIndexedReadMethod(),ipd.getIndexedWriteMethod()); } else { return new PropertyDescriptor( pd.getName(),pd.getReadMethod(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
private static void test(Class<?> type,boolean read,boolean write,boolean readindexed,boolean writeIndexed) { PropertyDescriptor pd = BeanUtils.findPropertyDescriptor(type,"size"); if (pd != null) { test(type,"read",read,null != pd.getReadMethod()); test(type,"write",write,null != pd.getWriteMethod()); if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; test(type,"indexed read",readindexed,null != ipd.getIndexedReadMethod()); test(type,"indexed write",writeIndexed,null != ipd.getIndexedWriteMethod()); } else if (readindexed || writeIndexed) { error(type,"indexed property does not exist"); } } else if (read || write || readindexed || writeIndexed) { error(type,"property does not exist"); } }
private static void test(Class<?> type,"property does not exist"); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean",bt); test(pd.getReadMethod()); test(pd.getWriteMethod()); // test IndexedPropertyDescriptor IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed",bt); test(ipd.getReadMethod()); test(ipd.getWriteMethod()); test(ipd.getIndexedReadMethod()); test(ipd.getIndexedWriteMethod()); // test EventSetDescriptor EventSetDescriptor esd = new EventSetDescriptor(bt,"test",lt,"process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
private static void test(Class<?> type,"property does not exist"); } }
private static void test(Class<?> type,"property does not exist"); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
private static void test(Class<?> type,"property does not exist"); } }
private static void test(Class<?> type,"property does not exist"); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName,Class<?> propertyType) { for (PropertyDescriptor pd : this.propertyDescriptors) { final Class<?> candidateType; final String candidateName = pd.getName(); if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; candidateType = ipd.getIndexedPropertyType(); if (candidateName.equals(propertyName) && (candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) { return pd; } } else { candidateType = pd.getPropertyType(); if (candidateName.equals(propertyName) && (candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) { return pd; } } } return null; }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
private static void test(Class<?> type,"property does not exist"); } }
private static void test(Class<?> type,"property does not exist"); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
private static void test(Class<?> type,"property does not exist"); } }
private static void test(Class<?> type,"property does not exist"); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName,Class<?> propertyType) { for (PropertyDescriptor pd : this.propertyDescriptors) { final Class<?> candidateType; final String candidateName = pd.getName(); if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; candidateType = ipd.getIndexedPropertyType(); if (candidateName.equals(propertyName) && (candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) { return pd; } } else { candidateType = pd.getPropertyType(); if (candidateName.equals(propertyName) && (candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) { return pd; } } } return null; }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
private static void test(Class<?> type,"property does not exist"); } }
private static void test(Class<?> type,"property does not exist"); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
private static void test(Class<?> type,"property does not exist"); } }
private static void test(Class<?> type,"property does not exist"); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
/** * Return the Java Class representing the property type of the specified property,or * <code>null</code> if there is no such property for the specified bean. This method * follows the same name resolution rules used by <code>getPropertyDescriptor()</code>,* so if the last element of a name reference is indexed,the type of the property itself * will be returned. If the last (or only) element has no property with the specified * name,<code>null</code> is returned. * * @param bean Bean for which a property descriptor is requested * @param name Possibly indexed and/or nested name of the property for which a property * descriptor is requested * @throws illegalaccessexception if the caller does not have access to the property * accessor method * @throws IllegalArgumentException if <code>bean</code> or <code>name</code> are null * or if a nested reference to a property returns null * @throws InvocationTargetException if the property accessor method throws an exception * @throws NoSuchMethodException if an accessor method for this property cannot be * found */ public static Class getPropertyType(Object bean,String name) throws illegalaccessexception,InvocationTargetException,NoSuchMethodException { if(bean == null) throw new IllegalArgumentException("No bean specified"); if(name == null) throw new IllegalArgumentException("No name specified"); PropertyDescriptor descriptor = getPropertyDescriptor(bean,name); if(descriptor == null) { return null; } else if(descriptor instanceof IndexedPropertyDescriptor) { return (((IndexedPropertyDescriptor) descriptor).getIndexedPropertyType()); } else if(descriptor instanceof MappedPropertyDescriptor) { return (((MappedPropertyDescriptor) descriptor).getMappedPropertyType()); } else { return descriptor.getPropertyType(); } }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
private static PropertyDescriptor create(PropertyDescriptor pd) { try { if (pd instanceof IndexedPropertyDescriptor) { IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd; return new IndexedPropertyDescriptor( ipd.getName(),pd.getWriteMethod()); } } catch (IntrospectionException exception) { exception.printstacktrace(); return null; } }
public void test_MixedBooleanSimpleClass7() throws Exception { BeanInfo info = Introspector .getBeanInfo(MixedBooleanSimpleClass7.class); Method getter = MixedBooleanSimpleClass7.class .getDeclaredMethod("isList"); Method setter = MixedBooleanSimpleClass7.class.getDeclaredMethod( "setList",boolean.class); for (PropertyDescriptor pd : info.getPropertyDescriptors()) { if (propertyName.equals(pd.getName())) { assertFalse(pd instanceof IndexedPropertyDescriptor); assertEquals(getter,pd.getReadMethod()); assertEquals(setter,pd.getWriteMethod()); } } }
public void testSetIndexedWriteMethod_return() throws IntrospectionException,NoSuchMethodException,NoSuchMethodException { String propertyName = "PropertyFour"; Class<MockJavaBean> beanClass = MockJavaBean.class; Method readMethod = beanClass.getmethod("get" + propertyName,(Class[]) null); Method writeMethod = beanClass.getmethod("set" + propertyName,new Class[] { String[].class }); Method indexedReadMethod = beanClass.getmethod("get" + propertyName,new Class[] { Integer.TYPE }); IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor( propertyName,readMethod,writeMethod,indexedReadMethod,null); assertNull(ipd.getIndexedWriteMethod()); Method badArgType = beanClass.getmethod("setPropertyFourInvalid",new Class[] { Integer.TYPE,String.class }); ipd.setIndexedWriteMethod(badArgType); assertEquals(String.class,ipd.getIndexedPropertyType()); assertEquals(String[].class,ipd.getPropertyType()); assertEquals(Integer.TYPE,ipd.getIndexedWriteMethod().getReturnType()); }
hudson.model.JobPropertyDescriptor的实例源码
public Map<JobPropertyDescriptor,JobProperty<? super InheritanceProject>> getProperties(IMode mode) { List<JobProperty<? super InheritanceProject>> lst = this.getAllProperties(mode); if (lst == null || lst.isEmpty()) { return Collections.emptyMap(); } HashMap<JobPropertyDescriptor,JobProperty<? super InheritanceProject>> map = new HashMap<JobPropertyDescriptor,JobProperty<? super InheritanceProject>>(); for (JobProperty<? super InheritanceProject> prop : lst) { map.put(prop.getDescriptor(),prop); } return map; }
/** * Test persisting jobs with parameters. * * @throws Exception in Jenkins rule */ @Test public void testSaveParameters() throws Exception { FreeStyleProject project = j.createFreeStyleProject(); GroovyScript scriptParam001 = new GroovyScript(new SecureGroovyScript(SCRIPT_ParaM001,false,null),new SecureGroovyScript(SCRIPT_FALLBACK_ParaM001,null)); ChoiceParameter param001 = new ChoiceParameter("param001","param001 description","random-name",scriptParam001,AbstractUnoChoiceParameter.ParaMETER_TYPE_SINGLE_SELECT,true,1); GroovyScript scriptParam002 = new GroovyScript(new SecureGroovyScript(SCRIPT_ParaM002,new SecureGroovyScript(SCRIPT_FALLBACK_ParaM002,null)); CascadeChoiceParameter param002 = new CascadeChoiceParameter("param002","param002 description",scriptParam002,"param001",1); ParametersDeFinitionProperty param001Def = new ParametersDeFinitionProperty( Arrays.<ParameterDeFinition>asList(param001,param002)); project.addProperty(param001Def); QueueTaskFuture<FreeStyleBuild> future = project.scheduleBuild2(0); FreeStyleBuild build = future.get(); // even though the cascaded parameter will fail to evaluate,we should // still get a success here. assertEquals(Result.SUCCESS,build.getResult()); XmlFile configXml = project.getConfigFile(); FreeStyleProject reReadProject = (FreeStyleProject) configXml.read(); int found = 0; for (Entry<JobPropertyDescriptor,JobProperty<? super FreeStyleProject>> entry : reReadProject.getProperties() .entrySet()) { JobProperty<? super FreeStyleProject> jobProperty = entry.getValue(); if (jobProperty instanceof ParametersDeFinitionProperty) { ParametersDeFinitionProperty paramDef = (ParametersDeFinitionProperty) jobProperty; List<ParameterDeFinition> parameters = paramDef.getParameterDeFinitions(); for (ParameterDeFinition parameter : parameters) { if (parameter instanceof AbstractScriptableParameter) { found++; AbstractScriptableParameter choiceParam = (AbstractScriptableParameter) parameter; String scriptText = ((GroovyScript) choiceParam.getScript()).getScript().getScript(); String fallbackScriptText = ((GroovyScript) choiceParam.getScript()).getFallbackScript() .getScript(); assertTrue("Found an empty script!",StringUtils.isNotBlank(scriptText)); assertTrue("Found an empty fallback script!",StringUtils.isNotBlank(fallbackScriptText)); if (parameter.getName().equals("param001")) { assertEquals(SCRIPT_ParaM001,scriptText); assertEquals(SCRIPT_FALLBACK_ParaM001,fallbackScriptText); } else { assertEquals(SCRIPT_ParaM002,scriptText); assertEquals(SCRIPT_FALLBACK_ParaM002,fallbackScriptText); } } } } } // We have two parameters before saving. We must have two Now. assertEquals("Didn't find all parameters after persisting xml",2,found); }
@Override public Map<JobPropertyDescriptor,JobProperty<? super InheritanceProject>> getProperties() { return this.getProperties(IMode.AUTO); }
public static List<JobPropertyDescriptor> getJobPropertyDescriptors( Class<? extends Job> clazz,boolean filterIsExcluding,String... filters) { List<JobPropertyDescriptor> out = new ArrayList<JobPropertyDescriptor>(); //JobPropertyDescriptor.getPropertyDescriptors(clazz); List<JobPropertyDescriptor> allDesc = Functions.getJobPropertyDescriptors(clazz); for (JobPropertyDescriptor desc : allDesc) { String dName = desc.getClass().getName(); if (filters.length > 0) { boolean matched = false; if (filters != null) { for (String filter : filters) { if (dName.contains(filter)) { matched = true; break; } } } if (filterIsExcluding && matched) { continue; } else if (!filterIsExcluding && !matched) { continue; } } //The class has survived the filter out.add(desc); } //At last,we make sure to sort the fields by full name; to ensure //that properties from the same package/plugin are next to each other Collections.sort(out,new Comparator<JobPropertyDescriptor>() { @Override public int compare(JobPropertyDescriptor o1,JobPropertyDescriptor o2) { String c1 = o1.getClass().getName(); String c2 = o2.getClass().getName(); return c1.compareto(c2); } }); return out; }
@Override public JobPropertyDescriptor getDescriptor() { return DESCRIPTOR; }
/** * We need to override this method do prevent Jenkins from trying to * register this class as a "real" property worthy of inclusion in the * configuration view. * <p> * This is necessary,because this class is only a pure wrapper around * {@link ParametersDeFinitionProperty} and does not own any properties * that need to be stored separately. * <p> * Unfortunately; not defining a Descriptor at all would lead to this * class not being able to completely wrap the * {@link ParametersDeFinitionProperty} class. */ @Override public JobPropertyDescriptor getDescriptor() { //return super.getDescriptor(); return (JobPropertyDescriptor) Jenkins.getInstance().getDescriptorOrDie( ParametersDeFinitionProperty.class ); }
java.beans.BeanDescriptor的实例源码
/** 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; }
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; }
/** * 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(); }
@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; }
/** 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(); } }
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)); }
@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; }
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; } }
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; }
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); } }
@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; }
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; }
@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; } }
@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; }
/** 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); } }
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; }
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; }
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; }
@Override public BeanDescriptor getBeanDescriptor() { Class customizer = null; try { customizer = Class.forName("org.netbeans.modules.javascript2.debug.ui.breakpoints.JSLineBreakpointCustomizer",Lookup.getDefault().lookup(ClassLoader.class)); } catch (ClassNotFoundException cnfex) { LOG.log(Level.WARNING,"No BP customizer",cnfex); } return new BeanDescriptor( JSLineBreakpoint.class,customizer); }
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>"); }
/** * 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); } }
@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; }
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); }
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); } }
private static void test(Class<?> type,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"); } } }
/** * 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); } }
@Override public BeanDescriptor getBeanDescriptor() { BeanDescriptor bd = new BeanDescriptor(TestClass.class,"user-defined-delegate"); return bd; }
private static void test(Class<?> type,cD); }
private static void test(BeanDescriptor bd,expected)) { throw new Error(name + ": expected = " + expected + "; actual = " + value); } }
private static void test(Class<?> type,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"); } } }
/** * 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); } }
/** * 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); } }
/** * 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); } }
/** * 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); }
/** * 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); }
/** * 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); }
public BeanDescriptor getBeanDescriptor() { BeanDescriptor descriptor = new BeanDescriptor(DerbyOptions.class); descriptor.setName(NbBundle.getMessage(DerbyOptionsBeanInfo.class,"LBL_DerbyOptions")); return descriptor; }
@Override public BeanDescriptor getBeanDescriptor() { return new BeanDescriptor(javax.swing.OverlayLayout.class); }
@Override public BeanDescriptor getBeanDescriptor() { return new BeanDescriptor( ComponentBreakpoint.class,ComponentBreakpointCustomizer.class); }
@Override public BeanDescriptor getBeanDescriptor() { return this.delegate.getBeanDescriptor(); }
java.beans.EventSetDescriptor的实例源码
/** try to register Propertychangelistener to instance to fire its changes. * @param bean */ private void initPList (Object bean,BeanInfo bInfo,BeanNode.Descriptor descr) { EventSetDescriptor[] descs = bInfo.getEventSetDescriptors(); try { Method setter = null; for (int i = 0; descs != null && i < descs.length; i++) { setter = descs[i].getAddListenerMethod(); if (setter != null && setter.getName().equals("addPropertychangelistener")) { // NOI18N propertychangelistener = new PropL(createSupportedPropertyNames(descr)); setter.invoke(bean,new Object[] {WeakListeners.propertyChange(propertychangelistener,bean)}); setSettingsInstance(bean); } } } catch (Exception ex) { // ignore } }
private void _addEvent( Hashtable<String,EventSetDescriptor> events,EventSetDescriptor descriptor ) { String key = descriptor.getName() + descriptor.getListenerType(); if (descriptor.getName().equals("propertyChange")) { _propertyChangeSource = true; } EventSetDescriptor oldDescriptor = events.get(key); if (oldDescriptor == null) { events.put(key,descriptor); return; } EventSetDescriptor composite = _createMergedEventSetDescriptor( oldDescriptor,descriptor); events.put(key,composite); }
static EventSetDescriptor __createMergedEventSetStub( EventSetDescriptor oldDescriptor,MethodDescriptor[] listenerDescriptors ) { try { EventSetDescriptor stubDescriptor = new EventSetDescriptor( oldDescriptor.getName(),oldDescriptor.getListenerType(),listenerDescriptors,oldDescriptor.getAddListenerMethod(),oldDescriptor.getRemoveListenerMethod()); // set the unicast attribute stubDescriptor.setUnicast(oldDescriptor.isUnicast()); return stubDescriptor; } catch (Exception e) { // _LOG.severe(e); return null; } }
public static void main(String[] args) throws IntrospectionException,NoSuchMethodException { EventSetDescriptor esd = new EventSetDescriptor( "foo",FooListener.class,new Method[] { FooListener.class.getmethod("fooHappened",EventObject.class),FooListener.class.getmethod("moreFooHappened",EventObject.class,Object.class),FooListener.class.getmethod("lessFooHappened"),},Bean.class.getmethod("addFooListener",FooListener.class),Bean.class.getmethod("removeFooListener",FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean",bt); test(pd.getReadMethod()); test(pd.getWriteMethod()); // test IndexedPropertyDescriptor IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed",bt); test(ipd.getReadMethod()); test(ipd.getWriteMethod()); test(ipd.getIndexedReadMethod()); test(ipd.getIndexedWriteMethod()); // test EventSetDescriptor EventSetDescriptor esd = new EventSetDescriptor(bt,"test",lt,"process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
@Override public EventSetDescriptor[] getEventSetDescriptors() { EventSetDescriptor[] es = new EventSetDescriptor[2]; try { es[iAction] = new EventSetDescriptor( TestClass.class,"actionListener",java.awt.event.ActionListener.class,new String[] {"actionPerformed"},"addActionListener","removeActionListener"); es[iMouse] = new EventSetDescriptor( TestClass.class,"mouseListener",java.awt.event.MouseListener.class,new String[] {"mouseClicked","mousepressed","mouseReleased","mouseEntered","mouseExited"},"addMouseListener","removeMouseListener"); } catch(IntrospectionException e) { e.printstacktrace(); } return es; }
public static void main(String[] args) throws IntrospectionException,FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
@Override public EventSetDescriptor[] getEventSetDescriptors() { EventSetDescriptor[] es = new EventSetDescriptor[2]; try { es[iAction] = new EventSetDescriptor( TestClass.class,"removeMouseListener"); } catch(IntrospectionException e) { e.printstacktrace(); } return es; }
public static void main(String[] args) throws IntrospectionException,FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
private static EventSetDescriptor[] getEdescriptor(){ EventSetDescriptor[] eventSets = new EventSetDescriptor[14]; try { eventSets[EVENT_ancestorListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"ancestorListener",javax.swing.event.AncestorListener.class,new String[] {"ancestorAdded","ancestorRemoved","ancestorMoved"},"addAncestorListener","removeAncestorListener" ); // NOI18N eventSets[EVENT_caretListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"caretListener",javax.swing.event.CaretListener.class,new String[] {"caretUpdate"},"addCaretListener","removeCaretListener" ); // NOI18N eventSets[EVENT_componentListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"componentListener",java.awt.event.ComponentListener.class,new String[] {"componentResized","componentMoved","componentShown","componentHidden"},"addComponentListener","removeComponentListener" ); // NOI18N eventSets[EVENT_containerListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"containerListener",java.awt.event.ContainerListener.class,new String[] {"componentAdded","componentRemoved"},"addContainerListener","removeContainerListener" ); // NOI18N eventSets[EVENT_focusListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"focusListener",java.awt.event.FocusListener.class,new String[] {"focusGained","focusLost"},"addFocusListener","removeFocusListener" ); // NOI18N eventSets[EVENT_hierarchyBoundsListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"hierarchyBoundsListener",java.awt.event.HierarchyBoundsListener.class,new String[] {"ancestorMoved","ancestorResized"},"addHierarchyBoundsListener","removeHierarchyBoundsListener" ); // NOI18N eventSets[EVENT_hierarchyListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"hierarchyListener",java.awt.event.HierarchyListener.class,new String[] {"hierarchyChanged"},"addHierarchyListener","removeHierarchyListener" ); // NOI18N eventSets[EVENT_inputMethodListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"inputMethodListener",java.awt.event.InputMethodListener.class,new String[] {"inputMethodTextChanged","caretPositionChanged"},"addInputMethodListener","removeInputMethodListener" ); // NOI18N eventSets[EVENT_keyListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"keyListener",java.awt.event.KeyListener.class,new String[] {"keyTyped","keypressed","keyreleased"},"addKeyListener","removeKeyListener" ); // NOI18N eventSets[EVENT_mouseListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"removeMouseListener" ); // NOI18N eventSets[EVENT_mouseMotionListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"mouseMotionListener",java.awt.event.MouseMotionListener.class,new String[] {"mouseDragged","mouseMoved"},"addMouseMotionListener","removeMouseMotionListener" ); // NOI18N eventSets[EVENT_mouseWheelListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"mouseWheelListener",java.awt.event.MouseWheelListener.class,new String[] {"mouseWheelMoved"},"addMouseWheelListener","removeMouseWheelListener" ); // NOI18N eventSets[EVENT_propertychangelistener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"propertychangelistener",java.beans.Propertychangelistener.class,new String[] {"propertyChange"},"addPropertychangelistener","removePropertychangelistener" ); // NOI18N eventSets[EVENT_vetoablechangelistener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MyTextArea.class,"vetoablechangelistener",java.beans.Vetoablechangelistener.class,new String[] {"vetoableChange"},"addVetoablechangelistener","removeVetoablechangelistener" ); // NOI18N } catch(IntrospectionException e) { e.printstacktrace(); }//GEN-HEADEREND:Events // Here you can add code for customizing the event sets array. return eventSets; }
private static EventSetDescriptor[] getEdescriptor(){ EventSetDescriptor[] eventSets = new EventSetDescriptor[15]; try { eventSets[EVENT_ancestorListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeAncestorListener" ); // NOI18N eventSets[EVENT_componentListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeComponentListener" ); // NOI18N eventSets[EVENT_containerListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeContainerListener" ); // NOI18N eventSets[EVENT_focusListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeFocusListener" ); // NOI18N eventSets[EVENT_hierarchyBoundsListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeHierarchyBoundsListener" ); // NOI18N eventSets[EVENT_hierarchyListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeHierarchyListener" ); // NOI18N eventSets[EVENT_inputMethodListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeInputMethodListener" ); // NOI18N eventSets[EVENT_keyListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeKeyListener" ); // NOI18N eventSets[EVENT_menuKeyListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"menuKeyListener",javax.swing.event.MenuKeyListener.class,new String[] {"menuKeyTyped","menuKeypressed","menukeyreleased"},"addMenuKeyListener","removeMenuKeyListener" ); // NOI18N eventSets[EVENT_mouseListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeMouseListener" ); // NOI18N eventSets[EVENT_mouseMotionListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeMouseMotionListener" ); // NOI18N eventSets[EVENT_mouseWheelListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeMouseWheelListener" ); // NOI18N eventSets[EVENT_popupMenuListener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"popupMenuListener",javax.swing.event.PopupMenuListener.class,new String[] {"popupMenuWillBecomeVisible","popupMenuWillBecomeInvisible","popupMenuCanceled"},"addPopupMenuListener","removePopupMenuListener" ); // NOI18N eventSets[EVENT_propertychangelistener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removePropertychangelistener" ); // NOI18N eventSets[EVENT_vetoablechangelistener] = new EventSetDescriptor ( com.talent.aio.examples.im.client.ui.component.MsgTextAreajpopupmenu.class,"removeVetoablechangelistener" ); // NOI18N } catch(IntrospectionException e) { e.printstacktrace(); }//GEN-HEADEREND:Events // Here you can add code for customizing the event sets array. return eventSets; }
public static void main(String[] args) throws IntrospectionException,FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
public static void main(String[] args) throws IntrospectionException,FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean","process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
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; }
void findAddRemovePairs(BeanInfoEmbryo b) throws IntrospectionException { Enumeration listenerEnum = listenerMethods.keys(); while(listenerEnum.hasMoreElements()) { DoubleKey k = (DoubleKey)listenerEnum.nextElement(); Method[] m = (Method[])listenerMethods.get(k); if(m[ADD] != null && m[REMOVE] != null) { EventSetDescriptor e = new EventSetDescriptor(Introspector.decapitalize(k.getName()),k.getType(),k.getType().getmethods(),m[ADD],m[REMOVE]); e.setUnicast(ArrayHelper.contains(m[ADD].getExceptionTypes(),java.util.TooManyListenersException.class)); if(!b.hasEvent(e)) { b.addEvent(e); } } } }
/** * Get the event set descriptors pertinent to data sources * * @return an <code>EventSetDescriptor[]</code> value */ @Override public EventSetDescriptor[] getEventSetDescriptors() { try { List<EventSetDescriptor> descriptors = new ArrayList<EventSetDescriptor>(); for (EventSetDescriptor es : super.getEventSetDescriptors()) { descriptors.add(es); } descriptors.add(new EventSetDescriptor(CSVToARFFHadoopJob.class,"dataSet",DataSourceListener.class,"acceptDataSet")); descriptors.add(new EventSetDescriptor(CSVToARFFHadoopJob.class,"image",ImageListener.class,"acceptimage")); return descriptors.toArray(new EventSetDescriptor[descriptors.size()]); } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors pertinent to data sources * * @return an <code>EventSetDescriptor[]</code> value */ @Override public EventSetDescriptor[] getEventSetDescriptors() { try { List<EventSetDescriptor> descriptors = new ArrayList<EventSetDescriptor>(); for (EventSetDescriptor es : super.getEventSetDescriptors()) { descriptors.add(es); } } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors pertinent to data sources * * @return an <code>EventSetDescriptor[]</code> value */ @Override public EventSetDescriptor[] getEventSetDescriptors() { try { List<EventSetDescriptor> descriptors = new ArrayList<EventSetDescriptor>(); for (EventSetDescriptor es : super.getEventSetDescriptors()) { descriptors.add(es); } descriptors.add(new EventSetDescriptor(WekaClassifierHadoopJob.class,"text",TextListener.class,"acceptText")); descriptors.add(new EventSetDescriptor(WekaClassifierHadoopJob.class,"batchClassifier",BatchClassifierListener.class,"acceptClassifier")); return descriptors.toArray(new EventSetDescriptor[descriptors.size()]); } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors pertinent to data sources * * @return an <code>EventSetDescriptor[]</code> value */ @Override public EventSetDescriptor[] getEventSetDescriptors() { try { List<EventSetDescriptor> descriptors = new ArrayList<EventSetDescriptor>(); for (EventSetDescriptor es : super.getEventSetDescriptors()) { descriptors.add(es); } descriptors.add(new EventSetDescriptor( WekaClassifierEvaluationHadoopJob.class,"acceptText")); descriptors.add(new EventSetDescriptor( WekaClassifierEvaluationHadoopJob.class,"acceptDataSet")); return descriptors.toArray(new EventSetDescriptor[descriptors.size()]); } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors pertinent to data sources * * @return an <code>EventSetDescriptor[]</code> value */ @Override public EventSetDescriptor[] getEventSetDescriptors() { try { List<EventSetDescriptor> descriptors = new ArrayList<EventSetDescriptor>(); for (EventSetDescriptor es : super.getEventSetDescriptors()) { descriptors.add(es); } descriptors.add(new EventSetDescriptor(KMeansClustererHadoopJob.class,"acceptText")); descriptors.add(new EventSetDescriptor(KMeansClustererHadoopJob.class,"batchClusterer",BatchClustererListener.class,"acceptClusterer")); return descriptors.toArray(new EventSetDescriptor[descriptors.size()]); } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors for this bean * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(IncrementalClassifierEvaluator.class,"chart",ChartListener.class,"acceptDataPoint"),new EventSetDescriptor(IncrementalClassifierEvaluator.class,"acceptText") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors for this bean * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { // hide all gui events try { EventSetDescriptor [] esds = { new EventSetDescriptor(DataVisualizer.class,"acceptimage") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Returns the event set descriptors * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(DataSource.class,"instance",InstanceListener.class,"acceptInstance"),new EventSetDescriptor(DataSource.class,"acceptDataSet") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
private DefaultActionGroup prepareActionGroup(final List<RadComponent> selection) { final DefaultActionGroup actionGroup = new DefaultActionGroup(); final EventSetDescriptor[] eventSetDescriptors; try { BeanInfo beanInfo = Introspector.getBeanInfo(selection.get(0).getComponentClass()); eventSetDescriptors = beanInfo.getEventSetDescriptors(); } catch (IntrospectionException e) { LOG.error(e); return null; } EventSetDescriptor[] sortedDescriptors = new EventSetDescriptor[eventSetDescriptors.length]; System.arraycopy(eventSetDescriptors,sortedDescriptors,eventSetDescriptors.length); Arrays.sort(sortedDescriptors,new Comparator<EventSetDescriptor>() { public int compare(final EventSetDescriptor o1,final EventSetDescriptor o2) { return o1.getListenerType().getName().compareto(o2.getListenerType().getName()); } }); for(EventSetDescriptor descriptor: sortedDescriptors) { actionGroup.add(new MyCreateListenerAction(selection,descriptor)); } return actionGroup; }
/** * Returns the event set descriptors * * @return an <code>EventSetDescriptor[]</code> value */ @Override public EventSetDescriptor[] getEventSetDescriptors() { try { EventSetDescriptor[] esds = { new EventSetDescriptor(DataSource.class,"acceptDataSet") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(TrainingSetProducer.class,"trainingSet",TrainingSetListener.class,"acceptTrainingSet"),new EventSetDescriptor(TestSetProducer.class,"testSet",TestSetListener.class,"acceptTestSet") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Returns the event set descriptors * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(DataSource.class,"acceptInstance") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors for this bean * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(DataVisualizer.class,"acceptDataSet"),new EventSetDescriptor(DataVisualizer.class,"acceptimage") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors pertinent to data sources * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(DataSource.class,"acceptInstance") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Returns a vector of BeanInstances that can be considered as outputs (or the * right-hand side of a sub-flow) * * @param subset the sub-flow to examine * @return a Vector of outputs of the sub-flow */ public static Vector<Object> outputs(Vector<Object> subset,Integer... tab) { Vector<Object> result = new Vector<Object>(); for (int i = 0; i < subset.size(); i++) { BeanInstance temp = (BeanInstance) subset.elementAt(i); if (checkForTarget(temp,subset,tab)) { // Now check source constraint if (checkSourceConstraint(temp,tab)) { // Now check that this bean can actually produce some events try { BeanInfo bi = Introspector.getBeanInfo(temp.getBean().getClass()); EventSetDescriptor[] esd = bi.getEventSetDescriptors(); if (esd != null && esd.length > 0) { result.add(temp); } } catch (IntrospectionException ex) { // quietly ignore } } } } return result; }
/** * Returns the event set descriptors * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(DataSource.class,"acceptDataSet") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
/** * Get the event set descriptors for this bean * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { // hide all gui events try { EventSetDescriptor [] esds = { new EventSetDescriptor(ModelPerformanceChart.class,"acceptimage") }; return esds; } catch (Exception ex) { ex.printstacktrace(); return null; } }
/** * Returns true if,at this time,the object will accept a connection with * respect to the supplied EventSetDescriptor * * @param esd the EventSetDescriptor * @return true if the object will accept a connection */ @Override public boolean connectionAllowed(EventSetDescriptor esd) { Vector<BeanInstance> targets = getSuitableTargets(esd); for (int i = 0; i < targets.size(); i++) { BeanInstance input = targets.elementAt(i); if (input.getBean() instanceof BeanCommon) { // if (((BeanCommon)input.getBean()).connectionAllowed(esd.getName())) { if (((BeanCommon) input.getBean()).connectionAllowed(esd)) { return true; } } else { return true; } } return false; }
/** * Returns the event set descriptors * * @return an <code>EventSetDescriptor[]</code> value */ public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(DataSource.class,new EventSetDescriptor(TrainingSetProducer.class,"acceptTestSet") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
public EventSetDescriptor [] getEventSetDescriptors() { try { EventSetDescriptor [] esds = { new EventSetDescriptor(Clusterer.class,"acceptClusterer"),new EventSetDescriptor(Clusterer.class,"graph",GraphListener.class,"acceptGraph"),"acceptText"),"configuration",ConfigurationListener.class,"acceptConfiguration") }; return esds; } catch (Exception ex) { ex.printstacktrace(); } return null; }
Event(RADComponent component,EventSetDescriptor eventSetDescriptor,Method listenerMethod) { this.component = component; this.eventSetDescriptor = eventSetDescriptor; this.listenerMethod = listenerMethod; }
java.beans.FeatureDescriptor的实例源码
/** Internal implementation of getSelection() which returns the selected feature * descriptor whether or not the component has focus. */ public final FeatureDescriptor _getSelection() { int i = getSelectedRow(); FeatureDescriptor result; //Check bounds - a change can be fired after the model has been changed,but //before the table has received the event and updated itself,in which case //you get an AIOOBE if (i < getPropertySetModel().getCount()) { result = getSheetModel().getPropertySetModel().getFeatureDescriptor(getSelectedRow()); } else { result = null; } return result; }
/** * Select (and start editing) the given property. * @param fd * @param startEditing */ public void select( FeatureDescriptor fd,boolean startEditing ) { PropertySetModel psm = getPropertySetModel(); final int index = psm.indexOf( fd ); if( index < 0 ) { return; //not in our list } getSelectionModel().setSelectionInterval( index,index ); if( startEditing && psm.isProperty( index ) ) { editCellAt( index,1,new MouseEvent( SheetTable.this,System.currentTimeMillis(),false) ); SwingUtilities.invokelater( new Runnable() { @Override public void run() { SheetCellEditor cellEditor = getEditor(); if( null != cellEditor ) { InplaceEditor inplace = cellEditor.getInplaceEditor(); if( null != inplace && null != inplace.getComponent() ) { inplace.getComponent().requestFocus(); } } } }); } }
@Override public void actionPerformed(ActionEvent ae) { int i = getSelectedRow(); if (i != -1) { FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(i); if (fd instanceof Property) { java.beans.propertyeditor ped = PropUtils.getpropertyeditor((Property) fd); System.err.println(ped.getClass().getName()); } else { System.err.println("PropertySets - no editor"); //NOI18N } } else { System.err.println("No selection"); //NOI18N } }
@Override protected Transferable createTransferable(JComponent c) { if (c instanceof SheetTable) { SheetTable table = (SheetTable) c; FeatureDescriptor fd = table.getSelection(); if (fd == null) { return null; } String res = fd.getdisplayName(); if (fd instanceof Node.Property) { Node.Property prop = (Node.Property) fd; res += ("\t" + PropUtils.getpropertyeditor(prop).getAsText()); } return new SheetTableTransferable(res); } return null; }
/** * Expand or collapse the PropertySet the given property belongs to. * @param fd * @since 6.47 */ protected final void toggleExpanded( FeatureDescriptor fd ) { int index = table.getPropertySetModel().indexOf( fd ); if( index >= 0 ) { table.getPropertySetModel().toggleExpanded( index ); } }
/** Creates a new instance of ModelProperty */ private ModelProperty(PropertyModel pm) { super(pm.getPropertyType()); this.mdl = pm; if (mdl instanceof ExPropertyModel) { FeatureDescriptor fd = ((ExPropertyModel) mdl).getFeatureDescriptor(); Boolean result = (Boolean) fd.getValue("canEditAsText"); // NOI18N if (result != null) { this.setValue("canEditAsText",result); } } //System.err.println( //"Created ModelProperty wrapper for mystery PropertyModel " + pm); }
/** * Feature descritor that describes the property. It is feature * descriptor so one can plug in PropertyDescritor and also Node.Property * which both inherit from FeatureDescriptor */ void setFeatureDescriptor(FeatureDescriptor desc) { if (desc == null) { throw new IllegalArgumentException("Cannot set FeatureDescriptor to null."); //NOI18N } this.featureDescriptor = desc; if (featureDescriptor != null) { Object obj = featureDescriptor.getValue(PROP_CHANGE_IMMEDIATE); if (obj instanceof Boolean) { setChangeImmediate(((Boolean) obj).booleanValue()); } } }
void readEnv (FeatureDescriptor desc) { if (desc instanceof Node.Property){ Node.Property prop = (Node.Property)desc; editable = prop.canWrite(); //enh 29294 - support one-line editor & suppression of custom //editor instructions = (String) prop.getValue ("instructions"); //NOI18N oneline = Boolean.TRUE.equals (prop.getValue ("oneline")); //NOI18N customEd = !Boolean.TRUE.equals (prop.getValue ("suppressCustomEditor")); //NOI18N } Object obj = desc.getValue(ObjectEditor.PROP_NULL); if (Boolean.TRUE.equals(obj)) { nullValue = NbBundle.getMessage(StringEditor.class,"CTL_NullValue"); } else { if (obj instanceof String) { nullValue = (String)obj; } else { nullValue = null; } } }
@Override public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,Object base) { if (base == null) { return null; } try { BeanInfo info = Introspector.getBeanInfo(base.getClass()); PropertyDescriptor[] pds = info.getPropertyDescriptors(); for (int i = 0; i < pds.length; i++) { pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME,Boolean.TRUE); pds[i].setValue(TYPE,pds[i].getPropertyType()); } return Arrays.asList((FeatureDescriptor[]) pds).iterator(); } catch (IntrospectionException e) { // } return null; }
@Override public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,pds[i].getPropertyType()); } return Arrays.asList((FeatureDescriptor[]) pds).iterator(); } catch (IntrospectionException e) { // } return null; }
/** * Tests that a valid FeatureDescriptors are returned. */ @Test public void testGetFeatureDescriptors02() { BeanELResolver resolver = new BeanELResolver(); ELContext context = new ELContextImpl(); Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(context,new Bean()); while (result.hasNext()) { PropertyDescriptor featureDescriptor = (PropertyDescriptor) result.next(); Assert.assertEquals(featureDescriptor.getPropertyType(),featureDescriptor.getValue(ELResolver.TYPE)); Assert.assertEquals(Boolean.TRUE,featureDescriptor.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); } }
/** * Tests that a valid FeatureDescriptors are returned. */ @Test public void testGetFeatureDescriptors02() { MapELResolver mapELResolver = new MapELResolver(); ELContext context = new ELContextImpl(); Map<String,String> map = new HashMap<String,String>(); map.put("key","value"); Iterator<FeatureDescriptor> result = mapELResolver .getFeatureDescriptors(context,map); while (result.hasNext()) { FeatureDescriptor featureDescriptor = result.next(); Assert.assertEquals("key",featureDescriptor.getdisplayName()); Assert.assertEquals("key",featureDescriptor.getName()); Assert.assertEquals("",featureDescriptor.getShortDescription()); Assert.assertFalse(featureDescriptor.isExpert()); Assert.assertFalse(featureDescriptor.isHidden()); Assert.assertTrue(featureDescriptor.isPreferred()); Assert.assertEquals("key".getClass(),featureDescriptor .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); } }
/** * Tests that a valid FeatureDescriptors are returned. */ @Test public void testGetFeatureDescriptors02() { ResourceBundleELResolver resolver = new ResourceBundleELResolver(); ELContext context = new ELContextImpl(); ResourceBundle resourceBundle = new TesterResourceBundle( new Object[][] { { "key","value" } }); @SuppressWarnings("unchecked") Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors( context,resourceBundle); while (result.hasNext()) { FeatureDescriptor featureDescriptor = result.next(); Assert.assertEquals("key",featureDescriptor.getShortDescription()); Assert.assertFalse(featureDescriptor.isExpert()); Assert.assertFalse(featureDescriptor.isHidden()); Assert.assertTrue(featureDescriptor.isPreferred()); Assert.assertEquals(String.class,featureDescriptor .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); } }
/** * Add all of the attributes of one FeatureDescriptor to thos * of another,replacing any attributes that conflict. */ static void __addFeatureValues( FeatureDescriptor addingDescriptor,FeatureDescriptor destinationDescriptor ) { Enumeration<String> keys = addingDescriptor.attributeNames(); if (keys != null) { while (keys.hasMoreElements()) { String key = keys.nextElement(); Object value = addingDescriptor.getValue(key); destinationDescriptor.setValue(key,value); } } }
@Override public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,pds[i].getPropertyType()); } return Arrays.asList((FeatureDescriptor[]) pds).iterator(); } catch (IntrospectionException e) { // } return null; }
/** * Tests that a valid FeatureDescriptors are returned. */ @Test public void testGetFeatureDescriptors02() { BeanELResolver resolver = new BeanELResolver(); ELContext context = new ELContextImpl(); Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(context,featureDescriptor.getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); } }
/** * Tests that a valid FeatureDescriptors are returned. */ @Test public void testGetFeatureDescriptors02() { MapELResolver mapELResolver = new MapELResolver(); ELContext context = new ELContextImpl(); Map<String,featureDescriptor .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); } }
/** * Tests that a valid FeatureDescriptors are returned. */ @Test public void testGetFeatureDescriptors02() { ResourceBundleELResolver resolver = new ResourceBundleELResolver(); ELContext context = new ELContextImpl(); ResourceBundle resourceBundle = new TesterResourceBundle( new Object[][] { { "key",featureDescriptor .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME)); } }
@Override public void attachEnv(PropertyEnv env) { FeatureDescriptor desc = env.getFeatureDescriptor(); if (desc instanceof Node.Property){ Node.Property prop = (Node.Property)desc; editable = prop.canWrite(); if (textComp != null) textComp.setEditable(editable); } }
@Override public void attachEnv(PropertyEnv env) { //System.out.println("Valuepropertyeditor.attachEnv("+env+"),feature descriptor = "+env.getFeatureDescriptor()); env.setState(PropertyEnv.STATE_NEEDS_VALIDATION); env.addVetoablechangelistener(validate); if (delegatepropertyeditor instanceof Expropertyeditor) { //System.out.println(" attaches to "+delegatepropertyeditor); if (delegateValue instanceof String) { ShortenedStrings.StringInfo shortenedInfo = ShortenedStrings.getShortenedInfo((String) delegateValue); if (shortenedInfo != null) { // The value is too large,do not allow editing! FeatureDescriptor desc = env.getFeatureDescriptor(); if (desc instanceof Node.Property){ Node.Property prop = (Node.Property)desc; // Need to make it uneditable try { Method forceNotEditableMethod = prop.getClass().getDeclaredMethod("forceNotEditable"); forceNotEditableMethod.setAccessible(true); forceNotEditableMethod.invoke(prop); } catch (Exception ex){} //editable = prop.canWrite(); } } } ((Expropertyeditor) delegatepropertyeditor).attachEnv(env); this.env = env; } }
private void call_propertysheet_select(propertysheet sheet,FeatureDescriptor descriptor,boolean edit) throws NoSuchMethodException,illegalaccessexception,IllegalArgumentException,InvocationTargetException { //private so far,will be public later Class clz = propertysheet.class; Method select_method = clz.getDeclaredMethod("select",FeatureDescriptor.class,boolean.class); //NOI18N select_method.setAccessible(true); select_method.invoke(sheet,descriptor,edit); }
@Override protected jpopupmenu createPopupMenu() { FeatureDescriptor fd = getSelection(); if (fd != null) { if (fd instanceof RuleEditorNode.DeclarationProperty) { //property // //actions: //remove //hide //???? //custom popop for the whole panel jpopupmenu pm = new jpopupmenu(); if(!addPropertyMode) { pm.add(new GoToSourceAction(RuleEditorPanel.this,(RuleEditorNode.DeclarationProperty) fd)); pm.addSeparator(); pm.add(new RemovePropertyAction(RuleEditorPanel.this,(RuleEditorNode.DeclarationProperty) fd)); } return pm; } else if (fd instanceof RuleEditorNode.PropertyCategoryPropertySet) { //property category //Todo possibly add "add property" action which would //preselect the css category in the "add property dialog". } } //no context popup - create the generic popup return genericPopupMenu; }
private TableCellRenderer getCustomrenderer( int row ) { FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(row); if (fd instanceof PropertySet) return null; Object res = fd.getValue( "custom.cell.renderer"); //NOI18N if( res instanceof TableCellRenderer ) { prepareCustomEditor( res ); return ( TableCellRenderer ) res; } return null; }
private TableCellEditor getCustomEditor( int row ) { FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(row); if (fd instanceof PropertySet) return null; Object res = fd.getValue( "custom.cell.editor"); //NOI18N if( res instanceof TableCellEditor ) { prepareCustomEditor( res ); return ( TableCellEditor ) res; } return null; }
/** Overridden to cast value to FeatureDescriptor and return true if the * text matches its display name. The popup search field uses this method * to check matches. */ @Override protected boolean matchText(Object value,String text) { if (value instanceof FeatureDescriptor) { return ((FeatureDescriptor) value).getdisplayName().toupperCase().startsWith(text.toupperCase()); } else { return false; } }
/** We only use a single listener on the selected node,propertysheet.SheetPCListener,* to centralize things. It will call this method if a property change is detected * so that it can be repainted. */ void repaintProperty(String name) { if (!isShowing()) { return; } if (PropUtils.isLoggable(SheetTable.class)) { PropUtils.log(SheetTable.class,"RepaintProperty: " + name); } PropertySetModel psm = getPropertySetModel(); int min = getFirstVisibleRow(); if (min == -1) { return; } int max = min + getVisibleRowCount(); for (int i = min; i < max; i++) { FeatureDescriptor fd = psm.getFeatureDescriptor(i); if (null != fd && fd.getName().equals(name)) { //repaint property value & name paintRow( i ); return; } } if (PropUtils.isLoggable(SheetTable.class)) { PropUtils.log(SheetTable.class,"Property is either scrolled offscreen or property name is bogus: " + name); } }
/**Overridden to do the assorted black magic by which one determines if * a property is editable */ @Override public boolean isCellEditable(int row,int column) { if (column == 0) { return null != getCustomEditor( row ); } FeatureDescriptor fd = getPropertySetModel().getFeatureDescriptor(row); boolean result; if (fd instanceof PropertySet) { result = false; } else { Property p = (Property) fd; result = p.canWrite(); if (result) { Object val = p.getValue("canEditAsText"); //NOI18N if (val != null) { result &= Boolean.TRUE.equals(val); if( !result ) { //#227661 - combo Box editor should be allowed to show its popup propertyeditor ped = PropUtils.getpropertyeditor(p); result |= ped.getTags() != null; } } } } return result; }
@Override public void actionPerformed(ActionEvent ae) { FeatureDescriptor fd = _getSelection(); if (fd instanceof PropertySet) { int row = SheetTable.this.getSelectedRow(); boolean b = getPropertySetModel().isExpanded(fd); if (b) { toggleExpanded(row); } } }
@Override public void actionPerformed(ActionEvent ae) { FeatureDescriptor fd = _getSelection(); if (fd instanceof PropertySet) { int row = SheetTable.this.getSelectedRow(); boolean b = getPropertySetModel().isExpanded(fd); if (!b) { toggleExpanded(row); } } }
public void valueChanged(propertyeditor editor) { Failed = false; try { // System.err.println("ValueChanged - new value " + editor.getValue()); if (getInplaceEditor() != null) { setEnteredValue(getproperty().getValue()); } else { //Handle case where our parent PropertyPanel is no longer showing,but //the custom editor we invoked still is. Issue 38004 PropertyModel mdl = (modelRef != null) ? modelRef.get() : null; if (mdl != null) { FeatureDescriptor fd = null; if (mdl instanceof ExPropertyModel) { fd = ((ExPropertyModel) mdl).getFeatureDescriptor(); } String title = null; if (fd != null) { title = fd.getdisplayName(); } Failed = PropUtils.updateProp(mdl,editor,title); //XXX } } } catch (Exception e) { throw (IllegalStateException) new IllegalStateException("Problem setting entered value from custom editor").initCause(e); } }
/** Basically some hacks to acquire the underlying property descriptor in * the case of a wrapper. This is here because some property editors will * cast the result of PropertyEnv.getFeatureDescriptor() as a specific * implementation type,so even if we're wrapping a property model,we * still need to make sure we're returning the class they expect. */ static final FeatureDescriptor findFeatureDescriptor(Propertydisplayer pd) { if (pd instanceof EditorPropertydisplayer) { //Issue 38004,more gunk to ensure we get the right feature //descriptor EditorPropertydisplayer epd = (EditorPropertydisplayer) pd; if (epd.modelRef != null) { PropertyModel pm = epd.modelRef.get(); if (pm instanceof ExPropertyModel) { FeatureDescriptor fd = ((ExPropertyModel) pm).getFeatureDescriptor(); if (fd != null) { return fd; } } } } Property p = pd.getproperty(); if (p instanceof ModelProperty) { return ((ModelProperty) p).getFeatureDescriptor(); } else if (p instanceof ModelProperty.DPMWrapper) { return ((ModelProperty.DPMWrapper) p).getFeatureDescriptor(); } else { return p; } }
/** Used by EditablePropertydisplayer to provide access to the real * feature descriptor. Some property editors will cast the result of * env.getFeatureDescriptor() as Property or PropertyDescriptor,so we * need to return the original */ FeatureDescriptor getFeatureDescriptor() { if (mdl instanceof ExPropertyModel) { return ((ExPropertyModel) mdl).getFeatureDescriptor(); } else { return this; } }
public String getAccessibleName() { String name = super.getAccessibleName(); if ((name == null) && model instanceof ExPropertyModel) { FeatureDescriptor fd = ((ExPropertyModel) model).getFeatureDescriptor(); name = NbBundle.getMessage(PropertyPanel.class,"ACS_PropertyPanel",fd.getdisplayName()); //NOI18N } return name; }
public String getAccessibleDescription() { String description = super.getAccessibleDescription(); if ((description == null) && model instanceof ExPropertyModel) { FeatureDescriptor fd = ((ExPropertyModel) model).getFeatureDescriptor(); description = NbBundle.getMessage(PropertyPanel.class,"ACSD_PropertyPanel",fd.getShortDescription()); //NOI18N } return description; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()); sb.append("@"); //NOI18N sb.append(System.identityHashCode(this)); sb.append("[state="); //NOI18N sb.append( (state == STATE_NEEDS_VALIDATION) ? "STATE_NEEDS_VALIDATION" : ((state == STATE_INVALID) ? "STATE_INVALID" : "STATE_VALID") ); //NOI18N sb.append(","); //NOI18N Factory f = factory; if (f != null) { sb.append("InplaceEditorFactory=").append(f.getClass().getName()); //NOI18N sb.append(","); //NOI18N } sb.append("editable="); //NOI18N sb.append(editable); sb.append(",isChangeImmediate="); //NOI18N sb.append(isChangeImmediate()); sb.append(",featureDescriptor="); //NOI18N final FeatureDescriptor fd = getFeatureDescriptor(); if (fd != null) { sb.append(fd.getdisplayName()); } else { sb.append("null"); // NOI18N } return sb.toString(); }
public void testCurrentNodes () throws Exception { tc.setActivatednodes(new Node[] {Node.EMPTY}); assertEquals ("This fires change",cnt); assertEquals ("One item in result",result.allItems ().size ()); Lookup.Item item = (Lookup.Item)result.allItems ().iterator ().next (); assertEquals ("Item should return Node.EMPTY",Node.EMPTY,item.getInstance()); assertActionMap (); tc.setActivatednodes (null); assertEquals ("One change",2,cnt); assertEquals ("One empty item in result",result.allItems ().size ()); item = (Lookup.Item)result.allItems ().iterator ().next (); assertEquals ("Item should return null",null,item.getInstance()); assertEquals ("Name is null","none",item.getId ()); assertActionMap (); Result<MyNode> subclass = lookup.lookup (new Lookup.Template<MyNode> (MyNode.class)); assertTrue("No items are returned",subclass.allItems().isEmpty()); Result<FeatureDescriptor> superclass = lookup.lookup (new Lookup.Template<FeatureDescriptor>(FeatureDescriptor.class)); assertEquals("One item is returned",superclass.allItems().size()); item = (Lookup.Item)superclass.allItems ().iterator ().next (); assertEquals ("Item should return null",item.getInstance()); tc.setActivatednodes (new Node[0]); assertEquals ("No change",3,cnt); assertEquals ("No items in lookup",result.allItems ().size ()); assertActionMap (); }
@Override public void attachEnv(PropertyEnv env) { FeatureDescriptor d = env.getFeatureDescriptor(); if (d instanceof Node.Property) { canWrite = ((Node.Property) d).canWrite(); } }
/** */ public void attachEnv (PropertyEnv env) { FeatureDescriptor desc = env.getFeatureDescriptor(); if (desc instanceof Node.Property){ Node.Property prop = (Node.Property)desc; editable = prop.canWrite(); } }
public void attachEnv(PropertyEnv env) { this.env = env; FeatureDescriptor desc = env.getFeatureDescriptor(); if (desc instanceof Node.Property){ Node.Property prop = (Node.Property)desc; editable = prop.canWrite(); //enh 29294 - support one-line editor & suppression of custom //editor instructions = (String) prop.getValue ("instructions"); //NOI18N oneline = Boolean.TRUE.equals (prop.getValue ("oneline")); //NOI18N customEd = !Boolean.TRUE.equals (prop.getValue ("suppressCustomEditor")); //NOI18N } }
@Override public FeatureDescriptor next() { if (!hasNext()) throw new NoSuchElementException(); FeatureDescriptor result = this.next; this.next = null; return result; }
今天的关于java.beans.IndexedPropertyDescriptor的实例源码和java.beans.introspection的分享已经结束,谢谢您的关注,如果想了解更多关于hudson.model.JobPropertyDescriptor的实例源码、java.beans.BeanDescriptor的实例源码、java.beans.EventSetDescriptor的实例源码、java.beans.FeatureDescriptor的实例源码的相关知识,请在本站进行查询。
本文标签: