final String defaultPreviewText = LanguageManager.get ( "weblaf.ex.npeditor.preview.text" );
final String previewText = SettingsManager.get ( "NinePatchEditor", "preview.text", defaultPreviewText );
preview.setText ( st ? parseToMultilineHtml ( previewText ) : "" );
final WebTextField textField = new WebTextField ( 8 );
textField.setText ( previewText );
textField.setHorizontalAlignment ( WebTextField.CENTER );
textField.setDrawFocus ( false );
textField.setEditable ( st );
textField.setMargin ( -1 );
textField.addCaretListener ( new CaretListener ()
{
@Override
public void caretUpdate ( final CaretEvent e )
{
SettingsManager.set ( "NinePatchEditor", "preview.text", textField.getText () );
preview.setText ( showText.isSelected () ? parseToMultilineHtml ( textField.getText () ) : "" );
}
} );
showText.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
final boolean show = showText.isSelected ();
SettingsManager.set ( "NinePatchEditor", "preview.showText", show );
textField.setEditable ( show );
preview.setText ( show ? parseToMultilineHtml ( textField.getText () ) : "" );
}
} );
textField.setLeadingComponent ( showText );
toolBar.addFill ( textField );
final WebButton chooseColor = new WebButton ( FOREGROUND_COLOR_ICON );
chooseColor.setLanguage ( "weblaf.ex.npeditor.preview.foregroundColor" );
preview.setForeground ( SettingsManager.get ( "NinePatchEditor", "preview.foregroundColor", Color.WHITE ) );
chooseColor.setCursor ( Cursor.getDefaultCursor () );
chooseColor.setDrawFocus ( false );
chooseColor.setRolloverDecoratedOnly ( true );
chooseColor.setRolloverDarkBorderOnly ( false );
chooseColor.setDrawLeft ( false );
chooseColor.setDrawLeftLine ( true );
chooseColor.setShadeWidth ( 0 );
chooseColor.addActionListener ( new ActionListener ()
{
private WebColorChooserDialog webColorChooser = null;
@Override
public void actionPerformed ( final ActionEvent e )
{
if ( webColorChooser == null )
{
webColorChooser = new WebColorChooserDialog ( SwingUtils.getWindowAncestor ( previewPanel ) );
}
webColorChooser.setColor ( preview.getForeground () );
if ( webColorChooser.showDialog () == DialogOptions.OK_OPTION )
{
final Color color = webColorChooser.getColor ();
SettingsManager.set ( "NinePatchEditor", "preview.foregroundColor", color );
preview.setForeground ( color );
}
}
} );
textField.setTrailingComponent ( chooseColor );
abp = new AlphaLayerPainter ();
final boolean da = SettingsManager.get ( "NinePatchEditor", "preview.transparentBackground", true );
final WebToggleButton drawAlphaBackground = new WebToggleButton ( TRANSPARENT_ICON );