}
}
}
private final Tree createTree(XUser user, TreeLoader<TreeNode> loader) {
final Tree tree = new Tree();
tree.setIndentWidth(18);
tree.setSelectionMode(SelectionMode.SINGLE);
TreeStore<TreeNode> treeStore = new TreeStore<TreeNode>(loader);
treeBinder = new TreeNodeBinder(tree, treeStore);
treeBinder.setDisplayProperty("name");
treeBinder.setAutoSelect(true);
treeBinder.init();
// tree model:
browserModel = new ViewBrowserModel(user, treeStore);
tree.addListener(Events.SelectionChange, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
TreeItem selection = tree.getSelectedItem();
if (selection == null) {
if (deleteItem != null) {
deleteItem.setEnabled(false);
deleteItem.setIconStyle("icon-delete-off");
}
if (renameItem != null) {
renameItem.setEnabled(false);
}
if (editViewProperties != null) {
editViewProperties.setEnabled(false);
}
if (createDirectLink != null) {
createDirectLink.setEnabled(false);
}
} else {
checkSelection(tree);
}
}
});
tree.addListener(Events.OnClick, new Listener<BaseEvent>() {
public void handleEvent(BaseEvent be) {
checkSelection(tree);
}
});
tree.addListener(Events.OnDoubleClick, new Listener<TreeEvent>() {
public void handleEvent(TreeEvent be) {
handleAction(OPEN);
}
});
tree.addListener(Events.OnKeyUp, new Listener<TreeEvent>() {
public void handleEvent(TreeEvent te) {
if (te.getKeyCode() == F2) {
handleAction(RENAME);
}
}
});
String sessionId = ((Workbench)Registry.get(Workbench.ID)).getUser().getSessionId();
WPaloFolderServiceProvider.getInstance().hasWritePermission(sessionId,
new Callback<Boolean>() {
public void onSuccess(Boolean result) {
if (result) {
addDragAndDrop(treeBinder);
}
}
});
tree.setContextMenu(createContextMenu());
tree.getRootItem().setExpanded(true);
return tree;
}