raimund@638: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
raimund@638:  * Software engineering by Intevation GmbH
raimund@638:  *
raimund@638:  * This file is Free Software under the GNU GPL (v>=3)
raimund@638:  * and comes with ABSOLUTELY NO WARRANTY! Check out
raimund@638:  * the documentation coming with IMIS-Labordaten-Application for details.
raimund@638:  */
raimund@638: 
raimund@638: /**
dustin@742:  * This is a controller for a Map.
dustin@742:  * Maps are used in the Ortsangaben of a Probe.
raimund@638:  */
raimund@638: Ext.define('Lada.controller.Map', {
raimund@638:     extend: 'Ext.app.Controller',
raimund@638: 
raimund@638:     requires: [
raimund@638:     ],
raimund@638: 
dustin@742:     /**
dustin@742:      * Initialize the Controller
dustin@742:      * It has only one listener.
dustin@742:      */
raimund@638:     init: function() {
raimund@638:         this.control({
raimund@638:             'maptoolbar button[action=add]': {
raimund@638:                 click: this.addLocation
raimund@638:             }
raimund@638:         });
raimund@638:         this.callParent(arguments);
raimund@638:     },
raimund@638: 
dustin@742:     /**
dustin@742:      * addLocation is a function which can be
dustin@742:      * used to add an location to create a new Location
dustin@742:      * with the help of the map.
dustin@742:      * The function uses {@link Lada.view.panel.Map#activateDraw}
dustin@742:      */
raimund@638:     addLocation: function(button) {
raimund@638:         var mapPanel = button.up('map');
raimund@638:         var details = button.up('window').down('locationform');
raimund@638:         var newLocation = Ext.create('Lada.model.Location');
raimund@638:         details.setRecord(newLocation);
raimund@638:         details.setReadOnly(false);
raimund@638: 
raimund@638:         mapPanel.activateDraw(newLocation);
raimund@638:     }
raimund@638: });