Package org.jahia.ajax.gwt.client.widget.node

Examples of org.jahia.ajax.gwt.client.widget.node.GWTJahiaNodeTreeFactory$GWTJahiaNodeTreePanel


            }
        }
        dependencies = new HashMap<String, List<String>>();
        boxes = new HashMap<String, CheckBox>();

        GWTJahiaNodeTreeFactory treeGridFactory = new GWTJahiaNodeTreeFactory(Arrays.asList("/permissions"), Arrays.asList(GWTJahiaNode.ICON, GWTJahiaNode.CHILDREN_INFO, "j:dependencies"));
        treeGridFactory.setOpenPath(openPath);
        treeGridFactory.setNodeTypes(Arrays.asList("jnt:permission"));

        BaseTreeLoader<GWTJahiaNode> loader = treeGridFactory.getLoader();
        store = treeGridFactory.getStore();
        final List<ColumnConfig> configs1 = new ArrayList<ColumnConfig>();
        ColumnConfig column = new ColumnConfig();
        column.setId("name");
        column.setHeader("");
        column.setRenderer(new TreeGridCellRenderer());
        column.setWidth(350);
        configs1.add(column);
        final GridCellRenderer<GWTJahiaNode> rolePermissionRenderer = new GridCellRenderer<GWTJahiaNode>() {
            public Object render(final GWTJahiaNode currentNode, String property, ColumnData config,
                                 final int rowIndex, final int colIndex, ListStore<GWTJahiaNode> s,
                                 final Grid<GWTJahiaNode> grid) {

                final CheckBox checkbox = new CheckBox();
                checkbox.setValue(selection.contains(currentNode));

                final GWTJahiaNode parentItem = store.getParent(currentNode);

                checkbox.setToolTip(currentNode.getName());
                boxes.put(currentNode.getPath(), checkbox);
                checkbox.addListener(Events.Change, new Listener<ComponentEvent>() {
                    public void handleEvent(ComponentEvent event) {
                        try {
                            if ((Boolean) ((FieldEvent) event).getValue()) {
                                selection.add(currentNode);

                                // Update dependencies
                                List<String> toCheck = dependencies.get(currentNode.getPath());
                                if (toCheck != null) {
                                    for (String s1 : toCheck) {
                                        CheckBox checkBox = boxes.get(s1);
                                        if (checkBox!=null && !checkBox.getValue()) {
                                            checkBox.setValue(true);
                                        }
                                    }
                                }

                                // Update children
                                checkbox.setData("partial", null);
                                List<GWTJahiaNode> l = store.getChildren(currentNode, true);
                                for (GWTJahiaNode node : l) {
                                    CheckBox b = boxes.get(node.getPath());
                                    if (b != null) {
                                        b.setValue(true);
                                    }
                                    selection.remove(node);
                                }

                                // If all siblings set, set parent
                                if (parentItem != null) {
                                    CheckBox parentBox = boxes.get(parentItem.getPath());
                                    if (!parentBox.getValue()) {
                                        List<GWTJahiaNode> siblings = store.getChildren(parentItem);
                                        boolean checkParent = true;
                                        for (GWTJahiaNode sibling : siblings) {
                                            checkParent &= selection.contains(sibling);
                                        }
                                        if (checkParent) {
                                            parentBox.setData("partial", null);
                                            parentBox.setValue(true);
                                        }
                                    }
                                }
                            } else {
                                selection.remove(currentNode);

                                // Update dependencies
                                Set<String> toCheck = dependencies.keySet();
                                for (String s1 : toCheck) {
                                    if (dependencies.get(s1).contains(currentNode.getPath())) {
                                        CheckBox checkBox = boxes.get(s1);
                                        if (checkBox != null && checkBox.getValue()) {
                                            checkBox.setValue(false);
                                        }
                                    }
                                }

                                // Uncheck parent
                                if (parentItem != null) {
                                    CheckBox parentBox = boxes.get(parentItem.getPath());
                                    if (parentBox.getValue()) {
                                        parentBox.setData("partial", Boolean.TRUE);
                                        parentBox.setValue(false);

                                        List<GWTJahiaNode> siblings = store.getChildren(parentItem);
                                        for (GWTJahiaNode node : siblings) {
                                                if (!node.getPath().equals(currentNode.getPath())) {
                                                    selection.add(node);
                                                }
                                        }
                                    }
                                }

                                // Update children
                                if (checkbox.getData("partial") == null) {
                                    checkbox.setData("partial", null);
                                    List<GWTJahiaNode> l = store.getChildren(currentNode, true);
                                    for (GWTJahiaNode node : l) {
                                        CheckBox b = boxes.get(node.getPath());
                                        if (b != null) {
                                            b.setValue(false);
                                        }
                                    }
                                }
                            }
                        } catch (Exception e) {
                            Log.debug("Exception on "+currentNode.getPath(), e);
                        }
                    }
                });

                if (parentItem != null) {
                    CheckBox parentBox = boxes.get(parentItem.getPath());
                    if (parentBox.getValue()) {
                        checkbox.setValue(true);
                        selection.remove(currentNode);
                    }
                }

                return checkbox;
            }
        };

        column = new ColumnConfig();
        column.setRenderer(rolePermissionRenderer);
        column.setId(engine.getNode().getName());
        column.setHeader(engine.getNode().getName());
        column.setWidth(100);
        column.setSortable(false);
        column.setGroupable(false);
        configs1.add(column);

        List<ColumnConfig> configs = configs1;
        TreeGrid<GWTJahiaNode> treeGrid = treeGridFactory.getTreeGrid(new ColumnModel(configs));

        treeGrid.setIconProvider(ContentModelIconProvider.getInstance());
        treeGrid.setBorders(true);
        treeGrid.setAutoExpandColumn("name");
        treeGrid.setAutoExpandMax(1000);
View Full Code Here


        setModal(true);
        getHeader().setBorders(false);
        getHeader().setIcon(ToolbarIconProvider.getInstance().getIcon("siteRepository"));

        // tree component
        GWTJahiaNodeTreeFactory factory = new GWTJahiaNodeTreeFactory(Arrays.asList("/sites/"+linker.getSelectionContext().getMainNode().getSiteKey()), true);
        factory.setNodeTypes(Arrays.asList("jmix:publication","jmix:workflowRulesable"));
        factory.setFields(Arrays.asList(GWTJahiaNode.NAME, GWTJahiaNode.DISPLAY_NAME, GWTJahiaNode.PUBLICATION_INFOS,
                                        GWTJahiaNode.WORKFLOW_INFOS));
        factory.setSelectedPath(linker.getSelectionContext().getMainNode().getPath());
        factory.setSaveOpenPath(true);
        loader = factory.getLoader();
        List<ColumnConfig> columns = new LinkedList<ColumnConfig>();
        ColumnConfig config = new ColumnConfig("displayName", "Name", 150);
        config.setRenderer(new TreeGridCellRenderer());
        config.setSortable(false);
        columns.add(config);
        checkboxMap = new HashMap<String, LayoutContainer>();
        for (GWTJahiaLanguage language : languages) {
            config = new PublicationCheckColumnConfig("publicationInfos", language.getDisplayName(), 100);
            config.setDataIndex(language.getLanguage());
            config.setSortable(false);

            TableData td = new TableData();
            td.setHorizontalAlign(Style.HorizontalAlignment.CENTER);
            td.setVerticalAlign(Style.VerticalAlignment.MIDDLE);

            HorizontalPanel p = new HorizontalPanel();
//            final LayoutContainer ctn = new LayoutContainer();
//            ctn.addStyleName("x-grid3-check-col");
//            ctn.setWidth(16);
//            ctn.setHeight(16);
//            p.add(ctn,td);
            p.add(new Text(language.getDisplayName()),td);
            config.setWidget(p, language.getLanguage());
//            checkboxMap.put(language.getLanguage(), ctn);
            columns.add(config);
        }


        ColumnModel cm = new ColumnModel(columns);
//        cm.addHeaderGroup(0, 1, new HeaderGroupConfig("Publication Info", 1, columns.size() - 1));
        m_tree = factory.getTreeGrid(cm);

        for (ColumnConfig column : columns) {
            if (column instanceof CheckColumnConfig) {
                m_tree.addPlugin((ComponentPlugin) column);
            }
View Full Code Here

     * Create Browser tree Grid
     *
     * @return
     */
    private TreeGrid<GWTJahiaNode> createCategoriedPickerPanel() {
        GWTJahiaNodeTreeFactory treeGridFactory =
                new GWTJahiaNodeTreeFactory(Arrays.asList("$systemsite/categories"), GWTJahiaNode.DEFAULT_REFERENCE_FIELDS);
        treeGridFactory.setNodeTypes(JCRClientUtils.CATEGORY_NODETYPES);
        ColumnConfig name = new ColumnConfig("displayName", Messages.get("label.title"), 500);
        name.setRenderer(new TreeGridCellRenderer<GWTJahiaNode>());
        name.setFixed(true);
        ColumnConfig action = new ColumnConfig("action", "Action", 100);
        action.setAlignment(Style.HorizontalAlignment.RIGHT);
        action.setRenderer(new GridCellRenderer() {
            public Object render(ModelData modelData, String s, ColumnData columnData, int i, int i1,
                                 ListStore listStore, Grid grid) {
                GWTJahiaNode gwtJahiaNode = (GWTJahiaNode) modelData;
                Button button = null;
                if (gwtJahiaNode.getNodeTypes().contains("jnt:category")) {
                    button = new Button(Messages.get("label.add", "Add"), new SelectionListener<ButtonEvent>() {
                        @Override
                        public void componentSelected(ButtonEvent buttonEvent) {
                            final GWTJahiaNode node1 = (GWTJahiaNode) buttonEvent.getButton().getData("associatedNode");
                            if (catStore.findModel(node1) == null) {
                                catStore.add(node1, false);
                            }
                        }
                    });
                    button.setData("associatedNode", modelData);
                    button.setIcon(StandardIconsProvider.STANDARD_ICONS.plusRound());
                }
                return button != null ? button : new Label("");
            }
        });
        action.setFixed(true);
        TreeGrid<GWTJahiaNode> treeGrid = treeGridFactory.getTreeGrid(new ColumnModel(Arrays.asList(name, action)));

        treeGrid.setIconProvider(ContentModelIconProvider.getInstance());

        treeGrid.setBorders(true);
        treeGrid.setAutoExpandColumn("displayName");
View Full Code Here

        tab.setLayout(new FitLayout());
        return tab;
    }

    private void initPageTree() {
        GWTJahiaNodeTreeFactory factory = new GWTJahiaNodeTreeFactory(paths);
        factory.setNodeTypes(folderTypes);
        factory.setFields(config.getTreeColumnKeys());
        this.pageFactory = factory;
        this.pageFactory.setSelectedPath(path);

        NodeColumnConfigList columns = new NodeColumnConfigList(config.getTreeColumns());
        columns.init();
        columns.get(0).setRenderer(new TreeGridCellRenderer());

        pageTree = factory.getTreeGrid(new ColumnModel(columns));

        pageTree.setAutoExpandColumn(columns.getAutoExpand());
        pageTree.getTreeView().setRowHeight(25);
        pageTree.getTreeView().setForceFit(true);
        pageTree.setHeight("100%");
View Full Code Here

        treeContainer = new LayoutContainer();
        treeContainer.setBorders(false);
        treeContainer.setScrollMode(Style.Scroll.AUTO);
        treeContainer.setLayout(new FitLayout());
        factory = new GWTJahiaNodeTreeFactory(paths);
        factory.setNodeTypes(this.folderTypes);

        NodeColumnConfigList columns = new NodeColumnConfigList(config.getTreeColumns());
        columns.init();
        columns.get(0).setRenderer(new TreeGridCellRenderer());
View Full Code Here

TOP

Related Classes of org.jahia.ajax.gwt.client.widget.node.GWTJahiaNodeTreeFactory$GWTJahiaNodeTreePanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.