public Color[] getColors() { return ColorUtility.getPredefinedExcelColors(); }
public String getAsText() { return ColorUtility.toAttributeValue( value ); }
final Color item; if ( value instanceof String ) { item = (Color) ColorUtility.toPropertyValue( (String) value ); } else { item = (Color) value; this.color = item; setBackground( item ); setText( ColorUtility.toAttributeValue( item ) ); return this;
public void load( final Properties p ) { name = p.getProperty( "name" ); if ( name == null ) { name = "<unnamed>"; } colors.clear(); for ( int i = 0; ; i++ ) { final String colorText = p.getProperty( "color." + i ); if ( StringUtils.isEmpty( colorText ) ) { break; } try { colors.add( ColorUtility.toPropertyValue( colorText ) ); } catch ( Exception e ) { break; } } }
public void setAsText( final String text ) throws IllegalArgumentException { try { setValue( ColorUtility.toPropertyValue( text ) ); } catch ( IllegalArgumentException e ) { // ignored exception setValue( null ); } }
public void save( final Properties p ) { p.setProperty( "name", name ); final Color[] colorsArray = getColors(); for ( int i = 0; i < colorsArray.length; i++ ) { final Color color = colorsArray[ i ]; p.setProperty( "color." + i, ColorUtility.toAttributeValue( color ) ); } }
public void load( final Configuration p, final String prefix ) { name = p.getConfigProperty( prefix + ".name" ); if ( name == null ) { name = "<unnamed>"; } colors.clear(); for ( int i = 0; ; i++ ) { final String colorText = p.getConfigProperty( prefix + ".color." + i ); if ( StringUtils.isEmpty( colorText ) ) { break; } try { colors.add( ColorUtility.toPropertyValue( colorText ) ); } catch ( Exception e ) { break; } } }
private Object[] getSelection( final Class arrayType, final Class propertyEditorType ) { if ( String[].class.equals( arrayType ) ) { if ( propertyEditorType != null && PropertyEditor.class.isAssignableFrom( propertyEditorType ) ) { try { final PropertyEditor editor = (PropertyEditor) propertyEditorType.newInstance(); return editor.getTags(); } catch ( Throwable e ) { logger.error( "Unable to instantiate property editor.", e );// NON-NLS } } } else if ( Color[].class.equals( arrayType ) ) { return ColorUtility.getPredefinedExcelColors(); } return null; }
this.color = item; setBackground( item ); setText( ColorUtility.toAttributeValue( item ) ); return this;
/** * Creates a new color combobox and populates it with the excel colors. */ public ColorComboBox() { final DefaultComboBoxModel model = new DefaultComboBoxModel( ColorUtility.getPredefinedExcelColors() ); model.insertElementAt( null, 0 ); model.setSelectedItem( null ); setModel( model ); setRenderer( new ColorCellRenderer() ); final int height1 = getPreferredSize().height; setMaximumSize( new Dimension( height1 * 4, height1 ) ); setFocusable( false ); setEditable( false ); }