Java Code Examples for java.beans.PropertyDescriptor#isHidden()
The following examples show how to use
java.beans.PropertyDescriptor#isHidden() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openjdk-jdk9 File: TestBooleanBeanProperties.java License: GNU General Public License v2.0 | 6 votes |
private static void test(Class<?> cls, boolean isBound, boolean isExpert, boolean isHidden, boolean isPref, boolean isReq, boolean isVS) { PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(cls, "value"); if (pd.isBound() != isBound) { throw new RuntimeException("isBound should be: " + isBound); } if (pd.isExpert() != isExpert || getValue(pd, "expert") != isExpert) { throw new RuntimeException("isExpert should be:" + isExpert); } if (pd.isHidden() != isHidden || getValue(pd, "hidden") != isHidden) { throw new RuntimeException("isHidden should be: " + isHidden); } if (pd.isPreferred() != isPref) { throw new RuntimeException("isPreferred should be: " + isPref); } if (getValue(pd, "required") != isReq) { throw new RuntimeException("required should be: " + isReq); } if (getValue(pd, "visualUpdate") != isVS) { throw new RuntimeException("required should be: " + isVS); } if (pd.getValue("enumerationValues") == null) { throw new RuntimeException("enumerationValues should be empty array"); } }
Example 2
Source Project: pentaho-reporting File: BeanUtility.java License: GNU Lesser General Public License v2.1 | 6 votes |
public String[] getProperties() throws BeanException { final ArrayList<String> propertyNames = new ArrayList<String>(); final PropertyDescriptor[] pd = getPropertyInfos(); for ( int i = 0; i < pd.length; i++ ) { final PropertyDescriptor property = pd[i]; if ( property.isHidden() ) { continue; } if ( property.getReadMethod() == null || property.getWriteMethod() == null ) { // it will make no sense to write a property now, that // we can't read in later... continue; } if ( BeanUtility.getPropertyType( property ).isArray() ) { final int max = findMaximumIndex( property ); for ( int idx = 0; idx < max; idx++ ) { propertyNames.add( property.getName() + '[' + idx + ']' ); } } else { propertyNames.add( property.getName() ); } } return propertyNames.toArray( new String[propertyNames.size()] ); }
Example 3
Source Project: netbeans File: WebBrowsersOptionsModel.java License: Apache License 2.0 | 5 votes |
private void findPropertyPanel() { try { InstanceCookie cookie = browserSettings.getCookie(InstanceCookie.class); PropertyDescriptor[] propDesc = Introspector.getBeanInfo(cookie.instanceClass()).getPropertyDescriptors(); PropertyDescriptor fallbackProp = null; for (PropertyDescriptor pd : propDesc ) { if (fallbackProp == null && !pd.isExpert() && !pd.isHidden()) { fallbackProp = pd; } if (pd.isPreferred() && !pd.isExpert() && !pd.isHidden()) { propertyPanel = new PropertyPanel(cookie.instanceCreate(), pd.getName(), PropertyPanel.PREF_CUSTOM_EDITOR); propertyPanelID = "PROPERTY_PANEL_" + propertyPanelIDCounter++; propertyPanel.setChangeImmediate(false); break; } } if (propertyPanel == null) { propertyPanel = new PropertyPanel(cookie.instanceCreate(), fallbackProp.getName(), PropertyPanel.PREF_CUSTOM_EDITOR); propertyPanelID = "PROPERTY_PANEL_" + propertyPanelIDCounter++; } } catch (Exception ex) { Exceptions.printStackTrace(ex); } }
Example 4
Source Project: groovy File: BuilderASTTransformation.java License: Apache License 2.0 | 5 votes |
protected static List<PropertyInfo> getPropertyInfoFromBeanInfo(ClassNode cNode, List<String> includes, List<String> excludes, boolean allNames) { final List<PropertyInfo> result = new ArrayList<PropertyInfo>(); try { BeanInfo beanInfo = Introspector.getBeanInfo(cNode.getTypeClass()); for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) { if (shouldSkipUndefinedAware(descriptor.getName(), excludes, includes, allNames)) continue; // skip hidden and read-only props if (descriptor.isHidden() || descriptor.getWriteMethod() == null) continue; result.add(new PropertyInfo(descriptor.getName(), ClassHelper.make(descriptor.getPropertyType()))); } } catch (IntrospectionException ignore) { } return result; }
Example 5
Source Project: openjdk-jdk9 File: TestBeanProperty.java License: GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { Class<?>[] types = {B.class, BL.class, BLF.class, E.class, H.class, P.class, VU.class, D.class, EVD.class, EVE.class, EV.class, EVL.class, EVX.class, R.class}; for (Class<?> type : types) { PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(type, "value"); if (((B.class == type) || (BLF.class == type)) && pd.isBound()) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("not bound"); } if ((BL.class == type) == !pd.isBound()) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("bound"); } if ((E.class == type) == !pd.isExpert()) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("expert"); } if ((H.class == type) == !pd.isHidden()) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("hidden"); } if ((P.class == type) == !pd.isPreferred()) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("preferred"); } if ((R.class == type) == !Boolean.TRUE.equals(pd.getValue("required"))) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("required"); } if ((D.class == type) == !"getter".equals(pd.getShortDescription())) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("shortDescription"); } if ((VU.class == type) == !Boolean.TRUE.equals(pd.getValue("visualUpdate"))) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("visualUpdate"); } if ((EV.class == type) == !isEV(pd, "LEFT", 2, "javax.swing.SwingConstants.LEFT", "RIGHT", 4, "javax.swing.SwingConstants.RIGHT")) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("enumerationValues from another package"); } if ((EVL.class == type) == !isEV(pd, "ZERO", 0, "ZERO", "ONE", 1, "ONE")) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("enumerationValues from another package"); } if ((EVX.class == type) == !isEV(pd, "ZERO", 0, "X.ZERO", "ONE", 1, "X.ONE")) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("enumerationValues from another package"); } if (EVD.class == type && !isEV(pd)) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("EV:"+ pd.getValue("enumerationValues")); } if (EVE.class == type && !isEV(pd)) { BeanUtils.reportPropertyDescriptor(pd); throw new Error("EV:"+ pd.getValue("enumerationValues")); } } }