本文整理汇总了Java中java.beans.PropertyEditor类的典型用法代码示例。如果您正苦于以下问题:Java PropertyEditor类的具体用法?Java PropertyEditor怎么用?Java PropertyEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PropertyEditor类属于java.beans包,在下文中一共展示了PropertyEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commitChanges
import java.beans.PropertyEditor; //导入依赖的package包/类
/**
* Used by PropertyAction to mimic property sheet behavior - trying to invoke
* PropertyEnv listener of the current property editor (we can't create our
* own PropertyEnv instance).
*
* @return current value
* @throws java.beans.PropertyVetoException if someone vetoes this change.
*/
public Object commitChanges() throws PropertyVetoException {
int currentIndex = editorsCombo.getSelectedIndex();
PropertyEditor currentEditor = currentIndex > -1 ? allEditors[currentIndex] : null;
if (currentEditor instanceof ExPropertyEditor) {
// we can only guess - according to the typical pattern the propetry
// editor itself or the custom editor usually implement the listener
// registered in PropertyEnv
PropertyChangeEvent evt = new PropertyChangeEvent(
this, PropertyEnv.PROP_STATE, null, PropertyEnv.STATE_VALID);
if (currentEditor instanceof VetoableChangeListener) {
((VetoableChangeListener)currentEditor).vetoableChange(evt);
}
Component currentCustEd = currentIndex > -1 ? allCustomEditors[currentIndex] : null;
if (currentCustEd instanceof VetoableChangeListener) {
((VetoableChangeListener)currentCustEd).vetoableChange(evt);
}
if (currentEditor instanceof PropertyChangeListener) {
((PropertyChangeListener)currentEditor).propertyChange(evt);
}
if (currentCustEd instanceof PropertyChangeListener) {
((PropertyChangeListener)currentCustEd).propertyChange(evt);
}
}
return commitChanges0();
}
示例2: createEditors
import java.beans.PropertyEditor; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void createEditors(Properties configuration) {
boolean trace = log.isTraceEnabled();
// load properties using this class class loader
ClassLoader classLoader = getClass().getClassLoader();
for (Map.Entry<Object, Object> entry : configuration.entrySet()) {
// key represents type
Class<?> key;
// value represents property editor
Class<?> editorClass;
try {
key = classLoader.loadClass((String) entry.getKey());
editorClass = classLoader.loadClass((String) entry.getValue());
} catch (ClassNotFoundException ex) {
throw (RuntimeException) new IllegalArgumentException("Cannot load class").initCause(ex);
}
Assert.isAssignable(PropertyEditor.class, editorClass);
if (trace)
log.trace("Adding property editor[" + editorClass + "] for type[" + key + "]");
editors.put(key, (Class<? extends PropertyEditor>) editorClass);
}
}
示例3: show
import java.beans.PropertyEditor; //导入依赖的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;
}
示例4: findThePropertyEditor
import java.beans.PropertyEditor; //导入依赖的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;
}
示例5: setValueWithMirror
import java.beans.PropertyEditor; //导入依赖的package包/类
boolean setValueWithMirror(Object value, Object valueMirror) {
this.currentValue = value;
Class clazz = valueMirror.getClass();
PropertyEditor propertyEditor = findPropertyEditor(clazz);
propertyEditor = testPropertyEditorOnValue(propertyEditor, valueMirror);
if (propertyEditor == null) {
return false;
}
boolean doAttach = false;
mirrorClass = clazz;
delegatePropertyEditor = propertyEditor;
if (env != null && propertyEditor instanceof ExPropertyEditor) {
doAttach = true;
}
delegateValue = valueMirror;
delegatePropertyEditor.setValue(valueMirror);
if (doAttach) {
((ExPropertyEditor) delegatePropertyEditor).attachEnv(env);
}
return doAttach;
}
示例6: getPropertyEditor
import java.beans.PropertyEditor; //导入依赖的package包/类
@Override
public PropertyEditor getPropertyEditor() {
return new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (text instanceof String) {
try {
entry.setMessage(!text.equals("") ? text : null);
} catch (IOException ex) {
History.LOG.log(Level.WARNING, null, ex);
}
return;
}
throw new java.lang.IllegalArgumentException(text);
}
@Override
public String getAsText() {
return te.getDisplayValue();
}
};
}
示例7: setRadioButtonMax
import java.beans.PropertyEditor; //导入依赖的package包/类
public void setRadioButtonMax(int i) {
if (i != radioButtonMax) {
Dimension oldPreferredSize = null;
if (isShowing()) {
oldPreferredSize = getPreferredSize();
}
int old = radioButtonMax;
radioButtonMax = i;
if (oldPreferredSize != null) {
//see if the change will affect anything
PropertyEditor ed = PropUtils.getPropertyEditor(prop);
String[] tags = ed.getTags();
if (tags != null) {
if ((tags.length >= i) != (tags.length >= old)) {
firePropertyChange("preferredSize", oldPreferredSize, getPreferredSize()); //NOI18N
}
}
}
}
}
示例8: actionPerformed
import java.beans.PropertyEditor; //导入依赖的package包/类
@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
}
}
示例9: getValueFromBeanInfoPropertyEditor
import java.beans.PropertyEditor; //导入依赖的package包/类
public static Object getValueFromBeanInfoPropertyEditor(
Class attrClass, String attrName, String attrValue,
Class propertyEditorClass)
throws JasperException
{
try {
PropertyEditor pe = (PropertyEditor)propertyEditorClass.newInstance();
pe.setAsText(attrValue);
return pe.getValue();
} catch (Exception ex) {
throw new JasperException(
Localizer.getMessage("jsp.error.beans.property.conversion",
attrValue, attrClass.getName(), attrName,
ex.getMessage()));
}
}
示例10: getPropertyEditor
import java.beans.PropertyEditor; //导入依赖的package包/类
PropertyEditor getPropertyEditor() { //package private for unit tests
PropertyEditor result;
if (editor != null) {
return editor;
}
if (getInplaceEditor() != null) {
result = getInplaceEditor().getPropertyEditor();
} else {
result = PropUtils.getPropertyEditor(getProperty());
}
editor = result;
return result;
}
示例11: getPropertyEditor
import java.beans.PropertyEditor; //导入依赖的package包/类
private PropertyEditor getPropertyEditor(Class<?> requiredType) {
// Special case: If no required type specified, which usually only happens for
// Collection elements, or required type is not assignable to registered type,
// which usually only happens for generic properties of type Object -
// then return PropertyEditor if not registered for Collection or array type.
// (If not registered for Collection or array, it is assumed to be intended
// for elements.)
if (this.registeredType == null ||
(requiredType != null &&
(ClassUtils.isAssignable(this.registeredType, requiredType) ||
ClassUtils.isAssignable(requiredType, this.registeredType))) ||
(requiredType == null &&
(!Collection.class.isAssignableFrom(this.registeredType) && !this.registeredType.isArray()))) {
return this.propertyEditor;
}
else {
return null;
}
}
示例12: getPropertyEditor
import java.beans.PropertyEditor; //导入依赖的package包/类
public PropertyEditor getPropertyEditor() {
if (mdl.getPropertyEditorClass() != null) {
try {
//System.err.println("ModelProperty creating a "
//+ mdl.getPropertyEditorClass());
Constructor c = mdl.getPropertyEditorClass().getConstructor();
c.setAccessible(true);
return (PropertyEditor) c.newInstance(new Object[0]);
} catch (Exception e) {
Exceptions.printStackTrace(e);
return new PropUtils.NoPropertyEditorEditor();
}
}
return super.getPropertyEditor();
}
示例13: findCustomEditor
import java.beans.PropertyEditor; //导入依赖的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;
}
示例14: getValueFromPropertyEditorManager
import java.beans.PropertyEditor; //导入依赖的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()));
}
}
示例15: getPropertyEditor
import java.beans.PropertyEditor; //导入依赖的package包/类
@Override
public PropertyEditor getPropertyEditor() {
if (editor == null) {
editor = super.getPropertyEditor();
}
return editor;
}