root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / ProjectDocumentFactory.java @ 7738
History | View | Annotate | Download (3.43 KB)
1 | 7343 | caballero | package com.iver.cit.gvsig.project.documents; |
---|---|---|---|
2 | |||
3 | 7738 | jaume | import java.security.KeyException; |
4 | import java.util.Map; |
||
5 | 7343 | caballero | |
6 | 7738 | jaume | import javax.swing.ImageIcon; |
7 | 7343 | caballero | |
8 | 7738 | jaume | import com.iver.andami.PluginServices; |
9 | import com.iver.cit.gvsig.project.Project; |
||
10 | 7343 | caballero | import com.iver.utiles.extensionPoints.ExtensionPoint; |
11 | import com.iver.utiles.extensionPoints.ExtensionPoints; |
||
12 | import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
||
13 | import com.iver.utiles.extensionPoints.IExtensionBuilder; |
||
14 | |||
15 | |||
16 | /**
|
||
17 | * Factory of ProjectDocument.
|
||
18 | *
|
||
19 | * @author Vicente Caballero Navarro
|
||
20 | */
|
||
21 | public abstract class ProjectDocumentFactory implements IExtensionBuilder { |
||
22 | /**
|
||
23 | * Returns the priority of de ProjectDocument.
|
||
24 | *
|
||
25 | * @return Priority.
|
||
26 | */
|
||
27 | public int getPriority() { |
||
28 | return 10; |
||
29 | } |
||
30 | |||
31 | /**
|
||
32 | * Returns image of button.
|
||
33 | *
|
||
34 | * @return Image button.
|
||
35 | */
|
||
36 | public abstract ImageIcon getButtonIcon(); |
||
37 | |||
38 | /**
|
||
39 | * Returns image of selected button.
|
||
40 | *
|
||
41 | * @return Image button.
|
||
42 | */
|
||
43 | public abstract ImageIcon getSelectedButtonIcon(); |
||
44 | |||
45 | /**
|
||
46 | * Returns the name of ProjectDocument.
|
||
47 | *
|
||
48 | * @return Name of ProjectDocument.
|
||
49 | */
|
||
50 | public String getNameType() { |
||
51 | return PluginServices.getText(this, "documento"); |
||
52 | } |
||
53 | |||
54 | /**
|
||
55 | * Create a new ProjectDocument.
|
||
56 | *
|
||
57 | * @param project Opened project.
|
||
58 | *
|
||
59 | * @return ProjectDocument.
|
||
60 | */
|
||
61 | public abstract ProjectDocument create(Project project); |
||
62 | |||
63 | /**
|
||
64 | * Introdece a gui to be able from the characteristics that we want a ProjectDocument
|
||
65 | *
|
||
66 | * @param project present Project.
|
||
67 | *
|
||
68 | * @return new ProjectDocument.
|
||
69 | */
|
||
70 | public ProjectDocument createFromGUI(Project project) {
|
||
71 | return create(project);
|
||
72 | } |
||
73 | |||
74 | /**
|
||
75 | * Returns the name of registration in the point of extension.
|
||
76 | *
|
||
77 | * @return Name of registration
|
||
78 | */
|
||
79 | public abstract String getRegisterName(); |
||
80 | |||
81 | /**
|
||
82 | * Create a ProjectDocumentFactory.
|
||
83 | *
|
||
84 | * @return ProjectDocumentFactory.
|
||
85 | */
|
||
86 | public Object create() { |
||
87 | return this; |
||
88 | } |
||
89 | |||
90 | /**
|
||
91 | * Create a ProjectDocumentFactory.
|
||
92 | *
|
||
93 | * @param args
|
||
94 | *
|
||
95 | * @return ProjectDocumentFactory.
|
||
96 | */
|
||
97 | public Object create(Object[] args) { |
||
98 | return this; |
||
99 | } |
||
100 | |||
101 | /**
|
||
102 | * Create a ProjectDocumentFactory.
|
||
103 | *
|
||
104 | * @param args
|
||
105 | *
|
||
106 | * @return ProjectDocumentFactory.
|
||
107 | */
|
||
108 | public Object create(Map args) { |
||
109 | return this; |
||
110 | } |
||
111 | |||
112 | /**
|
||
113 | * Registers in the points of extension the Factory with alias.
|
||
114 | *
|
||
115 | * @param registerName Register name.
|
||
116 | * @param obj Class of register.
|
||
117 | * @param alias Alias.
|
||
118 | */
|
||
119 | public static void register(String registerName, Object obj, String alias) { |
||
120 | ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
||
121 | extensionPoints.add("Documents", registerName, obj);
|
||
122 | |||
123 | ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get( |
||
124 | "Documents"));
|
||
125 | |||
126 | try {
|
||
127 | extPoint.addAlias(registerName, alias); |
||
128 | } catch (KeyException e) { |
||
129 | e.printStackTrace(); |
||
130 | } |
||
131 | } |
||
132 | |||
133 | /**Registers in the points of extension the Factory
|
||
134 | *
|
||
135 | * @param registerName Register name.
|
||
136 | * @param obj Class of register.
|
||
137 | */
|
||
138 | public static void register(String registerName, Object obj) { |
||
139 | ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
||
140 | extensionPoints.add("Documents", registerName, obj);
|
||
141 | } |
||
142 | } |