root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / ProjectDocumentFactory.java @ 8159
History | View | Annotate | Download (4.89 KB)
1 |
package com.iver.cit.gvsig.project.documents; |
---|---|
2 |
|
3 |
import java.security.KeyException; |
4 |
import java.util.Hashtable; |
5 |
import java.util.Map; |
6 |
|
7 |
import javax.swing.ImageIcon; |
8 |
|
9 |
import com.iver.andami.PluginServices; |
10 |
import com.iver.cit.gvsig.project.Project; |
11 |
import com.iver.cit.gvsig.project.documents.contextMenu.AbstractDocumentContextMenuAction; |
12 |
import com.iver.utiles.XMLEntity; |
13 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
14 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
15 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
16 |
import com.iver.utiles.extensionPoints.IExtensionBuilder; |
17 |
|
18 |
|
19 |
/**
|
20 |
* Factory of ProjectDocument.
|
21 |
*
|
22 |
* @author Vicente Caballero Navarro
|
23 |
*/
|
24 |
public abstract class ProjectDocumentFactory implements IExtensionBuilder { |
25 |
/**
|
26 |
* Returns the load priority of the ProjectDocument.
|
27 |
*
|
28 |
* @return Priority.
|
29 |
*/
|
30 |
public int getPriority() { |
31 |
return 10; |
32 |
} |
33 |
|
34 |
/**
|
35 |
* Returns the priority of the ProjectDocument in the project window list.
|
36 |
*
|
37 |
* @return Priority.
|
38 |
*/
|
39 |
public int getListPriority() { |
40 |
return 10; |
41 |
} |
42 |
|
43 |
/**
|
44 |
* Returns image of button.
|
45 |
*
|
46 |
* @return Image button.
|
47 |
*/
|
48 |
public abstract ImageIcon getButtonIcon(); |
49 |
|
50 |
/**
|
51 |
* Returns image of selected button.
|
52 |
*
|
53 |
* @return Image button.
|
54 |
*/
|
55 |
public abstract ImageIcon getSelectedButtonIcon(); |
56 |
|
57 |
/**
|
58 |
* Returns the name of ProjectDocument.
|
59 |
*
|
60 |
* @return Name of ProjectDocument.
|
61 |
*/
|
62 |
public String getNameType() { |
63 |
return PluginServices.getText(this, "documento"); |
64 |
} |
65 |
|
66 |
/**
|
67 |
* Create a new ProjectDocument.
|
68 |
*
|
69 |
* @param project Opened project.
|
70 |
*
|
71 |
* @return ProjectDocument.
|
72 |
*/
|
73 |
public abstract ProjectDocument create(Project project); |
74 |
|
75 |
/**
|
76 |
* Introdece a gui to be able from the characteristics that we want a ProjectDocument
|
77 |
*
|
78 |
* @param project present Project.
|
79 |
*
|
80 |
* @return new ProjectDocument.
|
81 |
*/
|
82 |
public ProjectDocument createFromGUI(Project project) {
|
83 |
return create(project);
|
84 |
} |
85 |
|
86 |
/**
|
87 |
* Returns the name of registration in the point of extension.
|
88 |
*
|
89 |
* @return Name of registration
|
90 |
*/
|
91 |
public abstract String getRegisterName(); |
92 |
|
93 |
/**
|
94 |
* Create a ProjectDocumentFactory.
|
95 |
*
|
96 |
* @return ProjectDocumentFactory.
|
97 |
*/
|
98 |
public Object create() { |
99 |
return this; |
100 |
} |
101 |
|
102 |
/**
|
103 |
* Create a ProjectDocumentFactory.
|
104 |
*
|
105 |
* @param args
|
106 |
*
|
107 |
* @return ProjectDocumentFactory.
|
108 |
*/
|
109 |
public Object create(Object[] args) { |
110 |
return this; |
111 |
} |
112 |
|
113 |
/**
|
114 |
* Create a ProjectDocumentFactory.
|
115 |
*
|
116 |
* @param args
|
117 |
*
|
118 |
* @return ProjectDocumentFactory.
|
119 |
*/
|
120 |
public Object create(Map args) { |
121 |
return this; |
122 |
} |
123 |
|
124 |
/**
|
125 |
* Registers in the points of extension the Factory with alias.
|
126 |
*
|
127 |
* @param registerName Register name.
|
128 |
* @param obj Class of register.
|
129 |
* @param alias Alias.
|
130 |
*/
|
131 |
public static void register(String registerName, Object obj, String alias) { |
132 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
133 |
extensionPoints.add("Documents", registerName, obj);
|
134 |
|
135 |
ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get( |
136 |
"Documents"));
|
137 |
|
138 |
try {
|
139 |
extPoint.addAlias(registerName, alias); |
140 |
} catch (KeyException e) { |
141 |
e.printStackTrace(); |
142 |
} |
143 |
} |
144 |
|
145 |
/**Registers in the points of extension the Factory
|
146 |
*
|
147 |
* @param registerName Register name.
|
148 |
* @param obj Class of register.
|
149 |
*/
|
150 |
public static void register(String registerName, Object obj) { |
151 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
152 |
extensionPoints.add("Documents", registerName, obj);
|
153 |
} |
154 |
|
155 |
/**
|
156 |
* Register an action for the document.
|
157 |
*
|
158 |
* This actions will be appears in the context menu of
|
159 |
* the project document list.
|
160 |
*
|
161 |
*
|
162 |
* @param documentRegisterName
|
163 |
* @param actionName
|
164 |
* @param action
|
165 |
*/
|
166 |
public static void registerAction(String documentRegisterName, String actionName, AbstractDocumentContextMenuAction action) { |
167 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
168 |
extensionPoints.add("DocumentActions_"+documentRegisterName, actionName, action);
|
169 |
} |
170 |
/**
|
171 |
* Try to resolve the documents conflicts before perform an import action
|
172 |
*
|
173 |
* @param root the XML document
|
174 |
* @param project the project
|
175 |
* @param conflicts Hashtable
|
176 |
* - keys: documents register name.
|
177 |
* - values: Hashtable
|
178 |
* (keys = index of the child in the xml group of the XML,
|
179 |
* values = XMLEntity in conflict)
|
180 |
*
|
181 |
* @return true if all the conflicts are resolved , else false
|
182 |
*/
|
183 |
public abstract boolean resolveImportXMLConflicts(XMLEntity root,Project project, Hashtable conflicts); |
184 |
} |