use of java.beans.FeatureDescriptor in project Activiti by Activiti.
the class ResourceBundleELResolver method getFeatureDescriptors.
/**
* 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;
}
use of java.beans.FeatureDescriptor in project ACS by ACS-Community.
the class ButtonEditor method handleButtonClick.
/**
* method called when the user clicks on the JButton.
* By default, this implementation does a setValue(Boolean.True)
* on the Bean property associated with the Button.
*
* Override this if you need to do something else when the button is
* clicked...
*
* @param evt the ActionEvent generated by the JButton
*/
protected void handleButtonClick(ActionEvent evt) {
FeatureDescriptor fd = propertyEnv.getFeatureDescriptor();
// this.setValue() does not propagate until the Bean.
if (fd instanceof Node.Property) {
try {
((Node.Property) fd).setValue(Boolean.TRUE);
} catch (Exception e) {
e.printStackTrace();
}
}
// nevertheless call this.setValue() to be coherent
setValue(Boolean.TRUE);
}
use of java.beans.FeatureDescriptor in project tomcat by apache.
the class ScopedAttributeELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
PageContext ctxt = (PageContext) context.getContext(JspContext.class);
List<FeatureDescriptor> list = new ArrayList<>();
Enumeration<String> e;
Object value;
String name;
e = ctxt.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.PAGE_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("page scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
e = ctxt.getAttributeNamesInScope(PageContext.REQUEST_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.REQUEST_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("request scope attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
if (ctxt.getSession() != null) {
e = ctxt.getAttributeNamesInScope(PageContext.SESSION_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.SESSION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("session scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
}
e = ctxt.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
while (e.hasMoreElements()) {
name = e.nextElement();
value = ctxt.getAttribute(name, PageContext.APPLICATION_SCOPE);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName(name);
descriptor.setDisplayName(name);
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setShortDescription("application scoped attribute");
descriptor.setValue("type", value.getClass());
descriptor.setValue("resolvableAtDesignTime", Boolean.FALSE);
list.add(descriptor);
}
return list.iterator();
}
use of java.beans.FeatureDescriptor in project tomcat by apache.
the class ResourceBundleELResolver method getFeatureDescriptors.
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
if (base instanceof ResourceBundle) {
List<FeatureDescriptor> feats = new ArrayList<>();
Enumeration<String> e = ((ResourceBundle) base).getKeys();
FeatureDescriptor feat;
String key;
while (e.hasMoreElements()) {
key = e.nextElement();
feat = new FeatureDescriptor();
feat.setDisplayName(key);
feat.setShortDescription("");
feat.setExpert(false);
feat.setHidden(false);
feat.setName(key);
feat.setPreferred(true);
feat.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
feat.setValue(TYPE, String.class);
feats.add(feat);
}
return feats.iterator();
}
return null;
}
use of java.beans.FeatureDescriptor in project tomcat by apache.
the class TestResourceBundleELResolver method testGetFeatureDescriptors02.
/**
* 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));
}
}
Aggregations