public BoxSizingPropertyEditor() { propertyChangeSupport = new PropertyChangeSupport( this ); valueConverter = new BoxSizingValueConverter(); }
/** * Gets the property value as text. * * @return The property value as a human editable string. * <p> * Returns null if the value can't be expressed as an editable string. * <p> * If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in * setAsText(). */ public String getAsText() { if ( value == null ) { return null; } try { return valueConverter.toAttributeValue( value ); } catch ( BeanException e ) { return null; } }
/** * Set the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String * is badly formatted or if this kind of property can't be expressed as text. * * @param text * The string to be parsed. */ public void setAsText( final String text ) throws IllegalArgumentException { if ( StringUtils.isEmpty( text ) ) { setValue( null ); return; } try { setValue( valueConverter.toPropertyValue( text ) ); } catch ( BeanException e ) { throw new IllegalArgumentException( "This is not a valid property-value" ); } }
registeredClasses.put( WhitespaceCollapse.class, new WhitespaceCollapseValueConverter() ); registeredClasses.put( VerticalTextAlign.class, new VerticalTextAlignValueConverter() ); registeredClasses.put( BoxSizing.class, new BoxSizingValueConverter() ); registeredClasses.put( BorderStyle.class, new BorderStyleValueConverter() ); registeredClasses.put( FontSmooth.class, new FontSmoothValueConverter() );