public boolean hasChildren(TreeNode data) {
return data != null && data.getXObject() != null &&
data.getXObject().hasChildren();
}
};
final Tree reportsTree = createTree(treeLoader);
ToolBar toolbar = new ToolBar();
TextToolItem addFolder = new TextToolItem("", "icon-create-folder");
addFolder.setToolTip(WPalo.i18n.reportNavigatorView_addFolderToolTip());
// "Create new Folder");
toolbar.add(addFolder);
TextToolItem addSheet = new TextToolItem("", "icon-create-sheet");
toolbar.add(addSheet);
addSheet.setToolTip(WPalo.i18n.reportNavigatorView_addWorkbookTemplateToolTip());
// "Create new Workbook Template");
addSheet.addSelectionListener(new CreateNewSheet(reportsTree));
TextToolItem addView = new TextToolItem("", "icon-create-view");
addView.setToolTip(WPalo.i18n.reportNavigatorView_addAdhocViewTemplateToolTip());
// "Create new AdHoc View Template");
toolbar.add(addView);
toolbar.add(new SeparatorToolItem());
TextToolItem delItems = new TextToolItem("", "icon-delete");
delItems.setToolTip(WPalo.i18n.reportNavigatorView_deleteItemsToolTip());
// "Delete items");
toolbar.add(delItems);
delItems.addSelectionListener(new SelectionListener<ComponentEvent>(){
public void componentSelected(ComponentEvent ce) {
}
});
navigator.setTopComponent(toolbar);
reportsTree.addListener(Events.OnClick, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
TreeNode node = (TreeNode) reportsTree.getSelectedItem().getModel();
if (node.getXObject() instanceof XView) {
fireEvent(new AppEvent<TreeNode>(WPaloEvent.SHOW_TEMPLATE_VIEW, node));
}
}
});
reportsTree.addListener(Events.OnDoubleClick, new Listener<BaseEvent>(){
public void handleEvent(BaseEvent be) {
TreeNode node = (TreeNode) reportsTree.getSelectedItem().getModel();
if (node.getXObject() instanceof XTemplate) {
fireEvent(new AppEvent<TreeNode>(WPaloEvent.EDIT_TEMPLATE_ITEM, node));
}
else if (node.getXObject() instanceof XView) {
fireEvent(new AppEvent<TreeNode>(WPaloEvent.EDIT_TEMPLATE_VIEW, node));