final String attributeName = attribute.getName ();
if ( attributeName.equals ( ComponentStyleConverter.COMPONENT_TYPE_ATTRIBUTE ) )
{
final Segment content = attribute.getValueSegment ();
final String type = element.getAttributeValue ( ComponentStyleConverter.COMPONENT_TYPE_ATTRIBUTE );
final SupportedComponent selectedType = SupportedComponent.valueOf ( type );
return new LinkGeneratorResult ()
{
@Override
public HyperlinkEvent execute ()
{
try
{
final WebPopOver typeChooser = new WebPopOver ( parentComponent );
typeChooser.setCloseOnFocusLoss ( true );
typeChooser.setStyleId ( "editor-pop-over" );
typeChooser.setMargin ( 5, 0, 5, 0 );
final List<SupportedComponent> supportedComponents =
SupportedComponent.getPainterSupportedComponents ();
final WebList historyList = new WebList ( supportedComponents );
historyList.setOpaque ( false );
historyList.setVisibleRowCount ( Math.min ( 10, supportedComponents.size () ) );
historyList.setRolloverSelectionEnabled ( true );
historyList.setSelectedValue ( selectedType );
historyList.setCellRenderer ( new WebComboBoxCellRenderer ()
{
@Override
public Component getListCellRendererComponent ( final JList list, final Object value,
final int index, final boolean isSelected,
final boolean cellHasFocus )
{
final WebComboBoxElement renderer = ( WebComboBoxElement ) super
.getListCellRendererComponent ( list, value, index, isSelected, cellHasFocus );
final SupportedComponent type = ( SupportedComponent ) value;
if ( type != null )
{
renderer.setIcon ( type.getIcon () );
renderer.setText ( type.toString () );
}
return renderer;
}
} );