new BasicEventList<ObservableObject>()
), connector
));
EventTableModel<ObservableObject> servicesTableModel = new EventTableModel<ObservableObject>(servicesEventList,
new BeanTableFormat<ObservableObject>(propertyNames, columnLabels));
final ObservableList<ServiceInfo> list = new ObservableList(servicesEventList, propertyNames, new String[]{"host", "name"});
jTable.setModel(servicesTableModel);
_selection = new EventSelectionModel<ObservableObject>(servicesEventList);
jTable.setSelectionModel(_selection);
TableComparatorChooser tableSorter = TableComparatorChooser.install(jTable, servicesEventList, TableComparatorChooser.SINGLE_COLUMN);
new Timer("services table updated", true).schedule(new TimerTask()
{
@Override
public void run()
{
List<ServiceInfo> allServices = new ArrayList();
HashSet<String> managers;
synchronized (_managers)
{
managers = new HashSet<String>(_managers.keySet());
}
for (String managerName : managers)
{
Map<String, ServiceInfo> list = null;
try
{
AsyncServiceManagerServer manager = _managers.get(managerName);
if (manager == null)
continue;
list = (Map<String, ServiceInfo>) ((Future)manager.getServiceList()).get(10, TimeUnit.SECONDS);
for (ServiceInfo info : list.values())
{
((ServiceInfoImpl)info).setHost(managerName);
}
}
catch (Exception e)
{
e.printStackTrace();
}
if (list == null || list.isEmpty())
{
System.out.println("error getting services");
}
else
{
for (Object service : list.values())
if (!ClientMain.hidden.containsObject((ServiceInfo) service))
allServices.add((ServiceInfo) service);
}
}
list.update(allServices);
}
},
0,
500);