super( title, getDescription(), null );
}
protected Component buildContent()
{
SimpleForm form = new SimpleForm();
form.addSpace( 5 );
Interface[] ifaces = getInterfaces( project );
DefaultComboBoxModel serviceComboModel = new DefaultComboBoxModel();
serviceCombo = form.appendComboBox( "REST Services", serviceComboModel, "Target Service" );
serviceCombo.setRenderer( new ModelItemListCellRenderer() );
for( Interface element : ifaces )
{
if( element instanceof RestService )
serviceComboModel.addElement( element );
}
resourceCombo = form.appendComboBox( "REST Resources", ( ( RestService )serviceCombo.getSelectedItem() )
.getOperationList().toArray(), "Target Resource" );
resourceCombo.setRenderer( new ModelItemListCellRenderer() );
methodCombo = form.appendComboBox( "REST Methods", ( ( RestResource )resourceCombo.getSelectedItem() )
.getRestMethodList().toArray(), "Target Method" );
methodCombo.setRenderer( new ModelItemListCellRenderer() );
serviceCombo.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
Interface iface = project.getInterfaceByName( ( ( Interface )serviceCombo.getSelectedItem() ).getName() );
resourceCombo.removeAllItems();
if( iface != null )
{
resourceCombo.setEnabled( true );
for( Operation op : iface.getOperationList() )
resourceCombo.addItem( op );
}
else
{
resourceCombo.setEnabled( false );
}
}
} );
resourceCombo.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
RestResource resource = ( RestResource )resourceCombo.getSelectedItem();
methodCombo.removeAllItems();
if( resource != null )
{
methodCombo.setEnabled( true );
for( RestMethod method : resource.getRestMethodList() )
methodCombo.addItem( method );
}
else
{
methodCombo.setEnabled( false );
}
}
} );
form.addSpace( 5 );
return form.getPanel();
}