final Rectangle wb =
source.getUI ().modelToView ( source, ( content.getBegin () + content.getEnd () ) / 2 );
typeChooser.show ( source, wb.x, wb.y, wb.width, wb.height, PopOverDirection.down );
return new HyperlinkEvent ( this, HyperlinkEvent.EventType.EXITED, null );
}
catch ( final BadLocationException e )
{
Log.error ( this, e );
return null;
}
}
@Override
public int getSourceOffset ()
{
return content.getBegin ();
}
};
}
}
}
}
else if ( propertyNodes.contains ( parentName ) )
{
final Segment content = element.getContent ();
final String contentString = content.toString ();
if ( booleanContent.contains ( contentString ) )
{
return new LinkGeneratorResult ()
{
@Override
public HyperlinkEvent execute ()
{
source.replaceRange ( contentString.equals ( trueString ) ? falseString : trueString, content.getBegin (),
content.getEnd () );
return new HyperlinkEvent ( this, HyperlinkEvent.EventType.EXITED, null );
}
@Override
public int getSourceOffset ()
{
return content.getBegin ();
}
};
}
else
{
if ( CompareUtils.contains ( name.toLowerCase (), colorContent ) )
{
final Color color = ( Color ) colorConverter.fromString ( contentString );
if ( color != null || contentString.equals ( ColorConverter.NULL_COLOR ) )
{
return new LinkGeneratorResult ()
{
@Override
public HyperlinkEvent execute ()
{
try
{
final WebPopOver colorChooser = new WebPopOver ( parentComponent );
colorChooser.setCloseOnFocusLoss ( true );
colorChooser.setStyleId ( "editor-pop-over" );
final WebColorChooserPanel colorChooserPanel = new WebColorChooserPanel ( false );
colorChooserPanel.setColor ( color != null ? color : Color.WHITE );
colorChooserPanel.addChangeListener ( new ChangeListener ()
{
private int length = content.getEnd () - content.getBegin ();
@Override
public void stateChanged ( final ChangeEvent e )
{
final Color newColor = colorChooserPanel.getColor ();
if ( color == null || newColor != null && !newColor.equals ( color ) )
{
final String colorString = colorConverter.toString ( newColor );
source.replaceRange ( colorString, content.getBegin (), content.getBegin () + length );
length = colorString.length ();
}
}
} );
colorChooser.add ( colorChooserPanel );
final Rectangle wb =
source.getUI ().modelToView ( source, ( content.getBegin () + content.getEnd () ) / 2 );
colorChooser.show ( source, wb.x, wb.y, wb.width, wb.height, PopOverDirection.down );
return new HyperlinkEvent ( this, HyperlinkEvent.EventType.EXITED, null );
}
catch ( final BadLocationException e )
{
Log.error ( this, e );
return null;
}
}
@Override
public int getSourceOffset ()
{
return content.getBegin ();
}
};
}
}
else if ( CompareUtils.contains ( name.toLowerCase (), transparencyContent ) )
{
final Float f = ( Float ) floatConverter.fromString ( contentString );
if ( f != null )
{
return new LinkGeneratorResult ()
{
@Override
public HyperlinkEvent execute ()
{
try
{
final WebPopOver transparencyChooser = new WebPopOver ( parentComponent );
transparencyChooser.setCloseOnFocusLoss ( true );
transparencyChooser.setStyleId ( "editor-pop-over" );
final int value = MathUtils.limit ( Math.round ( 1000 * f ), 0, 1000 );
final WebSlider slider = new WebSlider ( WebSlider.HORIZONTAL, 0, 1000, value );
slider.setPaintTicks ( true );
slider.setMajorTickSpacing ( 50 );
slider.setMinorTickSpacing ( 10 );
slider.setPaintLabels ( false );
slider.setSnapToTicks ( true );
slider.setMargin ( 10 );
slider.setPreferredWidth ( 500 );
slider.addChangeListener ( new ChangeListener ()
{
private int length = content.getEnd () - content.getBegin ();
@Override
public void stateChanged ( final ChangeEvent e )
{
final String floatString = floatConverter.toString ( ( float ) slider.getValue () / 1000 );
source.replaceRange ( floatString, content.getBegin (), content.getBegin () + length );
length = floatString.length ();
}
} );
transparencyChooser.add ( slider );
final Rectangle wb =
source.getUI ().modelToView ( source, ( content.getBegin () + content.getEnd () ) / 2 );
transparencyChooser.show ( source, wb.x, wb.y, wb.width, wb.height, PopOverDirection.down );
return new HyperlinkEvent ( this, HyperlinkEvent.EventType.EXITED, null );
}
catch ( final BadLocationException e )
{
Log.error ( this, e );
return null;