java.beans.FeatureDescriptor Java Examples

The following examples show how to use java.beans.FeatureDescriptor. 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 File: BeanELResolver.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: SheetTable.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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
    }
}
 
Example #3
Source File: TestResourceBundleELResolver.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * 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.getDisplayName());
        Assert.assertEquals("key", featureDescriptor.getName());
        Assert.assertEquals("", featureDescriptor.getShortDescription());
        Assert.assertFalse(featureDescriptor.isExpert());
        Assert.assertFalse(featureDescriptor.isHidden());
        Assert.assertTrue(featureDescriptor.isPreferred());
        Assert.assertEquals(String.class,
                featureDescriptor.getValue(ELResolver.TYPE));
        Assert.assertEquals(Boolean.TRUE, featureDescriptor
                .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
    }
}
 
Example #4
Source File: BeanELResolver.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@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;
}
 
Example #5
Source File: TestBeanELResolver.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * 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));
    }
}
 
Example #6
Source File: TestMapELResolver.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Tests that a valid FeatureDescriptors are returned.
 */
@Test
public void testGetFeatureDescriptors02() {
    MapELResolver mapELResolver = new MapELResolver();
    ELContext context = new StandardELContext(
            ELManager.getExpressionFactory());

    Map<String, String> map = new HashMap<>();
    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.TYPE));
        Assert.assertEquals(Boolean.TRUE, featureDescriptor
                .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
    }
}
 
Example #7
Source File: TestResourceBundleELResolver.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * 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.getDisplayName());
        Assert.assertEquals("key", featureDescriptor.getName());
        Assert.assertEquals("", featureDescriptor.getShortDescription());
        Assert.assertFalse(featureDescriptor.isExpert());
        Assert.assertFalse(featureDescriptor.isHidden());
        Assert.assertTrue(featureDescriptor.isPreferred());
        Assert.assertEquals(String.class,
                featureDescriptor.getValue(ELResolver.TYPE));
        Assert.assertEquals(Boolean.TRUE, featureDescriptor
                .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
    }
}
 
Example #8
Source File: TestResourceBundleELResolver.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Tests that a valid FeatureDescriptors are returned.
 */
@Test
public void testGetFeatureDescriptors02() {
    ResourceBundleELResolver resolver = new ResourceBundleELResolver();
    ELContext context = new StandardELContext(
            ELManager.getExpressionFactory());

    ResourceBundle resourceBundle = new TesterResourceBundle(
            new Object[][] { { "key", "value" } });
    Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(
            context, resourceBundle);

    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(String.class,
                featureDescriptor.getValue(ELResolver.TYPE));
        Assert.assertEquals(Boolean.TRUE, featureDescriptor
                .getValue(ELResolver.RESOLVABLE_AT_DESIGN_TIME));
    }
}
 
Example #9
Source File: ModelProperty.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 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;
    }
}
 
Example #10
Source File: JsonNodeELResolver.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * If the base object is not null, returns an Iterator containing the set of JavaBeans properties available on the given object. Otherwise, returns null. The Iterator returned must contain zero or
 * more instances of java.beans.FeatureDescriptor. Each info object contains information about a property in the bean, as obtained by calling the BeanInfo.getPropertyDescriptors method. The
 * FeatureDescriptor is initialized using the same fields as are present in the PropertyDescriptor, with the additional required named attributes "type" and "resolvableAtDesignTime" set as
 * follows:
 * <ul>
 * <li>{@link ELResolver#TYPE} - The runtime type of the property, from PropertyDescriptor.getPropertyType().</li>
 * <li>{@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true.</li>
 * </ul>
 * 
 * @param context
 *            The context of this evaluation.
 * @param base
 *            The bean to analyze.
 * @return An Iterator containing zero or more FeatureDescriptor objects, each representing a property on this bean, or null if the base object is null.
 */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
    if (isResolvable(base)) {
        JsonNode node = (JsonNode) base;
        final Iterator<String> keys = node.fieldNames();
        return new Iterator<FeatureDescriptor>() {
            @Override
            public boolean hasNext() {
                return keys.hasNext();
            }

            @Override
            public FeatureDescriptor next() {
                Object key = keys.next();
                FeatureDescriptor feature = new FeatureDescriptor();
                feature.setDisplayName(key == null ? "null" : key.toString());
                feature.setName(feature.getDisplayName());
                feature.setShortDescription("");
                feature.setExpert(true);
                feature.setHidden(false);
                feature.setPreferred(true);
                feature.setValue(TYPE, key == null ? "null" : key.getClass());
                feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true);
                return feature;

            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException("cannot remove");
            }
        };
    }
    return null;
}
 
Example #11
Source File: SheetTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example #12
Source File: TestBeanELResolver.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Tests that a valid FeatureDescriptors are not returned if base is not
 * Map.
 */
@Test
public void testGetFeatureDescriptors01() {
    BeanELResolver resolver = new BeanELResolver();
    ELContext context = new StandardELContext(ELManager.getExpressionFactory());

    Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(context, null);

    Assert.assertNull(result);
}
 
Example #13
Source File: RuleEditorPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #14
Source File: EditablePropertyDisplayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #15
Source File: TestMapELResolver.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Tests that a valid FeatureDescriptors are not returned if base is not
 * Map.
 */
@Test
public void testGetFeatureDescriptors01() {
    MapELResolver mapELResolver = new MapELResolver();
    ELContext context = new StandardELContext(
            ELManager.getExpressionFactory());

    Iterator<FeatureDescriptor> result = mapELResolver
            .getFeatureDescriptors(context, new Object());

    Assert.assertNull(result);
}
 
Example #16
Source File: TestBeanELResolver.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that a valid FeatureDescriptors are not returned if base is not
 * Map.
 */
@Test
public void testGetFeatureDescriptors01() {
    BeanELResolver resolver = new BeanELResolver();
    ELContext context = new ELContextImpl();

    Iterator<FeatureDescriptor> result = resolver.getFeatureDescriptors(context, null);

    Assert.assertNull(result);
}
 
Example #17
Source File: ResourceBundleELResolver.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * If the base object is a ResourceBundle, returns an Iterator containing the set of keys
 * available in the ResourceBundle. Otherwise, returns null. The Iterator returned must contain
 * zero or more instances of java.beans.FeatureDescriptor. Each info object contains information
 * about a key in the ResourceBundle, and is initialized as follows:
 * <ul>
 * <li>displayName - The String key name</li>
 * <li>name - Same as displayName property</li>
 * <li>shortDescription - Empty string</li>
 * <li>expert - false</li>
 * <li>hidden - false</li>
 * <li>preferred - true</li>
 * </ul>
 * In addition, the following named attributes must be set in the returned FeatureDescriptors:
 * <ul>
 * <li>{@link ELResolver#TYPE} - String.class.</li>
 * <li>{@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true</li>
 * </ul>
 * 
 * @param context
 *            The context of this evaluation.
 * @param base
 *            The bundle to analyze. Only bases of type ResourceBundle are handled by this
 *            resolver.
 * @return An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor
 *         objects, each representing a key in this bundle, or null if the base object is not a
 *         ResourceBundle.
 */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
	if (isResolvable(base)) {
		final Enumeration<String> keys = ((ResourceBundle) base).getKeys();
		return new Iterator<FeatureDescriptor>() {
			public boolean hasNext() {
				return keys.hasMoreElements();
			}
			public FeatureDescriptor next() {
				FeatureDescriptor feature = new FeatureDescriptor();
				feature.setDisplayName(keys.nextElement());
				feature.setName(feature.getDisplayName());
				feature.setShortDescription("");
				feature.setExpert(true);
				feature.setHidden(false);
				feature.setPreferred(true);
				feature.setValue(TYPE, String.class);
				feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true);
				return feature;
			}
			public void remove() {
				throw new UnsupportedOperationException("Cannot remove");
				
			}
		};
	}
	return null;
}
 
Example #18
Source File: BeanELResolver.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * If the base object is not null, returns an Iterator containing the set of JavaBeans
 * properties available on the given object. Otherwise, returns null. The Iterator returned must
 * contain zero or more instances of java.beans.FeatureDescriptor. Each info object contains
 * information about a property in the bean, as obtained by calling the
 * BeanInfo.getPropertyDescriptors method. The FeatureDescriptor is initialized using the same
 * fields as are present in the PropertyDescriptor, with the additional required named
 * attributes "type" and "resolvableAtDesignTime" set as follows:
 * <ul>
 * <li>{@link ELResolver#TYPE} - The runtime type of the property, from
 * PropertyDescriptor.getPropertyType().</li>
 * <li>{@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true.</li>
 * </ul>
 * 
 * @param context
 *            The context of this evaluation.
 * @param base
 *            The bean to analyze.
 * @return An Iterator containing zero or more FeatureDescriptor objects, each representing a
 *         property on this bean, or null if the base object is null.
 */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
	if (isResolvable(base)) {
		final PropertyDescriptor[] properties;
		try {
			properties = Introspector.getBeanInfo(base.getClass()).getPropertyDescriptors();
		} catch (IntrospectionException e) {
			return Collections.<FeatureDescriptor> emptyList().iterator();
		}
		return new Iterator<FeatureDescriptor>() {
			int next = 0;

			public boolean hasNext() {
				return properties != null && next < properties.length;
			}

			public FeatureDescriptor next() {
				PropertyDescriptor property = properties[next++];
				FeatureDescriptor feature = new FeatureDescriptor();
				feature.setDisplayName(property.getDisplayName());
				feature.setName(property.getName());
				feature.setShortDescription(property.getShortDescription());
				feature.setExpert(property.isExpert());
				feature.setHidden(property.isHidden());
				feature.setPreferred(property.isPreferred());
				feature.setValue(TYPE, property.getPropertyType());
				feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true);
				return feature;
			}

			public void remove() {
				throw new UnsupportedOperationException("cannot remove");
			}
		};
	}
	return null;
}
 
Example #19
Source File: SheetTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #20
Source File: CommonUtils.java    From zheshiyigeniubidexiangmu with MIT License 5 votes vote down vote up
public static String[] getNullPropertyNames(Object source) {
    final BeanWrapper wrappedSource = new BeanWrapperImpl(source);
    return Stream.of(wrappedSource.getPropertyDescriptors())
            .map(FeatureDescriptor::getName)
            .filter(propertyName -> wrappedSource.getPropertyValue(propertyName) == null)
            .toArray(String[]::new);
}
 
Example #21
Source File: JsonNodeELResolver.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * If the base object is not null, returns an Iterator containing the set of JavaBeans
 * properties available on the given object. Otherwise, returns null. The Iterator returned must
 * contain zero or more instances of java.beans.FeatureDescriptor. Each info object contains
 * information about a property in the bean, as obtained by calling the
 * BeanInfo.getPropertyDescriptors method. The FeatureDescriptor is initialized using the same
 * fields as are present in the PropertyDescriptor, with the additional required named
 * attributes "type" and "resolvableAtDesignTime" set as follows:
 * <ul>
 * <li>{@link ELResolver#TYPE} - The runtime type of the property, from
 * PropertyDescriptor.getPropertyType().</li>
 * <li>{@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true.</li>
 * </ul>
 * 
 * @param context
 *            The context of this evaluation.
 * @param base
 *            The bean to analyze.
 * @return An Iterator containing zero or more FeatureDescriptor objects, each representing a
 *         property on this bean, or null if the base object is null.
 */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
  if (isResolvable(base)) {
    JsonNode node = (JsonNode) base;
    final Iterator<String> keys = node.fieldNames();
    return new Iterator<FeatureDescriptor>() {
      public boolean hasNext() {
        return keys.hasNext();
      }
      public FeatureDescriptor next() {
        Object key = keys.next();
        FeatureDescriptor feature = new FeatureDescriptor();
        feature.setDisplayName(key == null ? "null" : key.toString());
        feature.setName(feature.getDisplayName());
        feature.setShortDescription("");
        feature.setExpert(true);
        feature.setHidden(false);
        feature.setPreferred(true);
        feature.setValue(TYPE, key == null ? "null" : key.getClass());
        feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true);
        return feature;
        
      }
      public void remove() {
        throw new UnsupportedOperationException("cannot remove");
      }
    };
  }
  return null;
}
 
Example #22
Source File: ValuePropertyEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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;
    }
}
 
Example #23
Source File: MapELResolver.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * If the base object is a map, returns an Iterator containing the set of keys available in the
 * Map. Otherwise, returns null. The Iterator returned must contain zero or more instances of
 * java.beans.FeatureDescriptor. Each info object contains information about a key in the Map,
 * and is initialized as follows:
 * <ul>
 * <li>displayName - The return value of calling the toString method on this key, or "null" if
 * the key is null</li>
 * <li>name - Same as displayName property</li>
 * <li>shortDescription - Empty string</li>
 * <li>expert - false</li>
 * <li>hidden - false</li>
 * <li>preferred - true</li>
 * </ul>
 * In addition, the following named attributes must be set in the returned FeatureDescriptors:
 * <ul>
 * <li>{@link ELResolver#TYPE} - The return value of calling the getClass() method on this key,
 * or null if the key is null.</li>
 * <li>{@link ELResolver#RESOLVABLE_AT_DESIGN_TIME} - true</li>
 * </ul>
 * 
 * @param context
 *            The context of this evaluation.
 * @param base
 *            The map to analyze. Only bases of type Map are handled by this resolver.
 * @return An Iterator containing zero or more (possibly infinitely more) FeatureDescriptor
 *         objects, each representing a key in this map, or null if the base object is not a
 *         map.
 */
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
	if (isResolvable(base)) {
		Map<?, ?> map = (Map<?, ?>) base;
		final Iterator<?> keys = map.keySet().iterator();
		return new Iterator<FeatureDescriptor>() {
			public boolean hasNext() {
				return keys.hasNext();
			}
			public FeatureDescriptor next() {
				Object key = keys.next();
				FeatureDescriptor feature = new FeatureDescriptor();
				feature.setDisplayName(key == null ? "null" : key.toString());
				feature.setName(feature.getDisplayName());
				feature.setShortDescription("");
				feature.setExpert(true);
				feature.setHidden(false);
				feature.setPreferred(true);
				feature.setValue(TYPE, key == null ? "null" : key.getClass());
				feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true);
				return feature;
				
			}
			public void remove() {
				throw new UnsupportedOperationException("cannot remove");
			}
		};
	}
	return null;
}
 
Example #24
Source File: Test4935607.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}
 
Example #25
Source File: MockElResolver.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
  return null;
}
 
Example #26
Source File: ReadOnlyMapELResolver.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object arg) {
  return null;
}
 
Example #27
Source File: SimulationExpressionManager.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1) {
  return null;
}
 
Example #28
Source File: ColorsGrammarQueryManager.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public FeatureDescriptor getDescriptor() {
    return new FeatureDescriptor();
}
 
Example #29
Source File: XSLGrammarQueryProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FeatureDescriptor getDescriptor() {
    return new FeatureDescriptor();
}
 
Example #30
Source File: Test4935607.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object expected, FeatureDescriptor fd) {
    System.out.println(fd.getName());
    Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
    if ((actual == null) ? (expected != null) : !actual.equals(expected))
        throw new Error("expected " + expected + " value, but actual value is " + actual);
}