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 @ 43911

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

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

    
77
                //                return new NewSkin();
78
            } catch (ClassNotFoundException e) {
79
                logger.error(Messages.getString("Launcher.No_se_encontro_la_clase_de_la_extension"), e);
80

    
81
                //                return new NewSkin();
82
            }
83
        }
84
        
85
        return null;
86
    }
87

    
88
    /**
89
     * DOCUMENT ME!
90
     *
91
     * @return Returns the skinExtension.
92
     */
93
    public static SkinExtension getSkinExtension() {
94
        return skinExtension;
95
    }
96
}