Search in sources :

Example 1 with TreeGridEvent

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));
    }
}
Also used : Listener(com.extjs.gxt.ui.client.event.Listener) GWTJahiaNode(org.jahia.ajax.gwt.client.data.node.GWTJahiaNode) ContentTypeTree(org.jahia.ajax.gwt.client.widget.edit.ContentTypeTree) FillLayout(com.extjs.gxt.ui.client.widget.layout.FillLayout) TreeGridEvent(com.extjs.gxt.ui.client.event.TreeGridEvent) TreeGrid(com.extjs.gxt.ui.client.widget.treegrid.TreeGrid) GWTJahiaNodeType(org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeType)

Aggregations

Listener (com.extjs.gxt.ui.client.event.Listener)1 TreeGridEvent (com.extjs.gxt.ui.client.event.TreeGridEvent)1 FillLayout (com.extjs.gxt.ui.client.widget.layout.FillLayout)1 TreeGrid (com.extjs.gxt.ui.client.widget.treegrid.TreeGrid)1 GWTJahiaNodeType (org.jahia.ajax.gwt.client.data.definition.GWTJahiaNodeType)1 GWTJahiaNode (org.jahia.ajax.gwt.client.data.node.GWTJahiaNode)1 ContentTypeTree (org.jahia.ajax.gwt.client.widget.edit.ContentTypeTree)1