use of com.extjs.gxt.ui.client.widget.treegrid.TreeGridView in project jahia by Jahia.
the class TemplatesTabItem method create.
/**
* Performs the creation of the tab item and populates its content. The tab contains two panes: one with the tree of templates,
* available in the module, and the second pane with the detail structure of the template content.
*
* @param config
* the tab configuration
* @return the created tab item
*/
@Override
public TabItem create(GWTSidePanelTab config) {
super.create(config);
this.tree.setSelectionModel(new TreeGridSelectionModel<GWTJahiaNode>() {
@Override
protected void handleMouseClick(GridEvent<GWTJahiaNode> e) {
super.handleMouseClick(e);
if (!getSelectedItem().getPath().equals(editLinker.getMainModule().getPath())) {
if (!getSelectedItem().getNodeTypes().contains("jnt:virtualsite") && !getSelectedItem().getNodeTypes().contains("jnt:templatesFolder")) {
MainModule.staticGoTo(getSelectedItem().getPath(), null);
}
}
}
});
this.tree.getSelectionModel().setSelectionMode(Style.SelectionMode.SINGLE);
this.tree.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GWTJahiaNode>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaNode> se) {
detailTree.getSelectionModel().deselectAll();
if (se.getSelectedItem() != null) {
detailLoader.load(se.getSelectedItem());
} else {
detailStore.removeAll();
}
}
});
tree.setContextMenu(createContextMenu(config.getTreeContextMenu(), tree.getSelectionModel()));
selectMainNodeTreeLoadListener = new SelectMainNodeTreeLoadListener(tree);
NodeColumnConfigList columns = new NodeColumnConfigList(config.getTreeColumns());
columns.init();
columns.get(0).setRenderer(NodeColumnConfigList.NAME_TREEGRID_RENDERER);
RpcProxy<List<GWTJahiaNode>> proxy = new RpcProxy<List<GWTJahiaNode>>() {
@Override
protected void load(Object currentPage, final AsyncCallback<List<GWTJahiaNode>> callback) {
if (currentPage != null) {
GWTJahiaNode gwtJahiaNode = (GWTJahiaNode) currentPage;
List<String> fields = new ArrayList<String>();
fields.add(GWTJahiaNode.LOCKS_INFO);
fields.add(GWTJahiaNode.PERMISSIONS);
fields.add(GWTJahiaNode.CHILDREN_INFO);
fields.add(GWTJahiaNode.ICON);
JahiaContentManagementService.App.getInstance().lsLoad(gwtJahiaNode.getPath(), displayedDetailTypes, null, null, fields, false, 0, 0, false, hiddenDetailTypes, null, false, false, new AsyncCallback<PagingLoadResult<GWTJahiaNode>>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(PagingLoadResult<GWTJahiaNode> nodes) {
callback.onSuccess(nodes.getData());
}
});
}
}
};
detailLoader = new BaseTreeLoader<GWTJahiaNode>(proxy) {
@Override
public boolean hasChildren(GWTJahiaNode parent) {
return parent.hasChildren();
}
};
detailStore = new TreeStore<GWTJahiaNode>(detailLoader);
detailTree = new TreeGrid<GWTJahiaNode>(detailStore, new ColumnModel(columns));
detailTree.setAutoExpandColumn("displayName");
detailTree.getTreeView().setRowHeight(25);
detailTree.getTreeView().setForceFit(true);
detailTree.setHeight("100%");
detailTree.setIconProvider(ContentModelIconProvider.getInstance());
detailTree.setAutoExpand(true);
detailTree.setContextMenu(createContextMenu(config.getTableContextMenu(), detailTree.getSelectionModel()));
detailTree.setView(new TreeGridView() {
@Override
protected void handleComponentEvent(GridEvent ge) {
switch(ge.getEventTypeInt()) {
case Event.ONMOUSEOVER:
GWTJahiaNode selection = (GWTJahiaNode) ge.getModel();
if (selection != null) {
List<Module> modules = ModuleHelper.getModulesByPath().get(selection.getPath());
if (modules != null) {
for (Module module : modules) {
Hover.getInstance().addHover(module, ge);
}
}
}
break;
case Event.ONMOUSEOUT:
selection = (GWTJahiaNode) ge.getModel();
if (selection != null) {
List<Module> modules = ModuleHelper.getModulesByPath().get(selection.getPath());
if (modules != null) {
for (Module module : modules) {
Hover.getInstance().removeHover(module);
}
}
}
break;
}
editLinker.getMainModule().setCtrlActive(ge);
super.handleComponentEvent(ge);
}
});
detailTree.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<GWTJahiaNode>() {
@Override
public void selectionChanged(SelectionChangedEvent<GWTJahiaNode> se) {
if (se.getSelection() != null) {
for (GWTJahiaNode selection : se.getSelection()) {
List<Module> modules = ModuleHelper.getModulesByPath().get(selection.getPath());
if (modules != null) {
for (Module module : modules) {
if (!editLinker.getMainModule().getSelections().containsKey(module)) {
editLinker.getMainModule().handleNewModuleSelection(module);
}
}
}
}
}
}
});
contentContainer = new LayoutContainer();
contentContainer.setBorders(false);
contentContainer.setScrollMode(Style.Scroll.AUTO);
contentContainer.setLayout(new FitLayout());
contentContainer.setTitle(Messages.get("label.detail", "detail"));
contentContainer.add(detailTree);
VBoxLayoutData contentVBoxData = new VBoxLayoutData();
contentVBoxData.setFlex(2);
tab.add(contentContainer, contentVBoxData);
return tab;
}
Aggregations