}
});
}
private synchronized void fillCompleteModel(final DocumentNode parent) {
BeanBasicDocument dir = parent.getUserObject();
BeanDirectory beanDir = (BeanDirectory) dir;
beanDir.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
refreshTree();
}
});
Map<String, DocumentNode> existingDocs = new HashMap<>();
for (int i = 0; i < parent.getChildCount(); i++) {
DocumentNode childNode = (DocumentNode) parent.getChildAt(i);
String documentId = childNode.getUserObject().getId().toString();
existingDocs.put(documentId, childNode);
}
for (final UniqueID id : beanDir.getDocuments()) {
BeanBasicDocument beanBasicDocument = CampaignClient.getInstance()
.getBean(id);
if (beanBasicDocument != null) {
DocumentNode node = existingDocs.get(beanBasicDocument.getId()
.toString());
if (node != null) {
existingDocs.remove(beanBasicDocument.getId().toString());
} else {
node = new DocumentNode(beanBasicDocument,
beanBasicDocument.isDirectory());
parent.add(node);
}
if (beanBasicDocument.isDirectory()) {
fillCompleteModel(node);
}
} else {
CampaignClient.getInstance().addWaitBeanListener(
new WaitBeanListener() {