| 1 24 package org.riotfamily.components.property; 25 26 import java.beans.PropertyEditor ; 27 28 32 public class PropertyEditorProcessor extends AbstractSinglePropertyProcessor { 33 34 private PropertyEditor propertyEditor; 35 36 private String defaultValue; 37 38 public PropertyEditorProcessor() { 39 } 40 41 public PropertyEditorProcessor(String property, 42 PropertyEditor propertyEditor) { 43 44 this(property, propertyEditor, null); 45 } 46 47 public PropertyEditorProcessor(String property, 48 PropertyEditor propertyEditor, String defaultValue) { 49 50 this.propertyEditor = propertyEditor; 51 setProperty(property); 52 setDefaultValue(defaultValue); 53 } 54 55 public void setPropertyEditor(PropertyEditor propertyEditor) { 56 this.propertyEditor = propertyEditor; 57 } 58 59 public void setDefaultValue(String defaultValue) { 60 this.defaultValue = defaultValue; 61 } 62 63 public synchronized Object resolveString(String value) { 64 if (value == null) { 65 value = defaultValue; 66 } 67 if (value == null) { 68 return null; 69 } 70 propertyEditor.setAsText(value); 71 return propertyEditor.getValue(); 72 } 73 74 public synchronized String convertToString(Object object) { 75 if (object == null) { 76 return null; 77 } 78 propertyEditor.setValue(object); 79 return propertyEditor.getAsText(); 80 } 81 82 public String copy(String value) { 83 return value; 84 } 85 86 public void delete(String value) { 87 } 88 89 } 90 | Popular Tags |