/**
* Setup a lookup controller.
*/
private void setupLookup(final TableVO auxVO,CodLookupColumn col,final ForeignKeyVO fk) {
LookupController lookupController = new LookupController();
final LookupServerDataLocator lookupDataLocator = new LookupServerDataLocator();
lookupDataLocator.setGridMethodName("executeQuery");
lookupDataLocator.setValidationMethodName("executeValidateQuery");
col.setLookupController(lookupController);
lookupController.setAllColumnVisible(false);
lookupController.setLookupDataLocator(lookupDataLocator);
lookupController.setFrameTitle(fk.getPkTableName());
lookupController.setLookupValueObjectClassName("org.jallinone.sqltool.java.RowVO");
ColumnVO vo = null;
int colWidth = 0;
int width = 0;
for(int j=0;j<auxVO.getColumns().size();j++) {
vo = (ColumnVO)auxVO.getColumns().get(j);
lookupController.setVisibleColumn(vo.getAttributeName(),true);
lookupController.setHeaderColumnName(vo.getAttributeName(),vo.getColumnHeaderName());
lookupController.setSortableColumn(vo.getAttributeName(),true);
lookupController.setFilterableColumn(vo.getAttributeName(),true);
colWidth = Math.max(vo.getColumnSize().intValue(),vo.getColumnHeaderName().length()*9);
lookupController.setPreferredWidthColumn(vo.getAttributeName(),colWidth);
width += colWidth;
for(int i=0;i<fk.getFkFieldNames().size();i++)
if (vo.getColumnName().equals(fk.getPkTableName()+"."+fk.getPkFieldNames().get(i)))
lookupController.addLookup2ParentLink(
vo.getAttributeName(),
tableVO.getAttributeName(fk.getFkTableName()+"."+fk.getFkFieldNames().get(i))
);
}
lookupController.setFramePreferedSize(new Dimension(Math.min(750,width+30),500));
lookupController.addLookupListener(new LookupListener() {
public void codeValidated(boolean validated) {}
public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {}
public void beforeLookupAction(ValueObject parentVO) {
lookupDataLocator.getLookupFrameParams().put(ApplicationConsts.QUERY_INFO,auxVO);
lookupDataLocator.getLookupValidationParameters().put(ApplicationConsts.QUERY_INFO,auxVO);
lookupDataLocator.getLookupValidationParameters().put(ApplicationConsts.CODE,fk.getPkFieldNames().get(fk.getPkFieldNames().size()-1));
}
public void forceValidate() {}
});