/* (C) GeoBasis-DE/LGB
 * Copyright by Landesvermessung und Geobasisinformation Brandenburg (LGB)
 *
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * LICENSE for details.
 */

Ext.define('LGB.ext4map.view.SaveFile', {
    extend: 'Ext.window.Window',
    alias: 'widget.geofilesave',
    requires: [ 'Ext.form.Panel'],

    /**
     * @cfg
     * The window title.
     */
    title: 'Datei anzeigen',

    /**
     * @cfg
     * The window width.
     */
    width: 370,

    /**
     * @cfg
     * The window layout.
     */
    layout: 'fit',

    /**
     * @cfg
     * Automaticaly show the window.
     */
    autoShow: true,

    /**
     * @cfg
     * The modality of the window.
     */
    modal: true,

    /**
     * @cfg
     * True to constrain this window within its containing element.
     */
    constrain: true,

    fileTypes: null,

    layers: null,

    /**
     * @private
     * Initialize the view.
     */
    initComponent: function() {
        var me = this;
        this.fileTypes = Ext.create('Ext.data.Store', {
            fields: ['id', 'name'],
            data: [{
                'id': 'csv', 'name': 'CSV'
            }, {
                'id': 'kml', 'name': 'KML'
            }, {
                'id': 'shp', 'name': 'Shapefile'
            }, {
                'id': 'json', 'name': 'GeoJSON'
            }, {
                'id': 'txt', 'name': 'WKT'
            }]
        });
        var panelItems = [];
        for (var i = 0; i < this.layers.length; i++) {
            panelItems.push({
                xtype: 'checkbox',
                fieldLabel: this.layers[i].get('name'),
                layer: this.layers[i],
                checked: true
            });
        }
        this.items = [{
            xtype: 'panel',
            layout: 'vbox',
            overflowX: 'auto',
            overflowY: 'auto',
            border: false,
            width: '100%',

            items: [{
                xtype: 'combobox',
                fieldLabel: 'Dateiformat',
                store: this.fileTypes,
                queryMode: 'memory',
                displayField: 'name',
                valueField: 'id',
                margin: 5,
                editable: false,
                value: 'csv'
            }, {
                xtype: 'label',
                margin: 5,
                text: 'Ebenen:'
            }, {
                xtype: 'panel',
                name: 'layerchoose',
                layout: 'vbox',
                border: false,
                margin: '0, 0, 0, 10',
                items: panelItems
            }]
        }];
        this.buttons = [{
            text: 'Speichern',
            action: 'savefile'
        }];
        this.callParent(arguments);
    }
});