use of java.beans.BeanDescriptor in project ACS by ACS-Community.
the class AcceptorBeanBeanInfo method getBeanDescriptorLazy.
protected BeanDescriptor getBeanDescriptorLazy() {
BeanDescriptor bd = new BeanDescriptor(AcceptorBean.class);
BeanTagger.addActions(bd, new String[] { "cern.gp.actions.AcceptAction" });
return bd;
}
use of java.beans.BeanDescriptor in project ACS by ACS-Community.
the class BeanTagger method addActions.
/**
* Adds classes of available actions to this BeanInfo. If the BeanInfo already
* defines some actions the existing ones and the new ones are merged together.
* @param actionClasses an array of the class of available action(s)
*/
public static void addActions(BeanInfo beanInfo, String[] actions) {
BeanDescriptor descriptor = beanInfo.getBeanDescriptor();
if (descriptor == null)
return;
addActions(descriptor, actions);
}
use of java.beans.BeanDescriptor in project jmeter by apache.
the class TestBeanGUI method getMenuCategories.
/** {@inheritDoc} */
@Override
public Collection<String> getMenuCategories() {
List<String> menuCategories = new LinkedList<>();
BeanDescriptor bd = beanInfo.getBeanDescriptor();
// in expert mode:
if (bd.isExpert() && !JMeterUtils.isExpertMode()) {
return null;
}
int matches = setupGuiClasses(menuCategories);
if (matches == 0) {
log.error("Could not assign GUI class to {}", testBeanClass);
} else if (matches > 1) {
// may be impossible, but no harm in
// checking ...
log.error("More than 1 GUI class found for {}", testBeanClass);
}
return menuCategories;
}
use of java.beans.BeanDescriptor in project jmeter by apache.
the class TestBeanGUI method setupGuiClasses.
/**
* Setup GUI class
* @param menuCategories List<String> menu categories
* @return number of matches
*/
private int setupGuiClasses(List<String> menuCategories) {
// How many classes can we assign from?
int matches = 0;
// TODO: there must be a nicer way...
BeanDescriptor bd = beanInfo.getBeanDescriptor();
if (Assertion.class.isAssignableFrom(testBeanClass)) {
menuCategories.add(MenuFactory.ASSERTIONS);
bd.setValue(TestElement.GUI_CLASS, AbstractAssertionGui.class.getName());
matches++;
}
if (ConfigElement.class.isAssignableFrom(testBeanClass)) {
menuCategories.add(MenuFactory.CONFIG_ELEMENTS);
bd.setValue(TestElement.GUI_CLASS, AbstractConfigGui.class.getName());
matches++;
}
if (Controller.class.isAssignableFrom(testBeanClass)) {
menuCategories.add(MenuFactory.CONTROLLERS);
bd.setValue(TestElement.GUI_CLASS, AbstractControllerGui.class.getName());
matches++;
}
if (Visualizer.class.isAssignableFrom(testBeanClass)) {
menuCategories.add(MenuFactory.LISTENERS);
bd.setValue(TestElement.GUI_CLASS, AbstractVisualizer.class.getName());
matches++;
}
if (PostProcessor.class.isAssignableFrom(testBeanClass)) {
menuCategories.add(MenuFactory.POST_PROCESSORS);
bd.setValue(TestElement.GUI_CLASS, AbstractPostProcessorGui.class.getName());
matches++;
}
if (PreProcessor.class.isAssignableFrom(testBeanClass)) {
menuCategories.add(MenuFactory.PRE_PROCESSORS);
bd.setValue(TestElement.GUI_CLASS, AbstractPreProcessorGui.class.getName());
matches++;
}
if (Sampler.class.isAssignableFrom(testBeanClass)) {
menuCategories.add(MenuFactory.SAMPLERS);
bd.setValue(TestElement.GUI_CLASS, AbstractSamplerGui.class.getName());
matches++;
}
if (Timer.class.isAssignableFrom(testBeanClass)) {
menuCategories.add(MenuFactory.TIMERS);
bd.setValue(TestElement.GUI_CLASS, AbstractTimerGui.class.getName());
matches++;
}
return matches;
}
use of java.beans.BeanDescriptor in project jdk8u_jdk by JetBrains.
the class GenSwingBeanInfo method genBeanInfo.
/**
* Generates the BeanInfo source file using instrospection and a
* Hashtable full of hints. This the only public method in this class.
*
* @param classname Root name of the class. i.e., JButton
* @param dochash A hashtable containing the DocBeanInfo.
*/
public void genBeanInfo(String packageName, String classname, Hashtable dochash) {
// The following initial values are just examples. All of these
// fields are initialized below.
String beanClassName = "JInternalFrame";
String beanClassObject = "javax.swing.JInternalFrame.class";
String beanDescription = "<A description of this component>.";
String beanPropertyDescriptors = "<createSwingPropertyDescriptor code>";
String classPropertyDescriptors = "<createSwingClassPropertyDescriptor code>";
Class cls = getClass(packageName, classname);
if (cls == null) {
messageAndExit("Can't find class: " + classname);
}
// Get the output stream.
PrintStream out = initOutputFile(classname);
// Run the Introspector and initialize the variables
BeanInfo beanInfo = null;
BeanDescriptor beanDescriptor = null;
try {
if (cls == javax.swing.JComponent.class) {
// Go all the way up the heirarchy for JComponent
beanInfo = Introspector.getBeanInfo(cls);
} else {
beanInfo = Introspector.getBeanInfo(cls, cls.getSuperclass());
}
beanDescriptor = beanInfo.getBeanDescriptor();
beanDescription = beanDescriptor.getShortDescription();
} catch (IntrospectionException e) {
messageAndExit("Introspection failed for " + cls.getName() + " " + e);
}
beanClassName = beanDescriptor.getName();
beanClassObject = cls.getName() + ".class";
if (DEBUG) {
System.out.println(">>>>GenSwingBeanInfo class: " + beanClassName);
}
// Generate the Class BeanDescriptor information first
if (dochash.size() > 0) {
if (dochash.containsKey(beanClassName)) {
DocBeanInfo dbi = (DocBeanInfo) dochash.remove(beanClassName);
classPropertyDescriptors = genBeanDescriptor(dbi);
if (DEBUG)
System.out.println("ClassPropertyDescriptors: " + classPropertyDescriptors);
if (!(dbi.desc.equals("null")))
beanDescription = dbi.desc;
} else
beanDescription = beanDescriptor.getShortDescription();
} else
beanDescription = beanDescriptor.getShortDescription();
// Generate the Property descriptors
beanPropertyDescriptors = genPropertyDescriptors(beanInfo, dochash);
// Dump the template to out, substituting values for
// @(token) tokens as they're encountered.
int currentIndex = 0;
// not loading this to get around build issue for now
String template = loadTemplate();
// current class.
while (currentIndex < template.length()) {
// Find the Token
int tokenStart = template.indexOf("@(", currentIndex);
if (tokenStart != -1) {
out.print(template.substring(currentIndex, tokenStart));
int tokenEnd = template.indexOf(")", tokenStart);
if (tokenEnd == -1) {
messageAndExit("Bad @(<token>) beginning at " + tokenStart);
}
String token = template.substring(tokenStart + 2, tokenEnd);
if (token.equals(TOK_BEANCLASS)) {
out.print(beanClassName);
} else if (token.equals(TOK_CLASSDESC)) {
if (!(classPropertyDescriptors.equals("<createSwingClassPropertyDescriptor code>"))) {
printDescriptors(out, classPropertyDescriptors, template, tokenStart);
}
} else if (token.equals(TOK_BEANPACKAGE)) {
out.print(packageName);
} else if (token.equals(TOK_BEANOBJECT)) {
out.print(beanClassObject);
} else if (token.equals(TOK_BEANDESC)) {
out.print(beanDescription);
} else if (token.equals(TOK_ENUMVARS)) {
out.print(enumcode);
} else if (token.equals(TOK_PROPDESC)) {
printDescriptors(out, beanPropertyDescriptors, template, tokenStart);
} else if (token.equals("#")) {
// Ignore the @(#) Version Control tag if it exists.
} else {
messageAndExit("Unrecognized token @(" + token + ")");
}
currentIndex = tokenEnd + 1;
} else {
// tokenStart == -1 - We are finsihed.
out.print(template.substring(currentIndex, template.length()));
break;
}
}
out.close();
}
Aggregations