int ix = fileTable.getSelectedRow();
if( ix == -1 )
return;
Attachment attachment = container.getAttachmentAt( ix );
if( attachment.isCached() )
{
String name = attachment.getName();
try
{
name = StringUtils.createFileName( name, '-' );
File tempFile = File.createTempFile( "attachment-" + name,
"." + ContentTypeHandler.getExtensionForContentType( attachment.getContentType() ) );
exportAttachment( tempFile, attachment, false );
}
catch( Exception e1 )
{
UISupport.showErrorMessage( e1 );
}
}
else
{
Tools.openURL( attachment.getUrl() );
}
}
} );
}