<commit_before>  /**
 * Copyright (c) 2009-2010 The Open Planning Project
 *
 * @requires GeoExplorer.js
 */

/** api: (define)
 *  module = GeoExplorer
 *  class = Embed
 *  base_link = GeoExplorer
 */
Ext.namespace("GeoExplorer");

/** api: constructor
 *  ..class:: GeoExplorer.Viewer(config)
 *
 *  Create a GeoExplorer application suitable for embedding in larger pages.
 */
GeoExplorer.GraceViewer = Ext.extend(GeoExplorer, {
    /**
     * Property: featuresPanel
     * {GeoExt.FeaturesPanel} the feature panel for the main viewport's map
     */
    featuresPanel: null,
    /**
     * Property: featuresTabPanel
     * {GeoExt.FeaturesPanel} the feature tab panel for the main viewport's map
     */    
    featuresTabPanel: null,

    /** private: property[featureCache]
     *  ``Object``
     */
    featureCache: null,
    
    /** private: property[user]
     *  ``Object``
     */
    user: null,

    /** api: config[useCapabilities]
     *  ``Boolean`` If set to false, no Capabilities document will be loaded.
     */
    
    featuresPanelText: "UT:Features",
    saveFeatureText: "UT:Save",
    saveSuccessfulText: "UT:Save successful",
    saveFailedText: "UT:Save failed",
    
    /** api: config[useToolbar]
     *  ``Boolean`` If set to false, no top toolbar will be rendered.
     */

    loadConfig: function(config) {
        var source;
        for (var s in config.sources) {
            source = config.sources[s];
            if (!source.ptype || /wmsc?source/.test(source.ptype)) {
                source.forceLazy = config.useCapabilities === false;
            }
            if (config.useToolbar === false) {
                var remove = true, layer;
                for (var i=config.map.layers.length-1; i>=0; --i) {
                    layer = config.map.layers[i];
                    if (layer.source == s) {
                        if (layer.visibility === false) {
                            config.map.layers.remove(layer);
                        } else {
                            remove = false;
                        }
                    }
                }
                if (remove) {
                    delete config.sources[s];
                }
            }
        }
        if (config.useToolbar !== false) {
            config.tools = (config.tools || []).concat({
                ptype: "gxp_styler",
                id: "styler",
                rasterStyling: true,
                actionTarget: undefined
            });
        }
        // load the super's super, because we don't want the default tools from
        // GeoExplorer
        GeoExplorer.superclass.loadConfig.apply(this, arguments);
    },
    
    /** private: method[initPortal]
     * Create the various parts that compose the layout.
     */
    initPortal: function() {

        // TODO: make a proper component out of this
        if (this.useMapOverlay !== false) {
            this.mapPanel.add(this.createMapOverlay());
        }

        if(this.useToolbar !== false) {
            this.toolbar = new Ext.Toolbar({
                xtype: "toolbar",
                region: "north",
                autoHeight: true,
                disabled: true,
                items: this.createTools()
            });
            this.on("ready", function() {this.toolbar.enable();}, this);
        }

	this.featuresTabPanel = new Ext.TabPanel({
                            border: false,
                            deferredRender: false,
                            resizeTabs:true, // turn on tab resizing
                            maxTabWidth: 100,
                            tabWidth:100,
                            //height:400,
                            enableTabScroll:true,
                            activeTab:0,
                            defaults: {autoScroll:true},
                            layoutOnTabChange: true
                        });
	
    // Add button save or not, according to the rights
    featureToolbar = [];
    if (!this.initialConfig.tools_enabled || this.initialConfig.tools_enabled.indexOf("edit_attr") != -1)
        featureToolbar = ["->", 
                {
                    text: this.saveFeatureText,
                    iconCls: "gxp-icon-save",
                    handler: function() {
                        jsonDataEncode = Ext.util.JSON.encode(this.featureCache);
                        Ext.Ajax.request({
                            url: this.urlWriteFeature,
                            method: 'POST',
                            params: { data :jsonDataEncode, source: this.user},
                            success: function(response, options) {
                                Ext.Msg.alert('Information', this.saveSuccessfulText);
                            },
                            failure: function(response, options) {
                                Ext.Msg.alert('Information', this.saveFailedText);
                            }
                        });
                    },
                    scope: this
                }];

	this.featuresPanel = new Ext.Panel({
            title: this.featuresPanelText,
            bodyCfg : { cls:'x-panel-body feature-panel'},
            border: false,<commit_msg>Manage return status<commit_after>  /**
 * Copyright (c) 2009-2010 The Open Planning Project
 *
 * @requires GeoExplorer.js
 */

/** api: (define)
 *  module = GeoExplorer
 *  class = Embed
 *  base_link = GeoExplorer
 */
Ext.namespace("GeoExplorer");

/** api: constructor
 *  ..class:: GeoExplorer.Viewer(config)
 *
 *  Create a GeoExplorer application suitable for embedding in larger pages.
 */
GeoExplorer.GraceViewer = Ext.extend(GeoExplorer, {
    /**
     * Property: featuresPanel
     * {GeoExt.FeaturesPanel} the feature panel for the main viewport's map
     */
    featuresPanel: null,
    /**
     * Property: featuresTabPanel
     * {GeoExt.FeaturesPanel} the feature tab panel for the main viewport's map
     */    
    featuresTabPanel: null,

    /** private: property[featureCache]
     *  ``Object``
     */
    featureCache: null,
    
    /** private: property[user]
     *  ``Object``
     */
    user: null,

    /** api: config[useCapabilities]
     *  ``Boolean`` If set to false, no Capabilities document will be loaded.
     */
    
    featuresPanelText: "UT:Features",
    saveFeatureText: "UT:Save",
    saveSuccessfulText: "UT:Save successful",
    saveFailedText: "UT:Save failed",
    
    /** api: config[useToolbar]
     *  ``Boolean`` If set to false, no top toolbar will be rendered.
     */

    loadConfig: function(config) {
        var source;
        for (var s in config.sources) {
            source = config.sources[s];
            if (!source.ptype || /wmsc?source/.test(source.ptype)) {
                source.forceLazy = config.useCapabilities === false;
            }
            if (config.useToolbar === false) {
                var remove = true, layer;
                for (var i=config.map.layers.length-1; i>=0; --i) {
                    layer = config.map.layers[i];
                    if (layer.source == s) {
                        if (layer.visibility === false) {
                            config.map.layers.remove(layer);
                        } else {
                            remove = false;
                        }
                    }
                }
                if (remove) {
                    delete config.sources[s];
                }
            }
        }
        if (config.useToolbar !== false) {
            config.tools = (config.tools || []).concat({
                ptype: "gxp_styler",
                id: "styler",
                rasterStyling: true,
                actionTarget: undefined
            });
        }
        // load the super's super, because we don't want the default tools from
        // GeoExplorer
        GeoExplorer.superclass.loadConfig.apply(this, arguments);
    },
    
    /** private: method[initPortal]
     * Create the various parts that compose the layout.
     */
    initPortal: function() {

        // TODO: make a proper component out of this
        if (this.useMapOverlay !== false) {
            this.mapPanel.add(this.createMapOverlay());
        }

        if(this.useToolbar !== false) {
            this.toolbar = new Ext.Toolbar({
                xtype: "toolbar",
                region: "north",
                autoHeight: true,
                disabled: true,
                items: this.createTools()
            });
            this.on("ready", function() {this.toolbar.enable();}, this);
        }

	this.featuresTabPanel = new Ext.TabPanel({
                            border: false,
                            deferredRender: false,
                            resizeTabs:true, // turn on tab resizing
                            maxTabWidth: 100,
                            tabWidth:100,
                            //height:400,
                            enableTabScroll:true,
                            activeTab:0,
                            defaults: {autoScroll:true},
                            layoutOnTabChange: true
                        });
	
    // Add button save or not, according to the rights
    featureToolbar = [];
    if (!this.initialConfig.tools_enabled || this.initialConfig.tools_enabled.indexOf("edit_attr") != -1)
        featureToolbar = ["->", 
                {
                    text: this.saveFeatureText,
                    iconCls: "gxp-icon-save",
                    handler: function() {
                        jsonDataEncode = Ext.util.JSON.encode(this.featureCache);
                        Ext.Ajax.request({
                            url: this.urlWriteFeature,
                            method: 'POST',
                            params: { data :jsonDataEncode, source: this.user, map_projection: this.mapPanel.map.projection.replace("EPSG:","")},
                            success: function(response, options) {
                                var modifiedOk = true;
                                if(response.responseText) {
                                    status = eval('(' + response.responseText + ')');
                                    if(status.records[0].status == false) {
                                        Ext.Msg.alert('Information', status.records[0].msg);
                                        modifiedOk = false;
                                    }
                                }
                                if(modifiedOk)
                                    Ext.Msg.alert('Information', this.saveSuccessfulText);
                            },
                            failure: function(response, options) {
                                Ext.Msg.alert('Information', this.saveFailedText);
                            }
                        });
                    },
                    scope: this
                }];

	this.featuresPanel = new Ext.Panel({
            title: this.featuresPanelText,
            bodyCfg : { cls:'x-panel-body feature-panel'},
            border: false,
{'fraction_non_alphanumeric': 0.10772284373872248, 'fraction_numerical': 0.003969686033922772, 'mean_word_length': 1.2761806981519508, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1208670', 'n_tokens_mistral': 2882, 'n_tokens_neox': 2726, 'n_words': 621}