svn-gvsig-desktop / trunk / frameworks / _fwAndami / src / com / iver / andami / ui / mdiManager / MDIManagerFactory.java @ 598
History | View | Annotate | Download (2.25 KB)
1 |
package com.iver.andami.ui.mdiManager; |
---|---|
2 |
|
3 |
import com.iver.andami.plugins.PluginClassLoader; |
4 |
import com.iver.andami.plugins.config.generate.SkinExtension; |
5 |
|
6 |
import org.apache.log4j.Logger; |
7 |
|
8 |
|
9 |
/**
|
10 |
* Se encarga de la creaci?n de la clase Skin.
|
11 |
*
|
12 |
* @author Fernando Gonz?lez Cort?s
|
13 |
*/
|
14 |
public class MDIManagerFactory { |
15 |
private static SkinExtension skinExtension = null; |
16 |
private static PluginClassLoader loader = null; |
17 |
private static MDIManager mdiManager = null; |
18 |
private static Logger logger = Logger.getLogger(MDIManagerFactory.class.getName()); |
19 |
|
20 |
/**
|
21 |
* DOCUMENT ME!
|
22 |
*
|
23 |
* @param extension DOCUMENT ME!
|
24 |
* @param loader DOCUMENT ME!
|
25 |
*/
|
26 |
public static void setSkinExtension(SkinExtension extension, |
27 |
PluginClassLoader loader) { |
28 |
MDIManagerFactory.loader = loader; |
29 |
MDIManagerFactory.skinExtension = extension; |
30 |
} |
31 |
|
32 |
/**
|
33 |
* Obtiene una referencia al Skin cargado. El skin cargado es un singleton, se
|
34 |
* devuelve la misma instancia a todas las invocaciones de ?ste m?todo
|
35 |
*
|
36 |
* @return referencia al skin cargado
|
37 |
*/
|
38 |
public static MDIManager createManager() { |
39 |
if (mdiManager != null) return mdiManager; |
40 |
|
41 |
if (skinExtension == null) { |
42 |
throw new NoSkinExtensionException("No skin extension in the plugins."); |
43 |
} else {
|
44 |
try {
|
45 |
mdiManager = (MDIManager) loader.loadClass(skinExtension.getClassName()) |
46 |
.newInstance(); |
47 |
return mdiManager;
|
48 |
} catch (InstantiationException e) { |
49 |
logger.error("No se pudo instanciar la clase skin", e);
|
50 |
|
51 |
// return new NewSkin();
|
52 |
} catch (IllegalAccessException e) { |
53 |
logger.error("No se pudo acceder a la clase skin", e);
|
54 |
|
55 |
// return new NewSkin();
|
56 |
} catch (ClassNotFoundException e) { |
57 |
logger.error("No se pudo encontrar la clase skin", e);
|
58 |
|
59 |
// return new NewSkin();
|
60 |
} |
61 |
} |
62 |
|
63 |
return null; |
64 |
} |
65 |
|
66 |
/**
|
67 |
* DOCUMENT ME!
|
68 |
*
|
69 |
* @return Returns the skinExtension.
|
70 |
*/
|
71 |
public static SkinExtension getSkinExtension() { |
72 |
return skinExtension;
|
73 |
} |
74 |
} |