本文整理汇总了Java中java.beans.PropertyEditorManager类的典型用法代码示例。如果您正苦于以下问题:Java PropertyEditorManager类的具体用法?Java PropertyEditorManager怎么用?Java PropertyEditorManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PropertyEditorManager类属于java.beans包,在下文中一共展示了PropertyEditorManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findThePropertyEditor
import java.beans.PropertyEditorManager; //导入依赖的package包/类
private static PropertyEditor findThePropertyEditor(Class clazz) {
PropertyEditor pe;
if (Object.class.equals(clazz)) {
pe = null;
} else {
pe = PropertyEditorManager.findEditor(clazz);
if (pe == null) {
Class sclazz = clazz.getSuperclass();
if (sclazz != null) {
pe = findPropertyEditor(sclazz);
}
}
}
classesWithPE.put(clazz, pe != null);
return pe;
}
示例2: fontButtonActionPerformed
import java.beans.PropertyEditorManager; //导入依赖的package包/类
private void fontButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fontButtonActionPerformed
PropertyEditor pe = PropertyEditorManager.findEditor(Font.class);
if (pe != null) {
pe.setValue(termOptions.getFont());
DialogDescriptor dd = new DialogDescriptor(pe.getCustomEditor(), FontChooser_title());
String defaultFontString = FontChooser_defaultFont_label();
dd.setOptions(new Object[]{DialogDescriptor.OK_OPTION,
defaultFontString, DialogDescriptor.CANCEL_OPTION}); //NOI18N
DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
if (dd.getValue() == DialogDescriptor.OK_OPTION) {
Font f = (Font) pe.getValue();
termOptions.setFont(f);
applyTermOptions();
} else if (dd.getValue() == defaultFontString) {
Font controlFont = UIManager.getFont("controlFont"); //NOI18N
int fontSize = (controlFont == null) ? 12 : controlFont.getSize();
termOptions.setFont(new Font("monospaced", Font.PLAIN, fontSize)); //NOI18N
}
}
}
示例3: testPackageUnregistering
import java.beans.PropertyEditorManager; //导入依赖的package包/类
public void testPackageUnregistering() {
MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test1.pkg"));
NodeOp.registerPropertyEditors();
MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test2.pkg"));
String[] editorSearchPath = PropertyEditorManager.getEditorSearchPath();
int count = 0;
for (int i = 0; i < editorSearchPath.length; i++) {
assertNotSame("test1.pkg", editorSearchPath[i]);
if ("test2.pkg".equals(editorSearchPath[i])) {
count++;
}
}
assertEquals(1, count);
}
示例4: btnSelectFontActionPerformed
import java.beans.PropertyEditorManager; //导入依赖的package包/类
private void btnSelectFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectFontActionPerformed
PropertyEditor pe = PropertyEditorManager.findEditor(Font.class);
if (pe != null) {
pe.setValue(outputOptions.getFont());
DialogDescriptor dd = new DialogDescriptor(pe.getCustomEditor(),
NbBundle.getMessage(Controller.class,
"LBL_Font_Chooser_Title")); //NOI18N
String defaultFont = NbBundle.getMessage(Controller.class,
"BTN_Defaul_Font"); //NOI18N
dd.setOptions(new Object[]{DialogDescriptor.OK_OPTION,
defaultFont, DialogDescriptor.CANCEL_OPTION}); //NOI18N
DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
if (dd.getValue() == DialogDescriptor.OK_OPTION) {
Font f = (Font) pe.getValue();
outputOptions.setFont(f);
} else if (dd.getValue() == defaultFont) {
outputOptions.setFont(null);
}
updateFontField();
}
}
示例5: getProperty
import java.beans.PropertyEditorManager; //导入依赖的package包/类
public static Property getProperty(Field field, Object object) {
// access also protected and private fields
field.setAccessible(true);
// Properties are only primitive types marked by Prop annotation
if (field.isAnnotationPresent(JProp.class)) {
// We require that class of the field to be loaded, because we often specify
// the PropertyEditor there in static block.
forceInitialization(field.getType());
//TODO this condition should be used on client when deciding whether to show an editor for it
if (PropertyEditorManager.findEditor(field.getType()) != null) {
// add the property
return new JavaProperty(object, field);
}
}
return null;
}
示例6: findCustomEditor
import java.beans.PropertyEditorManager; //导入依赖的package包/类
/**
* @param requiredType
* @param propertyPath
* @return
*/
public PropertyEditor findCustomEditor ( final Class<?> requiredType, final String propertyPath )
{
// first try to find exact match
String key = requiredType.getCanonicalName () + ":" + propertyPath;
PropertyEditor pe = this.propertyEditors.get ( key );
// 2nd: try to find for class only
if ( pe == null )
{
key = requiredType.getCanonicalName () + ":";
pe = this.propertyEditors.get ( key );
}
// 3rd: try to get internal
if ( pe == null )
{
pe = PropertyEditorManager.findEditor ( requiredType );
}
return pe;
}
示例7: getValueFromPropertyEditorManager
import java.beans.PropertyEditorManager; //导入依赖的package包/类
public static Object getValueFromPropertyEditorManager(
Class<?> attrClass, String attrName, String attrValue)
throws JasperException
{
try {
PropertyEditor propEditor =
PropertyEditorManager.findEditor(attrClass);
if (propEditor != null) {
propEditor.setAsText(attrValue);
return propEditor.getValue();
} else {
throw new IllegalArgumentException(
Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
}
} catch (IllegalArgumentException ex) {
throw new JasperException(
Localizer.getMessage("jsp.error.beans.property.conversion",
attrValue, attrClass.getName(), attrName,
ex.getMessage()));
}
}
示例8: getValueFromPropertyEditorManager
import java.beans.PropertyEditorManager; //导入依赖的package包/类
public static Object getValueFromPropertyEditorManager(
Class attrClass, String attrName, String attrValue)
throws JasperException
{
try {
PropertyEditor propEditor =
PropertyEditorManager.findEditor(attrClass);
if (propEditor != null) {
propEditor.setAsText(attrValue);
return propEditor.getValue();
} else {
throw new IllegalArgumentException(
Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
}
} catch (IllegalArgumentException ex) {
throw new JasperException(
Localizer.getMessage("jsp.error.beans.property.conversion",
attrValue, attrClass.getName(), attrName,
ex.getMessage()));
}
}
示例9: show
import java.beans.PropertyEditorManager; //导入依赖的package包/类
public static Font show(Font initialFont) {
PropertyEditor pe = PropertyEditorManager.findEditor(Font.class);
if (pe == null) {
throw new RuntimeException("Could not find font editor component.");
}
pe.setValue(initialFont);
DialogDescriptor dd = new DialogDescriptor(
pe.getCustomEditor(),
"Choose Font");
DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
if (dd.getValue() == DialogDescriptor.OK_OPTION) {
Font f = (Font)pe.getValue();
return f;
}
return initialFont;
}
示例10: test
import java.beans.PropertyEditorManager; //导入依赖的package包/类
private static void test(String[] path) {
try {
Beans.setDesignTime(true);
Beans.setGuiAvailable(true);
Introspector.setBeanInfoSearchPath(path);
PropertyEditorManager.setEditorSearchPath(path);
} catch (SecurityException exception) {
throw new Error("unexpected security exception", exception);
}
}
示例11: run
import java.beans.PropertyEditorManager; //导入依赖的package包/类
public void run() {
try {
Thread.sleep(this.time); // increase the chance of the deadlock
if (this.sync) {
synchronized (Test6963811.class) {
PropertyEditorManager.findEditor(Super.class);
}
}
else {
PropertyEditorManager.findEditor(Sub.class);
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}
示例12: getValueFromPropertyEditorManager
import java.beans.PropertyEditorManager; //导入依赖的package包/类
public static Object getValueFromPropertyEditorManager(Class<?> attrClass, String attrName, String attrValue)
throws JasperException {
try {
PropertyEditor propEditor = PropertyEditorManager.findEditor(attrClass);
if (propEditor != null) {
propEditor.setAsText(attrValue);
return propEditor.getValue();
} else {
throw new IllegalArgumentException(
Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
}
} catch (IllegalArgumentException ex) {
throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue,
attrClass.getName(), attrName, ex.getMessage()));
}
}
示例13: getValueFromPropertyEditorManager
import java.beans.PropertyEditorManager; //导入依赖的package包/类
public static Object getValueFromPropertyEditorManager(
Class<?> attrClass, String attrName, String attrValue)
throws JasperException
{
try {
PropertyEditor propEditor =
PropertyEditorManager.findEditor(attrClass);
if (propEditor != null) {
propEditor.setAsText(attrValue);
return propEditor.getValue();
} else {
throw new IllegalArgumentException(
Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
}
} catch (IllegalArgumentException ex) {
throw new JasperException(
Localizer.getMessage("jsp.error.beans.property.conversion",
attrValue, attrClass.getName(), attrName,
ex.getMessage()));
}
}
示例14: findEditor
import java.beans.PropertyEditorManager; //导入依赖的package包/类
/**
* Retrieve an editor object for a given class.
* This method seems unable to retrieve a primitive editor for obscure reasons.
* So better use the one based on PropertyDescriptor if possible.
*/
public static PropertyEditor findEditor(Class<?> cls) {
PropertyEditor editor = PropertyEditorManager.findEditor(cls);
// Try to unwrap primitives
if (editor == null && Primitives.isWrapperType(cls)) {
editor = PropertyEditorManager.findEditor(Primitives.unwrap(cls));
}
if ((editor == null) && useDefaultGOE) {
if (cls.isArray()) {
Class<?> unwrapped = Primitives.isWrapperType(cls.getComponentType()) ? Primitives.unwrap(cls.getComponentType()) : cls;
if (unwrapped.isPrimitive()) {
editor = new ArrayEditor();
} else {
editor = new ObjectArrayEditor<>(unwrapped.getComponentType());
}
} else if (cls.isEnum()) {
editor = new EnumEditor();
} else {
editor = new GenericObjectEditor();
((GenericObjectEditor)editor).setClassType(cls);
}
}
return editor;
}
示例15: load
import java.beans.PropertyEditorManager; //导入依赖的package包/类
/**
* Load values from the LocaleOption
*/
void load() {
final LocaleOption localeOption = LocaleOption.getDefault();
final String[] datePatternsList = localeOption.getDatePatternList();
this.datePatternsPE = PropertyEditorManager.findEditor(String[].class);
this.datePatternsPE.setValue( datePatternsList );
final String[] messagePatternsList = localeOption.getMessagePatternList();
this.messagePatternsPE = PropertyEditorManager.findEditor(String[].class);
this.messagePatternsPE.setValue( messagePatternsList );
final String[] numberPatternsList = localeOption.getNumberPatternList();
this.numberPatternsPE = PropertyEditorManager.findEditor(String[].class);
this.numberPatternsPE.setValue( numberPatternsList );
//---
this.datePatternsTextField.setText( this.datePatternsPE.getAsText() );
this.messagePatternsTextField.setText( this.messagePatternsPE.getAsText() );
this.numberPatternsTextField.setText( this.numberPatternsPE.getAsText() );
this.dateParseFormattedTextField.setValue( localeOption.getMessageArgDatePattern() );
this.numberParseFormattedTextField.setValue( localeOption.getMessageArgNumberPattern() );
}