Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / ui / mdiManager / MDIManagerFactory.java @ 41314

History | View | Annotate | Download (3.24 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui.mdiManager;
25

    
26
import org.apache.log4j.Logger;
27
import org.gvsig.andami.messages.Messages;
28
import org.gvsig.andami.plugins.PluginClassLoader;
29
import org.gvsig.andami.plugins.config.generate.SkinExtension;
30

    
31

    
32

    
33
/**
34
 * Se encarga de la creaci?n de la clase Skin.
35
 *
36
 * @author Fernando Gonz?lez Cort?s
37
 */
38
public class MDIManagerFactory {
39
    private static SkinExtension skinExtension = null;
40
    private static PluginClassLoader loader = null;
41
    private static MDIManager mdiManager = null;
42
    private static Logger logger = Logger.getLogger(MDIManagerFactory.class.getName());
43

    
44
    public static void setSkinExtension(SkinExtension extension,
45
        PluginClassLoader loader) {
46
        MDIManagerFactory.loader = loader;
47
        MDIManagerFactory.skinExtension = extension;
48
    }
49

    
50
    /**
51
     * Obtiene una referencia al Skin cargado. El skin cargado es un singleton, se
52
     * devuelve la misma instancia a todas las invocaciones de ?ste m?todo
53
     *
54
     * @return referencia al skin cargado
55
     */
56
    public static MDIManager createManager() {
57
            if (mdiManager != null) return mdiManager;
58
            
59
        if (skinExtension == null) {
60
                throw new NoSkinExtensionException(Messages.getString("MDIManagerFactory.No_skin_extension_in_the_plugins"));
61
        } else {
62
            try {
63
                mdiManager = (MDIManager) loader.loadClass(skinExtension.getClassName())
64
                                          .newInstance();
65
                return mdiManager;
66
            } catch (InstantiationException e) {
67
                logger.error(Messages.getString("Launcher.Error_instanciando_la_extension"), e);
68

    
69
                //                return new NewSkin();
70
            } catch (IllegalAccessException e) {
71
                logger.error(Messages.getString("Launcher.Error_instanciando_la_extension"), e);
72

    
73
                //                return new NewSkin();
74
            } catch (ClassNotFoundException e) {
75
                logger.error(Messages.getString("Launcher.No_se_encontro_la_clase_de_la_extension"), e);
76

    
77
                //                return new NewSkin();
78
            }
79
        }
80
        
81
        return null;
82
    }
83

    
84
    /**
85
     * DOCUMENT ME!
86
     *
87
     * @return Returns the skinExtension.
88
     */
89
    public static SkinExtension getSkinExtension() {
90
        return skinExtension;
91
    }
92
}