Project

General

Profile

Download (3.15 KB) Statistics
| Branch: | Revision:

git_sitools_idoc / flarecast / workspace / client-user-3.0 / app / core / Module.js @ master

1
/*******************************************************************************
2
 * Copyright 2010-2014 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
3
 * 
4
 * This file is part of SITools2.
5
 * 
6
 * SITools2 is free software: you can redistribute it and/or modify it under the
7
 * terms of the GNU General Public License as published by the Free Software
8
 * Foundation, either version 3 of the License, or (at your option) any later
9
 * version.
10
 * 
11
 * SITools2 is distributed in the hope that it will be useful, but WITHOUT ANY
12
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
 * 
15
 * You should have received a copy of the GNU General Public License along with
16
 * SITools2. If not, see <http://www.gnu.org/licenses/>.
17
 ******************************************************************************/
18

    
19
/*global Ext, sitools, i18n, projectGlobal, alertFailure, showResponse*/
20

    
21
Ext.namespace('sitools.user.core');
22
/**
23
 * Abstract Module class
24
 * @class sitools.user.core.Module
25
 */
26
Ext.define('sitools.user.core.Module', {
27
    mixins: {
28
        observable: 'Ext.util.Observable',
29
        plugin : 'sitools.user.core.SitoolsPlugin'
30
    },
31
    
32
    config : {
33
        moduleModel : null,
34
        viewCmp : null,
35
        application : null,
36
        controllers : [] 
37
    },
38
    
39
    /**
40
     * Show the given view
41
     * 
42
     * @param view
43
     *            the view to show
44
     */
45
    show : function (view) {
46
        this.setViewCmp(view);
47
        view.type = "module";
48
        var project = Ext.getStore("ProjectStore").getProject();
49
        var navMode = this.getApplication().getController('core.NavigationModeFactory').getNavigationMode(project.get("navigationMode"));
50
        
51
        navMode.openModule(view, this.getModuleModel());
52
        view.fireEvent("registermodule", this, view);
53
    },
54
    
55
    /**
56
     * Method to override to initialize the module
57
     */
58
    init : Ext.emptyFn,
59

    
60
    /**
61
     * Initialize the module
62
     *
63
     * @param application
64
     *            the application
65
     * @param moduleModel moduleModel
66
     * @param callback the callback called when the module is initialised
67
     * @param scope the scope of the callback
68
     */
69
    create : function (application, moduleModel, callback, scope) {
70
        this.setModuleModel(moduleModel);
71
        this.setApplication(application);
72
        // initialize all controllers
73
        if (!Ext.isEmpty(this.getControllers())) {
74
            Ext.each(this.getControllers(), function (controller) {
75
                this.getApplication().getController(controller);
76
            }, this);
77
        }
78
        
79
        //load javascripts, then css then internationalization
80
        this.loadJs(callback, scope);
81
    },
82

    
83
    /**
84
     * Method called when a module is opened into a static DIV.
85
     */
86
    createViewForDiv : Ext.emptyFn,
87
    
88
    /**
89
     * method called when trying to save preference
90
     * @returns
91
     */
92
    _getSettings : Ext.emptyFn,
93
    
94
    /**
95
     * use to open a component linked to the module
96
     */
97
    openMyComponent : null,
98
    
99
    /**
100
     * use to delegate opening to the module itself
101
     */
102
    openMe : null
103

    
104

    
105
});