root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / ProjectMapFactory.java @ 24962
History | View | Annotate | Download (17.1 KB)
1 | 7343 | caballero | package com.iver.cit.gvsig.project.documents.layout; |
---|---|---|---|
2 | |||
3 | 7758 | jmvivo | import java.awt.Component; |
4 | 7738 | jaume | import java.text.DateFormat; |
5 | 7758 | jmvivo | import java.util.Arrays; |
6 | import java.util.Comparator; |
||
7 | 7738 | jaume | import java.util.Date; |
8 | 7758 | jmvivo | import java.util.Enumeration; |
9 | import java.util.Hashtable; |
||
10 | 7343 | caballero | |
11 | 7738 | jaume | import javax.swing.ImageIcon; |
12 | 7758 | jmvivo | import javax.swing.JOptionPane; |
13 | 7738 | jaume | |
14 | 20994 | jmvivo | import org.gvsig.fmap.mapcontrol.MapControl; |
15 | 24962 | vcaballero | import org.gvsig.project.document.table.FeatureTableDocumentFactory; |
16 | 20994 | jmvivo | |
17 | 7738 | jaume | import com.iver.andami.PluginServices; |
18 | 14821 | jmvivo | import com.iver.cit.gvsig.AddLayer; |
19 | 7343 | caballero | import com.iver.cit.gvsig.project.Project; |
20 | import com.iver.cit.gvsig.project.documents.ProjectDocument; |
||
21 | import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory; |
||
22 | 7758 | jmvivo | import com.iver.cit.gvsig.project.documents.contextMenu.actions.CopyDocumentContextMenuAction; |
23 | import com.iver.cit.gvsig.project.documents.contextMenu.actions.CutDocumentContextMenuAction; |
||
24 | import com.iver.cit.gvsig.project.documents.contextMenu.actions.PasteDocumentContextMenuAction; |
||
25 | 9392 | caballero | import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
26 | 7758 | jmvivo | import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory; |
27 | import com.iver.utiles.XMLEntity; |
||
28 | 7343 | caballero | |
29 | |||
30 | /**
|
||
31 | * Factory of maps.
|
||
32 | *
|
||
33 | * @author Vicente Caballero Navarro
|
||
34 | */
|
||
35 | public class ProjectMapFactory extends ProjectDocumentFactory { |
||
36 | 7379 | caballero | public static String registerName = "ProjectMap"; |
37 | 7343 | caballero | |
38 | /**
|
||
39 | * Returns image of button.
|
||
40 | *
|
||
41 | * @return Image button.
|
||
42 | */
|
||
43 | public ImageIcon getButtonIcon() { |
||
44 | 14821 | jmvivo | // return new ImageIcon(ProjectMap.class.getClassLoader().getResource("images/mapas.png"));
|
45 | 15945 | jmvivo | return PluginServices.getIconTheme().get("document-map-icon"); |
46 | 7343 | caballero | } |
47 | |||
48 | /**
|
||
49 | * Returns image of selected button.
|
||
50 | *
|
||
51 | * @return Image button.
|
||
52 | */
|
||
53 | public ImageIcon getSelectedButtonIcon() { |
||
54 | 14821 | jmvivo | // return new ImageIcon(ProjectMap.class.getClassLoader().getResource("images/mapas_sel.png"));
|
55 | 15945 | jmvivo | return PluginServices.getIconTheme().get("document-map-icon-sel"); |
56 | 7343 | caballero | } |
57 | |||
58 | /**
|
||
59 | * Create a new ProjectDocument.
|
||
60 | *
|
||
61 | * @param project Opened project.
|
||
62 | *
|
||
63 | * @return ProjectDocument.
|
||
64 | */
|
||
65 | 9392 | caballero | // public ProjectDocument create(Project project) {
|
66 | // String layoutName = "";
|
||
67 | // String aux = PluginServices.getText(this, "untitled");
|
||
68 | // layoutName = aux + " - " + ProjectMap.numMaps++;
|
||
69 | //
|
||
70 | // if (project != null) {
|
||
71 | // // Buscamos si alguna vista ya ten?a este nombre:
|
||
72 | // while (existLayoutName(project, layoutName)) {
|
||
73 | // layoutName = aux + " - " + ProjectView.numViews++;
|
||
74 | // }
|
||
75 | // }
|
||
76 | //
|
||
77 | // ProjectMap map = createMap(layoutName);
|
||
78 | // map.setModel(new Layout());
|
||
79 | // map.getModel().setProjectMap(map);
|
||
80 | // map.setProject(project, 0);
|
||
81 | // map.setProjectDocumentFactory(this);
|
||
82 | //
|
||
83 | // return map;
|
||
84 | // }
|
||
85 | 7343 | caballero | public ProjectDocument create(Project project) {
|
86 | 9690 | caballero | String mapName = ""; |
87 | String aux = PluginServices.getText(this, "untitled"); |
||
88 | int numMaps=((Integer)ProjectDocument.NUMS.get(registerName)).intValue(); |
||
89 | mapName = aux + " - " + numMaps++;
|
||
90 | if (project != null) { |
||
91 | while (existName(project, mapName)) {
|
||
92 | mapName = aux + " - " + numMaps++;
|
||
93 | } |
||
94 | } |
||
95 | ProjectDocument.NUMS.put(registerName,new Integer(numMaps)); |
||
96 | ProjectMap map = createMap(mapName); |
||
97 | 7343 | caballero | map.setModel(new Layout());
|
98 | map.getModel().setProjectMap(map); |
||
99 | map.setProject(project, 0);
|
||
100 | 7758 | jmvivo | map.setProjectDocumentFactory(this);
|
101 | 7343 | caballero | |
102 | return map;
|
||
103 | } |
||
104 | 9690 | caballero | /**
|
105 | 7343 | caballero | * Returns the name of registration in the point of extension.
|
106 | *
|
||
107 | * @return Name of registration
|
||
108 | */
|
||
109 | public String getRegisterName() { |
||
110 | return registerName;
|
||
111 | } |
||
112 | |||
113 | /**
|
||
114 | * Returns the name of ProjectDocument.
|
||
115 | *
|
||
116 | * @return Name of ProjectDocument.
|
||
117 | */
|
||
118 | public String getNameType() { |
||
119 | return PluginServices.getText(this, "Mapa"); |
||
120 | } |
||
121 | |||
122 | /**
|
||
123 | * Create a ne ProjectMap
|
||
124 | *
|
||
125 | * @param baseName name
|
||
126 | *
|
||
127 | * @return ProjectMap.
|
||
128 | */
|
||
129 | 9690 | caballero | private static ProjectMap createMap(String baseName) { |
130 | 7343 | caballero | ProjectMap m = new ProjectMap();
|
131 | 9690 | caballero | m.setName(baseName); |
132 | 7343 | caballero | m.setCreationDate(DateFormat.getInstance().format(new Date())); |
133 | return m;
|
||
134 | } |
||
135 | |||
136 | /**
|
||
137 | * Registers in the points of extension the Factory with alias.
|
||
138 | *
|
||
139 | */
|
||
140 | public static void register() { |
||
141 | register(registerName, new ProjectMapFactory(),
|
||
142 | "com.iver.cit.gvsig.project.ProjectMap");
|
||
143 | 7855 | jaume | |
144 | 7758 | jmvivo | registerAction(registerName,"copy",new CopyDocumentContextMenuAction()); |
145 | registerAction(registerName,"cut",new CutDocumentContextMenuAction()); |
||
146 | registerAction(registerName,"paste",new PasteDocumentContextMenuAction()); |
||
147 | 14821 | jmvivo | |
148 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
149 | 15956 | jmvivo | "document-map-icon",
|
150 | 14821 | jmvivo | AddLayer.class.getClassLoader().getResource("images/mapas.png")
|
151 | ); |
||
152 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
153 | 15956 | jmvivo | "document-map-icon-sel",
|
154 | 14821 | jmvivo | AddLayer.class.getClassLoader().getResource("images/mapas_sel.png")
|
155 | ); |
||
156 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
157 | 14821 | jmvivo | "neresize-icon",
|
158 | AddLayer.class.getClassLoader().getResource("images/NEResize.png")
|
||
159 | ); |
||
160 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
161 | 14821 | jmvivo | "eresize-icon",
|
162 | AddLayer.class.getClassLoader().getResource("images/EResize.png")
|
||
163 | ); |
||
164 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
165 | 14821 | jmvivo | "nresize-icon",
|
166 | AddLayer.class.getClassLoader().getResource("images/NResize.png")
|
||
167 | ); |
||
168 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
169 | 14821 | jmvivo | "move-icon",
|
170 | AddLayer.class.getClassLoader().getResource("images/Move.png")
|
||
171 | ); |
||
172 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
173 | 14821 | jmvivo | "sereresize-icon",
|
174 | AddLayer.class.getClassLoader().getResource("images/SEResize.png")
|
||
175 | ); |
||
176 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
177 | 14821 | jmvivo | "symboltag-icon",
|
178 | AddLayer.class.getClassLoader().getResource("images/symbolTag.gif")
|
||
179 | ); |
||
180 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
181 | 14821 | jmvivo | "move-icon",
|
182 | AddLayer.class.getClassLoader().getResource("images/Move.png")
|
||
183 | ); |
||
184 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
185 | 14821 | jmvivo | "numero-icon",
|
186 | AddLayer.class.getClassLoader().getResource("images/numero.png")
|
||
187 | ); |
||
188 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
189 | 14821 | jmvivo | "barra1-icon",
|
190 | AddLayer.class.getClassLoader().getResource("images/barra1.png")
|
||
191 | ); |
||
192 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
193 | 14821 | jmvivo | "barra2-icon",
|
194 | AddLayer.class.getClassLoader().getResource("images/barra2.png")
|
||
195 | ); |
||
196 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
197 | 14821 | jmvivo | "barra3-icon",
|
198 | AddLayer.class.getClassLoader().getResource("images/barra3.png")
|
||
199 | ); |
||
200 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
201 | 14821 | jmvivo | "text-left-icon",
|
202 | AddLayer.class.getClassLoader().getResource("images/left.PNG")
|
||
203 | ); |
||
204 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
205 | 14821 | jmvivo | "text-center-v-icon",
|
206 | AddLayer.class.getClassLoader().getResource("images/centerV.PNG")
|
||
207 | ); |
||
208 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
209 | 14821 | jmvivo | "text-right-icon",
|
210 | AddLayer.class.getClassLoader().getResource("images/right.PNG")
|
||
211 | ); |
||
212 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
213 | 14821 | jmvivo | "left-rotation-icon",
|
214 | AddLayer.class.getClassLoader().getResource("images/leftrotation.png")
|
||
215 | ); |
||
216 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
217 | 14821 | jmvivo | "text-up-icon",
|
218 | AddLayer.class.getClassLoader().getResource("images/up.PNG")
|
||
219 | ); |
||
220 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
221 | 14821 | jmvivo | "text-center-h-icon",
|
222 | AddLayer.class.getClassLoader().getResource("images/centerH.PNG")
|
||
223 | ); |
||
224 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
225 | 14821 | jmvivo | "text-down-icon",
|
226 | AddLayer.class.getClassLoader().getResource("images/down.PNG")
|
||
227 | ); |
||
228 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
229 | 14821 | jmvivo | "text-distup-icon",
|
230 | AddLayer.class.getClassLoader().getResource("images/distUp.PNG")
|
||
231 | ); |
||
232 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
233 | 14821 | jmvivo | "text-distcenterh-icon",
|
234 | AddLayer.class.getClassLoader().getResource("images/distCenterH.PNG")
|
||
235 | ); |
||
236 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
237 | 14821 | jmvivo | "text-distdown-icon",
|
238 | AddLayer.class.getClassLoader().getResource("images/distDown.PNG")
|
||
239 | ); |
||
240 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
241 | 14821 | jmvivo | "text-distleft-icon",
|
242 | AddLayer.class.getClassLoader().getResource("images/distLeft.PNG")
|
||
243 | ); |
||
244 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
245 | 14821 | jmvivo | "text-distcenterv-icon",
|
246 | AddLayer.class.getClassLoader().getResource("images/distCenterV.PNG")
|
||
247 | ); |
||
248 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
249 | 14821 | jmvivo | "text-distright-icon",
|
250 | AddLayer.class.getClassLoader().getResource("images/distRight.PNG")
|
||
251 | ); |
||
252 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
253 | 14821 | jmvivo | "text-size-width-icon",
|
254 | AddLayer.class.getClassLoader().getResource("images/sizeWidth.PNG")
|
||
255 | ); |
||
256 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
257 | 14821 | jmvivo | "text-size-height-icon",
|
258 | AddLayer.class.getClassLoader().getResource("images/sizeHeight.PNG")
|
||
259 | ); |
||
260 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
261 | 14821 | jmvivo | "text-size-other-icon",
|
262 | AddLayer.class.getClassLoader().getResource("images/sizeOther.PNG")
|
||
263 | ); |
||
264 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
265 | 14821 | jmvivo | "text-space-right-icon",
|
266 | AddLayer.class.getClassLoader().getResource("images/spaceRight.PNG")
|
||
267 | ); |
||
268 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
269 | 14821 | jmvivo | "text-inlayout-icon",
|
270 | AddLayer.class.getClassLoader().getResource("images/inLayout.PNG")
|
||
271 | ); |
||
272 | |||
273 | //Tools
|
||
274 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
275 | 14821 | jmvivo | "rect-select-cursor",
|
276 | 15640 | jmvivo | MapControl.class.getResource("images/RectSelectCursor.gif")
|
277 | 14821 | jmvivo | ); |
278 | 15945 | jmvivo | |
279 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
280 | 14821 | jmvivo | "circle-cursor",
|
281 | AddLayer.class.getClassLoader().getResource("images/CircleCursor.png")
|
||
282 | ); |
||
283 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
284 | 14821 | jmvivo | "line-cursor",
|
285 | AddLayer.class.getClassLoader().getResource("images/LineCursor.png")
|
||
286 | ); |
||
287 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
288 | 14821 | jmvivo | "point-cursor",
|
289 | AddLayer.class.getClassLoader().getResource("images/PointCursor.png")
|
||
290 | ); |
||
291 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
292 | 14821 | jmvivo | "poligon-cursor",
|
293 | AddLayer.class.getClassLoader().getResource("images/PoligonCursor.png")
|
||
294 | ); |
||
295 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
296 | 14821 | jmvivo | "rectangle-cursor",
|
297 | AddLayer.class.getClassLoader().getResource("images/RectangleCursor.png")
|
||
298 | ); |
||
299 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
300 | 14821 | jmvivo | "crux-cursor",
|
301 | AddLayer.class.getClassLoader().getResource("images/CruxCursor.png")
|
||
302 | ); |
||
303 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
304 | 14821 | jmvivo | "layout-hand-icon",
|
305 | AddLayer.class.getClassLoader().getResource("images/LayoutHand.gif")
|
||
306 | ); |
||
307 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
308 | 14821 | jmvivo | "zoom-in-cursor",
|
309 | AddLayer.class.getClassLoader().getResource("images/ZoomInCursor.gif")
|
||
310 | ); |
||
311 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
312 | 14821 | jmvivo | "hand-icon",
|
313 | AddLayer.class.getClassLoader().getResource("images/Hand.gif")
|
||
314 | ); |
||
315 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
316 | 14821 | jmvivo | "zoom-out-cursor",
|
317 | AddLayer.class.getClassLoader().getResource("images/ZoomOutCursor.gif")
|
||
318 | ); |
||
319 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
320 | 14821 | jmvivo | "layout-zoom-in-cursor",
|
321 | AddLayer.class.getClassLoader().getResource("images/LayoutZoomInCursor.gif")
|
||
322 | ); |
||
323 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
324 | 14821 | jmvivo | "layout-zoom-out-cursor",
|
325 | AddLayer.class.getClassLoader().getResource("images/LayoutZoomOutCursor.gif")
|
||
326 | ); |
||
327 | 15640 | jmvivo | PluginServices.getIconTheme().registerDefault( |
328 | "right-rotation-icon",
|
||
329 | AddLayer.class.getClassLoader().getResource("images/rightrotation.png")
|
||
330 | ); |
||
331 | PluginServices.getIconTheme().registerDefault( |
||
332 | "point-select-cursor",
|
||
333 | MapControl.class.getResource("images/PointSelectCursor.gif")
|
||
334 | ); |
||
335 | 14821 | jmvivo | |
336 | |||
337 | 7343 | caballero | } |
338 | |||
339 | /**
|
||
340 | * Returns the priority of de ProjectDocument.
|
||
341 | *
|
||
342 | * @return Priority.
|
||
343 | */
|
||
344 | public int getPriority() { |
||
345 | return 2; |
||
346 | } |
||
347 | 7758 | jmvivo | |
348 | public boolean resolveImportXMLConflicts(XMLEntity root, Project project, Hashtable conflicts) { |
||
349 | XMLEntity xmlMaps = root.firstChild("type",this.getRegisterName()); |
||
350 | XMLEntity xmlViews = root.firstChild("type",ProjectViewFactory.registerName);
|
||
351 | 24962 | vcaballero | XMLEntity xmlTables = root.firstChild("type",FeatureTableDocumentFactory.registerName);
|
352 | 7758 | jmvivo | |
353 | Hashtable mapsConflits = (Hashtable)conflicts.get(ProjectMapFactory.registerName); |
||
354 | |||
355 | Hashtable viewsConflits = (Hashtable)conflicts.get(ProjectViewFactory.registerName); |
||
356 | |||
357 | 24962 | vcaballero | Hashtable tablesConflits = (Hashtable)conflicts.get(FeatureTableDocumentFactory.registerName); |
358 | 7758 | jmvivo | |
359 | |||
360 | if (mapsConflits != null && mapsConflits.size() > 0) { |
||
361 | int option = JOptionPane.showConfirmDialog( |
||
362 | (Component)PluginServices.getMainFrame(),
|
||
363 | "<html>"+
|
||
364 | PluginServices.getText(this,"conflicto_de_nombres_de_mapas_al_pegar") + "<br>" + |
||
365 | PluginServices.getText(this,"debera_introducir_nombres_para_los_mapas_a_pegar") + "<br>" + |
||
366 | "</html>", //Mensaje |
||
367 | PluginServices.getText(this,"pegar_mapas"),//titulo |
||
368 | JOptionPane.YES_NO_OPTION
|
||
369 | ); |
||
370 | if (option != JOptionPane.YES_OPTION) { |
||
371 | return false; |
||
372 | } |
||
373 | Enumeration en = mapsConflits.elements();
|
||
374 | while (en.hasMoreElements()) {
|
||
375 | XMLEntity map = (XMLEntity)en.nextElement(); |
||
376 | String newName = JOptionPane.showInputDialog( |
||
377 | (Component)PluginServices.getMainFrame(),
|
||
378 | "<html>"+
|
||
379 | PluginServices.getText(this,"nuevo_nombre_para_el_mapa") +" "+ map.getStringProperty("name") + ":" + |
||
380 | "</html>", //Mensaje |
||
381 | map.getStringProperty("name") //Valor por defecto |
||
382 | ); |
||
383 | if (newName == null) { |
||
384 | JOptionPane.showMessageDialog(
|
||
385 | (Component)PluginServices.getMainFrame(),
|
||
386 | "<html>"+PluginServices.getText(this,"operacion_cancelada")+"</html>",//Mensaje |
||
387 | PluginServices.getText(this,"pegar_mapas"),//titulo |
||
388 | JOptionPane.ERROR_MESSAGE
|
||
389 | ); |
||
390 | } else if (newName.equalsIgnoreCase(map.getStringProperty("name")) ) { |
||
391 | JOptionPane.showMessageDialog(
|
||
392 | (Component)PluginServices.getMainFrame(),
|
||
393 | "<html>"+
|
||
394 | PluginServices.getText(this,"operacion_cancelada") +":<br>" + |
||
395 | PluginServices.getText(this,"nombre_no_valido")+ |
||
396 | "</html>",//Mensaje |
||
397 | PluginServices.getText(this,"pegar_mapas"),//titulo |
||
398 | JOptionPane.ERROR_MESSAGE
|
||
399 | ); |
||
400 | return false; |
||
401 | } |
||
402 | map.setName(newName); |
||
403 | } |
||
404 | } |
||
405 | |||
406 | if (viewsConflits != null && viewsConflits.size() > 0) { |
||
407 | int option = JOptionPane.showConfirmDialog( |
||
408 | (Component)PluginServices.getMainFrame(),
|
||
409 | "<html>"+
|
||
410 | PluginServices.getText(this,"conflicto_de_nombres_de_vistas_al_pegar") + "<br>" + |
||
411 | PluginServices.getText(this,"no_se_pegaran_las_vistas_del_conflicto") + "<br>" + |
||
412 | PluginServices.getText(this,"desea_continuar") + |
||
413 | "</html>",
|
||
414 | PluginServices.getText(this,"pegar_mapas"),//titulo |
||
415 | JOptionPane.YES_NO_OPTION
|
||
416 | ); |
||
417 | if (option != JOptionPane.YES_OPTION) { |
||
418 | return false; |
||
419 | } |
||
420 | // Eliminamos las vistas del xml que no vamos a importar
|
||
421 | |||
422 | // Esto me devuelve los indices en orden inverso
|
||
423 | int[] indexes = this.getIndexOfConflict(viewsConflits); |
||
424 | for (int i=0;i < indexes.length;i++) { |
||
425 | xmlViews.removeChild(indexes[i]); |
||
426 | } |
||
427 | viewsConflits = null;
|
||
428 | |||
429 | } |
||
430 | |||
431 | |||
432 | if (tablesConflits != null && tablesConflits.size() > 0) { |
||
433 | int option = JOptionPane.showConfirmDialog( |
||
434 | (Component)PluginServices.getMainFrame(),
|
||
435 | "<html>" +
|
||
436 | PluginServices.getText(this,"conflito_de_nombres_de_tablas_al_pegar") + "<br>" + |
||
437 | PluginServices.getText(this,"no_se_pegaran_las_tablas") + "<br>" + |
||
438 | PluginServices.getText(this,"desea_continuar") + |
||
439 | "</html>", //Mensaje |
||
440 | PluginServices.getText(this,"pegar_mapas"), |
||
441 | JOptionPane.YES_NO_OPTION
|
||
442 | ); |
||
443 | if (option != JOptionPane.YES_OPTION) { |
||
444 | return false; |
||
445 | } |
||
446 | xmlTables.removeAllChildren(); |
||
447 | } |
||
448 | |||
449 | 7855 | jaume | |
450 | 7758 | jmvivo | return true; |
451 | } |
||
452 | 7855 | jaume | |
453 | 7758 | jmvivo | /**
|
454 | * Devuelve las claves de conflits ordenados
|
||
455 | * en orden inverso. Las claves se esperan que
|
||
456 | * sean instancias de Integer
|
||
457 | */
|
||
458 | private int[] getIndexOfConflict(Hashtable conflits) { |
||
459 | Object[] tmpArray = conflits.keySet().toArray(); |
||
460 | Arrays.sort(tmpArray,new Comparator() { |
||
461 | public int compare(Object o1, Object o2) { |
||
462 | return ((Integer)o2).intValue() - ((Integer)o1).intValue(); |
||
463 | } |
||
464 | } |
||
465 | ); |
||
466 | int[] indexes = new int[] {tmpArray.length}; |
||
467 | for (int i = 0;i< tmpArray.length;i++) { |
||
468 | indexes[i] = ((Integer)tmpArray[i]).intValue();
|
||
469 | } |
||
470 | return indexes;
|
||
471 | |||
472 | |||
473 | } |
||
474 | 7343 | caballero | } |