@Override
public void initGUI()
{
try
{
final ResourceService resources = Engine.instance().getResourceService();
SwingEngine swingEngine = new SwingEngine(this);
AddressClientManager acm = (AddressClientManager) Engine.instance().getManager(AddressClientManager.ID);
columns = acm.getAddressTableColumns();
JPanel panel = (JPanel) swingEngine.render(getClass().getResource("/swixml/AddressQueryPane.xml"));
content.add(panel, createConstraints(0, 0, 1, 1, GridBagConstraints.BOTH, 100, 100, null));
search.idle();
AddressTableCellRenderer renderer = new AddressTableCellRenderer();
AddressTableModel model = new AddressTableModel();
addressTable.setModel(model);
addressTable.getColumnModel().getColumn(0).setMinWidth(0);
addressTable.getColumnModel().getColumn(0).setMaxWidth(0);
for (int i = 1; i < model.getColumnCount(); ++i)
{
addressTable.getColumnModel().getColumn(i).setCellRenderer(renderer);
}
addressTable.addMouseListener(new AddressTableMouseListener());
for (int i : new IntRange(0, columns.size() - 1))
{
ITableColumn c = columns.get(i);
if (StringTools.isTrimEmpty(c.getTitle().get()))
{
if (c.getCellIcon() != null)
{
addressTable.getColumnModel().getColumn(i).setMinWidth(c.getCellIcon().getIconWidth() + 4);
addressTable.getColumnModel().getColumn(i).setMaxWidth(c.getCellIcon().getIconWidth() + 4);
}
else
{
addressTable.getColumnModel().getColumn(i).setMinWidth(4);
addressTable.getColumnModel().getColumn(i).setMaxWidth(4);
}
}
}
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>();
addressTable.setRowSorter(sorter);
sorter.setModel(model);
addressStore.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
search(IComboBoxIdItem.getSelectedId(addressStore).toString(), searchText.getText());
}
});
searchText.grabFocus();
new Thread()
{
@Override
public void run()
{
search.busy();
AddressClientService acs = (AddressClientService) Engine.instance().getManager(
AddressClientService.ID);
for (final AddressStore ads : acs.listAddressStores())
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
addressStore.addItem(new IComboBoxIdItem(ads.getName(), resources
.getStringWithoutException(ads.getTitle())));
}
});
}