{
return (ListBrowser) views.get( viewKey );
}
else
{
final ListBrowserDef viewDef;
try
{
final byte[] data = (byte[]) index.find( "listBrowser." + name );
if( data == null )
{
throw new IllegalArgumentException(
"The view does not exist"
);
}
viewDef = new ListBrowserDef();
viewDef.read( data );
}
catch( Exception e )
{
throw new RuntimeException( "Error loading view: " + e );
}
sendWait();
ListBrowser browser;
final boolean nativeView =
viewDef.getType() != null ?
viewDef.getType().byteValue() == ListBrowserDef.NATIVE :
isListBrowserDefaultNative();
if( nativeView )
{
browser = new ListBrowserView(
getController( viewDef.getController() ),
ResourceManager.getResource( viewDef.getTitle() ),
viewDef.getId(),
viewDef.getPageSize() != null ?
viewDef.getPageSize().intValue() :
10
);
}
else
{
final DataListView dlv = new DataListView(
getController( viewDef.getController() ),
ResourceManager.getResource( viewDef.getTitle() ),
viewDef.getId()
);
final DataList dataList = dlv.getDataList();
if( viewDef.getColor() != null )
{
dataList.setColor( viewDef.getColor().intValue() );
}
if( viewDef.getSelectedColor() != null )
{
dataList.setSelectedColor(
viewDef.getSelectedColor().intValue()
);
}
if( viewDef.getBackground() != null )
{
dataList.setBackground( viewDef.getBackground().intValue() );
}
if( viewDef.getSelectedBackground() != null )
{
dataList.setSelectedBackground(
viewDef.getSelectedBackground().intValue()
);
}
if( viewDef.getMaxLines() != null )
{
dataList.setMaxLines( viewDef.getMaxLines().intValue() );
}
browser = dlv;
}
final Vector fields = viewDef.getFields();
final int fieldCount = fields.size();
for( int i = 0; i < fieldCount; i++ )
{
final FieldDef field = (FieldDef) fields.elementAt( i );
if( browser instanceof ListBrowserView )
{
browser.addField( field.getName() );
}
else
{
browser.addField(
field.getName(),
field.getLabel(),
field.getMode() != null ?
field.getMode().byteValue() :
DataList.PLAIN,
field.getTrueLabel(),
field.getFalseLabel(),
field.getResource()
);
}
}
final String separator = viewDef.getSeparator();
if( separator != null)
{
browser.setSeparator( separator );
}
if( browser instanceof ListBrowserView )
{
((ListBrowserView) browser).setWrap(
viewDef.getWrap() != null &&
viewDef.getWrap().booleanValue()
);
}
else
{
((DataListView) browser).getDataList().setWrap(
viewDef.getWrap() != null &&
viewDef.getWrap().booleanValue()
);
}
Font font = null;
if( viewDef.getFontFace() != null )
{
font = Font.getFont(
viewDef.getFontFace().intValue(),
viewDef.getFontStyle() != null ?
viewDef.getFontStyle().intValue() :
Font.STYLE_PLAIN,
viewDef.getFontSize() != null ?
viewDef.getFontSize().intValue() :
Font.SIZE_SMALL
);
}
else if( viewDef.getFontStyle() != null )
{
font = Font.getFont(
Font.FACE_PROPORTIONAL,
viewDef.getFontStyle().intValue(),
viewDef.getFontSize() != null ?
viewDef.getFontSize().intValue() :
Font.SIZE_SMALL
);
}
else if( viewDef.getFontSize() != null )
{
font = Font.getFont(
Font.FACE_PROPORTIONAL,
Font.STYLE_PLAIN,
viewDef.getFontSize().intValue()
);
}
if( font != null )
{
if( browser instanceof DataListView )
{
((DataListView) browser).getDataList().setFont( font );
}
}
final Vector speedOptions = viewDef.getSpeedOptions();
final int speedOptionCount = speedOptions.size();
for( int i = 0; i < speedOptionCount; i++ )
{
final SpeedOptionDef option = (SpeedOptionDef)
speedOptions.elementAt( i );