use of com.extjs.gxt.ui.client.event.TreeGridEvent in project jahia by Jahia.
the class NewViewActionItem method newView.
@SuppressWarnings("unchecked")
private void newView(final Linker linker, boolean isLoading) {
final GWTJahiaNode selectedNode = linker.getSelectionContext().getSingleSelection();
if (selectedNode.getNodeTypes().contains("jnt:moduleVersionFolder")) {
// Open popup to select nodeType
ArrayList<String> paths = new ArrayList<String>();
paths.add(JahiaGWTParameters.getSiteNode().getPath());
for (String s : (List<String>) JahiaGWTParameters.getSiteNode().getProperties().get("j:resolvedDependencies")) {
for (GWTJahiaNode n : JahiaGWTParameters.getSitesMap().values()) {
if (n.getName().equals(s)) {
paths.add(n.getPath());
}
}
}
if (!isLoading) {
linker.loading(Messages.get("label.loading", "Loading"));
}
JahiaContentManagementService.App.getInstance().getContentTypesAsTree(Arrays.asList("nt:base"), null, true, new BaseAsyncCallback<List<GWTJahiaNodeType>>() {
@Override
public void onSuccess(List<GWTJahiaNodeType> result) {
linker.loaded();
final com.extjs.gxt.ui.client.widget.Window popup = new com.extjs.gxt.ui.client.widget.Window();
popup.addStyleName("new-view-modal");
popup.setHeadingHtml(Messages.get("label.addView", "Add view"));
popup.setHeight(400);
popup.setWidth(350);
popup.setModal(true);
popup.setLayout(new FillLayout());
ContentTypeTree contentTypeTree = new ContentTypeTree();
contentTypeTree.fillStore(result);
TreeGrid<?> treeGrid = contentTypeTree.getTreeGrid();
treeGrid.sinkEvents(Event.ONDBLCLICK + Event.ONCLICK);
treeGrid.addListener(Events.OnDoubleClick, new Listener<TreeGridEvent<GWTJahiaNodeType>>() {
public void handleEvent(TreeGridEvent<GWTJahiaNodeType> baseEvent) {
GWTJahiaNodeType gwtJahiaNodeType = baseEvent.getModel();
if (gwtJahiaNodeType != null && linker != null) {
GWTJahiaNodeType engineNodeType = TEMPLATE.equals(gwtJahiaNodeType.getName()) ? fileNodeTypes.get(TEMPLATE_FILE) : fileNodeTypes.get(VIEW_FILE);
createEngine(engineNodeType, selectedNode, gwtJahiaNodeType.getName());
popup.hide();
}
}
});
popup.add(contentTypeTree);
popup.show();
}
@Override
public void onFailure(Throwable caught) {
linker.loaded();
super.onFailure(caught);
}
});
} else {
if (isLoading) {
linker.loaded();
}
GWTJahiaNodeType fileNodeType = TEMPLATE.equals(findNodeType(selectedNode)) ? fileNodeTypes.get(TEMPLATE_FILE) : fileNodeTypes.get(VIEW_FILE);
createEngine(fileNodeType, selectedNode, findNodeType(selectedNode));
}
}
Aggregations