<commit_before>/*
 * Copyright (C) 2012-2013 B3Partners B.V.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * TOC component
 * Creates a Table of comtents Component
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */

Ext.define('Maps', {
    extend: 'Ext.data.TreeModel',
    fields: [
        // Added convert function to icon
        {name: 'icon', type: 'string', convert: function(fieldName, record) {
            if(record.get('leaf')) {
                return contextPath + '/viewer-html/components/resources/images/selectionModule/map.png';
            }
            return contextPath + '/viewer-html/components/resources/images/selectionModule/folder.png';
        }}
    ]
});

Ext.define ("viewer.components.TOC",{
    extend: "viewer.components.Component",
    panel: null,
    buttonBar: null,
    selectedContent : null,
    appLayers :  null,
    service : null,
    levels : null,
    backgroundLayers: null,
    // popup:null,
    qtips:null,
    toggleAllLayersState:true,
    config: {
        label: null,
        iconUrl: null,
        tooltip: null,
        groupCheck:true,
        layersChecked:true,
        showBaselayers:true,
        title: "Table of Contents",
        showLeafIcon: true,
        showNodeIcon: true,
        zoomToScaleText: "Zoom to scale",
        expandOnStartup: true,
        toggleAllLayersOnText: 'All layers on',
        toggleAllLayersOffText: 'All layers off',
        initToggleAllLayers: true,
        showAllLayersOff: false,
        showAllLayersOn: false,
        expandOnEnabledLayer:false
    },
    constructor: function (config){
        config.details.useExtLayout = true;
        viewer.components.TOC.superclass.constructor.call(this, config);
        this.initConfig(config);
        /*backwards compatible, if 'showToggleAllLayers' is configured in the past
        both toggle all layers buttons must be shown*/
        if (config.showToggleAllLayers!==undefined){
            this.showAllLayersOff=config.showToggleAllLayers;
            this.showAllLayersOn=config.showToggleAllLayers;
        }
        this.toggleAllLayersState = this.config.initToggleAllLayers;
        this.renderButton();
        this.loadTree();
        this.loadInitLayers();
        this.config.viewerController.addListener(viewer.viewercontroller.controller.Event.ON_SELECTEDCONTENT_CHANGE,this.selectedContentChanged,this);
        this.config.viewerController.mapComponent.getMap().addListener(viewer.viewercontroller.controller.Event.ON_FINISHED_CHANGE_EXTENT,this.extentChanged,this);
        this.config.viewerController.mapComponent.getMap().addListener(viewer.viewercontroller.controller.Event.ON_LAYER_VISIBILITY_CHANGED,this.layerVisibilityChanged,this);
        return this;
    },
    // Build the tree
    loadTree : function(){
        // Get the current state of the map
        this.backgroundLayers = new Array();
        this.selectedContent = this.config.viewerController.app.selectedContent;
        this.appLayers = this.config.viewerController.app.appLayers;
        this.levels = this.config.viewerController.app.levels;
        this.services = this.config.viewerController.app.services;
        var me = this;
        Ext.QuickTips.init();
        this.qtips = new Array();
        var store = Ext.create('Ext.data.TreeStore', {
            model: 'Maps',
            root: {
                text: 'Root',
                expanded: me.config.expandOnStartup,
                checked: false,
                children: []
            }
        });

        store.addListener("beforeexpand",this.beforeExpand, this);
        store.addListener("expand",this.onExpand,this);

        var title = "";
        if(this.config.title && !this.config.viewerController.layoutManager.isTabComponent(this.name) && !this.config.isPopup) title = this.config.title;

        var tools = [];
        // Only if 'showHelpButton' configuration is present and not set to "false" we will show the help button
        if(this.config && this.config.hasOwnProperty('showHelpButton') && this.config.showHelpButton !== "false") {
            tools = [{
                type:'help',
                handler: function(event, toolEl, panel){
                    me.config.viewerController.showHelp(me.config);
                }
            }];
        }

        var dockedItems = [];
        if(this.showAllLayersOn || this.showAllLayersOff){
            dockedItems = [
                {
                    xtype: 'toolbar',
                    dock: 'top',
                    layout: {
                        pack: 'end'
                    },
                    items: [
                        {
                            id: 'toggleAllLayersButton',
                            text: me.toggleAllLayersState ? me.config.toggleAllLayersOnText:me.config.toggleAllLayersOffText,<commit_msg>Fixed #312: eventname changed to 'nodeexpand' and 'nodebeforeexpand'.<commit_after>/*
 * Copyright (C) 2012-2013 B3Partners B.V.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * TOC component
 * Creates a Table of comtents Component
 * @author <a href="mailto:<EMAIL>"><NAME>onen</a>
 */

Ext.define('Maps', {
    extend: 'Ext.data.TreeModel',
    fields: [
        // Added convert function to icon
        {name: 'icon', type: 'string', convert: function(fieldName, record) {
            if(record.get('leaf')) {
                return contextPath + '/viewer-html/components/resources/images/selectionModule/map.png';
            }
            return contextPath + '/viewer-html/components/resources/images/selectionModule/folder.png';
        }}
    ]
});

Ext.define ("viewer.components.TOC",{
    extend: "viewer.components.Component",
    panel: null,
    buttonBar: null,
    selectedContent : null,
    appLayers :  null,
    service : null,
    levels : null,
    backgroundLayers: null,
    // popup:null,
    qtips:null,
    toggleAllLayersState:true,
    config: {
        label: null,
        iconUrl: null,
        tooltip: null,
        groupCheck:true,
        layersChecked:true,
        showBaselayers:true,
        title: "Table of Contents",
        showLeafIcon: true,
        showNodeIcon: true,
        zoomToScaleText: "Zoom to scale",
        expandOnStartup: true,
        toggleAllLayersOnText: 'All layers on',
        toggleAllLayersOffText: 'All layers off',
        initToggleAllLayers: true,
        showAllLayersOff: false,
        showAllLayersOn: false,
        expandOnEnabledLayer:false
    },
    constructor: function (config){
        config.details.useExtLayout = true;
        viewer.components.TOC.superclass.constructor.call(this, config);
        this.initConfig(config);
        /*backwards compatible, if 'showToggleAllLayers' is configured in the past
        both toggle all layers buttons must be shown*/
        if (config.showToggleAllLayers!==undefined){
            this.showAllLayersOff=config.showToggleAllLayers;
            this.showAllLayersOn=config.showToggleAllLayers;
        }
        this.toggleAllLayersState = this.config.initToggleAllLayers;
        this.renderButton();
        this.loadTree();
        this.loadInitLayers();
        this.config.viewerController.addListener(viewer.viewercontroller.controller.Event.ON_SELECTEDCONTENT_CHANGE,this.selectedContentChanged,this);
        this.config.viewerController.mapComponent.getMap().addListener(viewer.viewercontroller.controller.Event.ON_FINISHED_CHANGE_EXTENT,this.extentChanged,this);
        this.config.viewerController.mapComponent.getMap().addListener(viewer.viewercontroller.controller.Event.ON_LAYER_VISIBILITY_CHANGED,this.layerVisibilityChanged,this);
        return this;
    },
    // Build the tree
    loadTree : function(){
        // Get the current state of the map
        this.backgroundLayers = new Array();
        this.selectedContent = this.config.viewerController.app.selectedContent;
        this.appLayers = this.config.viewerController.app.appLayers;
        this.levels = this.config.viewerController.app.levels;
        this.services = this.config.viewerController.app.services;
        var me = this;
        Ext.QuickTips.init();
        this.qtips = new Array();
        var store = Ext.create('Ext.data.TreeStore', {
            model: 'Maps',
            root: {
                text: 'Root',
                expanded: me.config.expandOnStartup,
                checked: false,
                children: []
            }
        });

        store.addListener("nodebeforeexpand",this.beforeExpand, this);
        store.addListener("nodeexpand",this.onExpand,this);

        var title = "";
        if(this.config.title && !this.config.viewerController.layoutManager.isTabComponent(this.name) && !this.config.isPopup) title = this.config.title;

        var tools = [];
        // Only if 'showHelpButton' configuration is present and not set to "false" we will show the help button
        if(this.config && this.config.hasOwnProperty('showHelpButton') && this.config.showHelpButton !== "false") {
            tools = [{
                type:'help',
                handler: function(event, toolEl, panel){
                    me.config.viewerController.showHelp(me.config);
                }
            }];
        }

        var dockedItems = [];
        if(this.showAllLayersOn || this.showAllLayersOff){
            dockedItems = [
                {
                    xtype: 'toolbar',
                    dock: 'top',
                    layout: {
                        pack: 'end'
                    },
                    items: [
                        {
                            id: 'toggleAllLayersButton',
                            text: me.toggleAllLayersState ? me.config.toggleAllLayersOnText:me.config.toggleAllLayersOffText,
{'fraction_non_alphanumeric': 0.10326285089318264, 'fraction_numerical': 0.002096244987240248, 'mean_word_length': 2.3281771307249013, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3516854', 'n_tokens_mistral': 3092, 'n_tokens_neox': 2963, 'n_words': 684}