root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / layout / fframes / FrameFactory.java @ 29596
History | View | Annotate | Download (2.92 KB)
1 |
package org.gvsig.app.project.documents.layout.fframes; |
---|---|
2 |
|
3 |
import java.util.Iterator; |
4 |
import java.util.Map; |
5 |
|
6 |
import org.gvsig.andami.PluginServices; |
7 |
import org.gvsig.andami.messages.NotificationManager; |
8 |
import org.gvsig.tools.ToolsLocator; |
9 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
10 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
11 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
12 |
|
13 |
|
14 |
/**
|
15 |
* Factory of FFrame.
|
16 |
*
|
17 |
* @author Vicente Caballero Navarro
|
18 |
*/
|
19 |
public abstract class FrameFactory implements ExtensionBuilder { |
20 |
|
21 |
public static IFFrame createFrameFromName(String s) { |
22 |
|
23 |
Iterator<Extension> iterator = ToolsLocator.getExtensionPointManager()
|
24 |
.get( |
25 |
"FFrames").iterator();
|
26 |
while (iterator.hasNext()) {
|
27 |
try {
|
28 |
FrameFactory frameFactory = (FrameFactory) iterator.next() |
29 |
.create(); |
30 |
if (frameFactory.getRegisterName().equals(s)) {
|
31 |
IFFrame frame=frameFactory.createFrame(); |
32 |
if (frame == null) { |
33 |
return null; |
34 |
} |
35 |
frame.setFrameLayoutFactory(frameFactory); |
36 |
return frame;
|
37 |
} |
38 |
} catch (Exception e) { |
39 |
NotificationManager.addError(e); |
40 |
} |
41 |
} |
42 |
return null; |
43 |
} |
44 |
|
45 |
|
46 |
/**
|
47 |
* Returns the name of FFrame.
|
48 |
*
|
49 |
* @return Name of fframe.
|
50 |
*/
|
51 |
public String getNameType() { |
52 |
return PluginServices.getText(this, "frame"); |
53 |
} |
54 |
|
55 |
/**
|
56 |
* Create a new IFFrame.
|
57 |
*
|
58 |
* @return IFFrame.
|
59 |
*/
|
60 |
public abstract IFFrame createFrame(); |
61 |
|
62 |
/**
|
63 |
* Returns the name of registration in the point of extension.
|
64 |
*
|
65 |
* @return Name of registration
|
66 |
*/
|
67 |
public abstract String getRegisterName(); |
68 |
|
69 |
/**
|
70 |
* Create a FrameLayoutFactory.
|
71 |
*
|
72 |
* @return FrameLayoutFactory.
|
73 |
*/
|
74 |
public Object create() { |
75 |
return this; |
76 |
} |
77 |
|
78 |
/**
|
79 |
* Create a FrameLayoutFactory.
|
80 |
*
|
81 |
* @param args
|
82 |
*
|
83 |
* @return FrameLayoutFactory.
|
84 |
*/
|
85 |
public Object create(Object[] args) { |
86 |
return this; |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Create a FrameLayoutFactory.
|
91 |
*
|
92 |
* @param args
|
93 |
*
|
94 |
* @return FrameLayoutFactory.
|
95 |
*/
|
96 |
public Object create(Map args) { |
97 |
return this; |
98 |
} |
99 |
|
100 |
/**
|
101 |
* Registers in the points of extension the Factory with alias.
|
102 |
*
|
103 |
* @param registerName
|
104 |
* Register name.
|
105 |
* @param obj
|
106 |
* FrameFactory to register.
|
107 |
* @param alias
|
108 |
* Alias.
|
109 |
*/
|
110 |
public static void register(String registerName, FrameFactory obj, |
111 |
String alias) {
|
112 |
ExtensionPoint ep = ToolsLocator.getExtensionPointManager().add( |
113 |
"FFrames");
|
114 |
ep.append(registerName, "", obj);
|
115 |
if (alias != null){ |
116 |
ep.addAlias(registerName, alias); |
117 |
} |
118 |
} |
119 |
|
120 |
/**
|
121 |
* Registers in the points of extension the Factory
|
122 |
*
|
123 |
* @param registerName
|
124 |
* Register name.
|
125 |
* @param obj
|
126 |
* FrameFactory to register.
|
127 |
*/
|
128 |
public static void register(String registerName, FrameFactory obj) { |
129 |
register(registerName, obj, null);
|
130 |
} |
131 |
} |