setIcon(item, baseName);
}
}
protected TreeItem createItem(TreeNode model) {
final TreeItem item = super.createItem(model);
if (model.getXObject() instanceof XAccount) {
model.set("name", ((XAccount) model.getXObject()).getConnection().getName());
}
if (model.getType().equals(XStaticReportFolder.class.getName())) {
IconListener staticListener = new IconListener(item, "static-folder");
item.addListener(Events.Expand, staticListener);
item.addListener(Events.Collapse, staticListener);
setIcon(item, "static-folder");
XStaticReportFolder sf = (XStaticReportFolder) model.getXObject();
sf.setReturnComputedKids(true);
} else if (model.getType().equals(XDynamicReportFolder.class.getName())) {
IconListener dynamicListener = new IconListener(item, "dynamic-folder");
item.addListener(Events.Expand, dynamicListener);
item.addListener(Events.Collapse, dynamicListener);
setIcon(item, "dynamic-folder");
String text = item.getText();
XDynamicReportFolder df = (XDynamicReportFolder) model.getXObject();
if (df.getSourceHierarchy() == null && df.getSourceSubset() == null) {
text += " (undef. hierarchy)";
} else {
if (df.getSourceSubset() != null) {
text += " (" + df.getSourceSubset().getName() + ")";
} else {
text += " (" + df.getSourceHierarchy().getName() + ")";
}
}
item.setText(text);
df.setReturnComputedKids(true);
} else if (model.getType().equals(XReport.TYPE)) {
String typeName;
if (((XReport) model.getXObject()).getReceiverType().equals(
XConstants.TYPE_FOLDER_ELEMENT_VIEW)) {
typeName = "icon-view";
} else {
typeName = "icon-sheet";
}
item.setIconStyle(typeName);
}
return item;
}