Revision 128 org.gvsig.educa.batovi/trunk/org.gvsig.educa.batovi.mapviewer/org.gvsig.educa.batovi.mapviewer/src/main/java/org/gvsig/educa/batovi/mapviewer/Main.java
Main.java | ||
---|---|---|
29 | 29 |
import java.io.IOException; |
30 | 30 |
import java.net.URL; |
31 | 31 |
import java.util.List; |
32 |
import java.util.Locale; |
|
33 |
import java.util.MissingResourceException; |
|
34 |
import java.util.ResourceBundle; |
|
32 | 35 |
|
33 | 36 |
import javax.swing.AbstractAction; |
34 | 37 |
import javax.swing.Box; |
... | ... | |
45 | 48 |
|
46 | 49 |
import org.gvsig.educa.thematicmap.ThematicMapLocator; |
47 | 50 |
import org.gvsig.educa.thematicmap.ThematicMapManager; |
48 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilation; |
|
49 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompiler; |
|
50 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilerListener; |
|
51 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilerStatus; |
|
52 | 51 |
import org.gvsig.educa.thematicmap.map.ThematicMap; |
53 | 52 |
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingLocator; |
54 | 53 |
import org.gvsig.educa.thematicmap.swing.ThematicMapSwingManager; |
... | ... | |
56 | 55 |
import org.gvsig.educa.thematicmap.swing.ThematicMapWindowManager.CONFIRM_DIALOG_OPTION; |
57 | 56 |
import org.gvsig.educa.thematicmap.swing.ThematicMapWindowManager.CONFIRM_DIALOG_TYPE; |
58 | 57 |
import org.gvsig.educa.thematicmap.swing.ThematicMapWindowManager.MESSAGE_DIALOG_TYPE; |
59 |
import org.gvsig.educa.thematicmap.swing.editor.ThematicMapCompilationEditor; |
|
60 |
import org.gvsig.educa.thematicmap.swing.editor.ThematicMapCompilationEditorListener; |
|
61 | 58 |
import org.gvsig.educa.thematicmap.swing.viewer.ThematicMapViewer; |
62 | 59 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
63 | 60 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
... | ... | |
81 | 78 |
|
82 | 79 |
private static final Logger LOG = LoggerFactory.getLogger(Main.class); |
83 | 80 |
|
81 |
private static Main instance = null; |
|
82 |
|
|
83 |
private ResourceBundle resourceBundle = null; |
|
84 |
|
|
84 | 85 |
private final ThematicMapManager manager; |
85 | 86 |
private final ThematicMapSwingManager swingManager; |
86 | 87 |
private final ThematicMapWindowManager winManager; |
... | ... | |
100 | 101 |
private AbstractAction exitAction; |
101 | 102 |
private AbstractAction closeThematicMapAction; |
102 | 103 |
|
103 |
private AbstractAction createCompilationAction; |
|
104 |
|
|
105 |
private AbstractAction createCompilationFromMapAction; |
|
106 |
|
|
107 | 104 |
private AbstractAction installThematicMaps; |
108 | 105 |
|
109 | 106 |
private AbstractAction addInstallUrl; |
110 | 107 |
|
111 |
private final MapToolsRegistrant mapToolsRegistrant;
|
|
108 |
private MapToolsRegistrant mapToolsRegistrant; |
|
112 | 109 |
|
113 | 110 |
private StatusBar statusBar; |
114 | 111 |
|
... | ... | |
122 | 119 |
|
123 | 120 |
public static void main(String args[]) { |
124 | 121 |
new DefaultLibrariesInitializer().fullInitialize(); |
122 |
instance = new Main(); |
|
123 |
instance.init(); |
|
124 |
instance.show(); |
|
125 |
} |
|
125 | 126 |
|
126 |
Main main = new Main();
|
|
127 |
main.show();
|
|
127 |
public static Main getInstance() {
|
|
128 |
return instance;
|
|
128 | 129 |
} |
129 | 130 |
|
130 | 131 |
/** |
... | ... | |
138 | 139 |
disposeManager = ToolsLocator.getDisposableManager(); |
139 | 140 |
swingInstallerManager = |
140 | 141 |
SwingInstallerLocator.getSwingInstallerManager(); |
142 |
fileChooser = new JFileChooser(); |
|
143 |
LOG.info("Strating application"); |
|
144 |
} |
|
141 | 145 |
|
146 |
private void init() { |
|
147 |
|
|
142 | 148 |
String defaultFolderPath = |
143 | 149 |
"gvSIG/plugins/org.gvsig.educa.thematicmap.app.viewer/thematicMaps"; |
144 | 150 |
File defaultFolder = |
... | ... | |
147 | 153 |
if (!defaultFolder.exists()) { |
148 | 154 |
defaultFolder.mkdirs(); |
149 | 155 |
} |
156 |
LOG.info("Default map folder: {}", defaultFolder); |
|
150 | 157 |
manager.setInstallationMapFolder(defaultFolder.getAbsolutePath()); |
151 | 158 |
|
152 | 159 |
mapToolsRegistrant = new MapToolsRegistrant(); |
153 | 160 |
swingManager.addMapControlRegistrant(mapToolsRegistrant); |
154 | 161 |
|
155 |
fileChooser = new JFileChooser(); |
|
156 |
|
|
157 | 162 |
try { |
158 | 163 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
159 | 164 |
} catch (Exception ex) { |
... | ... | |
164 | 169 |
|
165 | 170 |
} |
166 | 171 |
|
172 |
public ThematicMapWindowManager getWindowsManager() { |
|
173 |
return winManager; |
|
174 |
} |
|
175 |
|
|
167 | 176 |
/** |
168 | 177 |
* Shows main frame |
169 | 178 |
*/ |
... | ... | |
173 | 182 |
createActions(); |
174 | 183 |
|
175 | 184 |
// Create JFrame to show data |
176 |
mainFrame = new JFrame("gvSIG Batovi Map Viewer");
|
|
185 |
mainFrame = new JFrame(translate("gvSIG_Batovi_Map_Viewer"));
|
|
177 | 186 |
mainFrame.setUndecorated(true); |
178 | 187 |
mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
179 | 188 |
mainFrame.setLayout(new BorderLayout(10, 10)); |
... | ... | |
197 | 206 |
mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); |
198 | 207 |
mainFrame.setLocation(0, 0); |
199 | 208 |
mainFrame.setVisible(true); |
200 |
|
|
201 | 209 |
} |
202 | 210 |
|
203 | 211 |
/** |
... | ... | |
207 | 215 |
@SuppressWarnings("serial") |
208 | 216 |
private void createActions() { |
209 | 217 |
setThematiMapFolderAction = |
210 |
new AbstractAction("Set thematic map folder") {
|
|
218 |
new AbstractAction(translate("Select_Thematic_Map_folder")) {
|
|
211 | 219 |
|
212 | 220 |
public void actionPerformed(ActionEvent e) { |
213 | 221 |
setThematicMapFolder(); |
... | ... | |
215 | 223 |
}; |
216 | 224 |
|
217 | 225 |
showOpenThematicMapDialogAction = |
218 |
new AbstractAction("Open a Thematic Map") {
|
|
226 |
new AbstractAction(translate("Open_Thematic_map")) {
|
|
219 | 227 |
|
220 | 228 |
public void actionPerformed(ActionEvent e) { |
221 | 229 |
showOpenThematicMapDialog(); |
... | ... | |
223 | 231 |
}; |
224 | 232 |
showOpenThematicMapDialogAction.setEnabled(false); |
225 | 233 |
|
226 |
setZoomToolAction = new AbstractAction("Tool Zoom") {
|
|
234 |
setZoomToolAction = new AbstractAction(translate("Zoom")) {
|
|
227 | 235 |
|
228 | 236 |
public void actionPerformed(ActionEvent e) { |
229 | 237 |
setZoomTool(); |
... | ... | |
231 | 239 |
}; |
232 | 240 |
setZoomToolAction.setEnabled(false); |
233 | 241 |
|
234 |
setPanToolAction = new AbstractAction("Tool Pan") {
|
|
242 |
setPanToolAction = new AbstractAction(translate("Pan")) {
|
|
235 | 243 |
|
236 | 244 |
public void actionPerformed(ActionEvent e) { |
237 | 245 |
setPanTool(); |
... | ... | |
239 | 247 |
}; |
240 | 248 |
setPanToolAction.setEnabled(false); |
241 | 249 |
|
242 |
zoomAllAction = new AbstractAction("Zoom all") {
|
|
250 |
zoomAllAction = new AbstractAction(translate("Zoom_all")) {
|
|
243 | 251 |
|
244 | 252 |
public void actionPerformed(ActionEvent e) { |
245 | 253 |
zoomAll(); |
... | ... | |
247 | 255 |
}; |
248 | 256 |
zoomAllAction.setEnabled(false); |
249 | 257 |
|
250 |
setMeasuerToolAction = new AbstractAction("Tool measure") {
|
|
258 |
setMeasuerToolAction = new AbstractAction(translate("measure")) {
|
|
251 | 259 |
|
252 | 260 |
public void actionPerformed(ActionEvent e) { |
253 | 261 |
setMeasuerTool(); |
... | ... | |
255 | 263 |
}; |
256 | 264 |
setMeasuerToolAction.setEnabled(false); |
257 | 265 |
|
258 |
setAreaToolAction = new AbstractAction("Tool area") {
|
|
266 |
setAreaToolAction = new AbstractAction(translate("area")) {
|
|
259 | 267 |
|
260 | 268 |
public void actionPerformed(ActionEvent e) { |
261 | 269 |
setAreaTool(); |
... | ... | |
263 | 271 |
}; |
264 | 272 |
setAreaToolAction.setEnabled(false); |
265 | 273 |
|
266 |
setInfoToolAction = new AbstractAction("Tool Info") {
|
|
274 |
setInfoToolAction = new AbstractAction(translate("infoByPoint")) {
|
|
267 | 275 |
|
268 | 276 |
public void actionPerformed(ActionEvent e) { |
269 | 277 |
setInfoTool(); |
... | ... | |
271 | 279 |
}; |
272 | 280 |
setInfoToolAction.setEnabled(false); |
273 | 281 |
|
274 |
closeThematicMapAction = new AbstractAction("Close Map") {
|
|
282 |
closeThematicMapAction = new AbstractAction(translate("Close_Map")) {
|
|
275 | 283 |
|
276 | 284 |
public void actionPerformed(ActionEvent e) { |
277 | 285 |
closeMap(); |
... | ... | |
279 | 287 |
}; |
280 | 288 |
closeThematicMapAction.setEnabled(false); |
281 | 289 |
|
282 |
exitAction = new AbstractAction("Exit") {
|
|
290 |
exitAction = new AbstractAction(translate("Exit")) {
|
|
283 | 291 |
|
284 | 292 |
public void actionPerformed(ActionEvent e) { |
285 | 293 |
exit(); |
286 | 294 |
} |
287 | 295 |
}; |
288 | 296 |
|
289 |
createCompilationAction = new AbstractAction("Create a compilation") { |
|
297 |
addInstallUrl = |
|
298 |
new AbstractAction(translate("Add_a_ThematicMap_install_URL")) { |
|
290 | 299 |
|
291 |
public void actionPerformed(ActionEvent e) { |
|
292 |
createCompilation(); |
|
293 |
} |
|
294 |
}; |
|
295 |
createCompilationAction.setEnabled(false); |
|
296 |
|
|
297 |
createCompilationFromMapAction = |
|
298 |
new AbstractAction("Create compilation from current map") { |
|
299 |
|
|
300 | 300 |
public void actionPerformed(ActionEvent e) { |
301 |
createCompilationFromMap();
|
|
301 |
addThematicMapUrl();
|
|
302 | 302 |
} |
303 |
|
|
303 | 304 |
}; |
304 |
createCompilationFromMapAction.setEnabled(false); |
|
305 | 305 |
|
306 |
addInstallUrl = new AbstractAction("Add a ThematicMap install URL") { |
|
306 |
installThematicMaps = |
|
307 |
new AbstractAction(translate("Install_ThematicMaps")) { |
|
307 | 308 |
|
308 |
public void actionPerformed(ActionEvent e) { |
|
309 |
addThematicMapUrl();
|
|
310 |
} |
|
309 |
public void actionPerformed(ActionEvent e) {
|
|
310 |
installThematicMap();
|
|
311 |
}
|
|
311 | 312 |
|
312 |
}; |
|
313 |
|
|
314 |
installThematicMaps = new AbstractAction("Install ThematicMaps") { |
|
315 |
|
|
316 |
public void actionPerformed(ActionEvent e) { |
|
317 |
installThematicMap(); |
|
318 |
} |
|
319 |
|
|
320 |
}; |
|
313 |
}; |
|
321 | 314 |
installThematicMaps.setEnabled(false); |
322 | 315 |
|
323 |
showHideTocAction = new AbstractAction("Show/Hide Toc") {
|
|
316 |
showHideTocAction = new AbstractAction(translate("Show_Hide_Toc")) {
|
|
324 | 317 |
|
325 | 318 |
public void actionPerformed(ActionEvent e) { |
326 | 319 |
showHideToc(); |
... | ... | |
386 | 379 |
public void setThematicMapFolder() { |
387 | 380 |
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
388 | 381 |
int result = |
389 |
fileChooser.showDialog(mainFrame, "Select ThematicMap folder");
|
|
382 |
fileChooser.showDialog(mainFrame, translate("Select_folder"));
|
|
390 | 383 |
if (result != JFileChooser.APPROVE_OPTION) { |
391 | 384 |
return; |
392 | 385 |
} |
... | ... | |
398 | 391 |
folder.getAbsolutePath()); |
399 | 392 |
CONFIRM_DIALOG_OPTION resp = |
400 | 393 |
winManager.showConfirmDialog(mainFrame, |
401 |
"No maps found. Select this folder anyway?",
|
|
402 |
"Set ThematicMap folder", CONFIRM_DIALOG_TYPE.YES_NO,
|
|
403 |
MESSAGE_DIALOG_TYPE.WARNING); |
|
394 |
translate("No_maps_found._Select_this_folder_anyway"),
|
|
395 |
translate("Select_Thematic_Map_folder"),
|
|
396 |
CONFIRM_DIALOG_TYPE.YES_NO, MESSAGE_DIALOG_TYPE.WARNING);
|
|
404 | 397 |
if (resp != CONFIRM_DIALOG_OPTION.OK_YES) { |
405 | 398 |
return; |
406 | 399 |
} |
... | ... | |
410 | 403 |
manager.setInstallationMapFolder(folder.getAbsolutePath()); |
411 | 404 |
} catch (Exception e) { |
412 | 405 |
LOG.error("Error setting thematic map folder", e); |
413 |
winManager |
|
414 |
.showMessageDialog( |
|
415 |
mainFrame, |
|
416 |
"Setting folder", |
|
417 |
"Problem foudn setting Thematic Map folder (See log for more information)", |
|
418 |
MESSAGE_DIALOG_TYPE.ERROR); |
|
406 |
winManager.showMessageDialog(mainFrame, |
|
407 |
translate("Select_Thematic_Map_folder"), |
|
408 |
translate("Problem_found_setting_Thematic_Map_folder"), |
|
409 |
MESSAGE_DIALOG_TYPE.ERROR); |
|
419 | 410 |
} |
420 | 411 |
updateControls(); |
421 | 412 |
} |
... | ... | |
426 | 417 |
public void showOpenThematicMapDialog() { |
427 | 418 |
if (manager.getInstallationMapFolder() == null) { |
428 | 419 |
LOG.warn("thematic map folder not set on open Thematic Map request"); |
429 |
winManager.showMessageDialog(mainFrame, "Open a Thematic Map", |
|
430 |
"Select a Thematic Map folder first", MESSAGE_DIALOG_TYPE.INFO); |
|
420 |
winManager.showMessageDialog(mainFrame, |
|
421 |
translate("Open_Thematic_map"), |
|
422 |
translate("Select_a_Thematic_Map_folder_first"), |
|
423 |
MESSAGE_DIALOG_TYPE.INFO); |
|
431 | 424 |
return; |
432 | 425 |
} |
433 | 426 |
OpenThematicMap openThematicMap = |
434 | 427 |
new OpenThematicMap(this, manager.getInstalledMaps()); |
435 |
winManager.showWindow(openThematicMap, "Open a Thematic Map...",
|
|
428 |
winManager.showWindow(openThematicMap, translate("Open_Thematic_map"),
|
|
436 | 429 |
MODE.DIALOG); |
437 | 430 |
} |
438 | 431 |
|
... | ... | |
443 | 436 |
* @return |
444 | 437 |
*/ |
445 | 438 |
public boolean openMap(ThematicMap curMap) { |
439 |
LOG.info("Opening map: {}", curMap.getSourceFilePath()); |
|
446 | 440 |
ThematicMapViewer viewer; |
447 | 441 |
try { |
448 | 442 |
viewer = swingManager.getViewer(curMap); |
449 | 443 |
} catch (Exception e) { |
450 | 444 |
LOG.error("Can't open map", e); |
451 |
winManager.showMessageDialog(mainFrame, "Open Thematic map", |
|
452 |
"Problem found opening map (see log for details)", |
|
445 |
winManager.showMessageDialog(mainFrame, |
|
446 |
translate("Open_Thematic_map"), |
|
447 |
translate("Problem_found_opening_map_see_log_for_details"), |
|
453 | 448 |
MESSAGE_DIALOG_TYPE.ERROR); |
454 | 449 |
return false; |
455 | 450 |
} |
... | ... | |
458 | 453 |
mainFrame.add(viewer.getSwingComponent(), BorderLayout.CENTER); |
459 | 454 |
curViewer = viewer; |
460 | 455 |
updateControls(); |
456 |
LOG.info("Map opened"); |
|
461 | 457 |
return true; |
462 | 458 |
} |
463 | 459 |
|
... | ... | |
488 | 484 |
} |
489 | 485 |
statusBar.clear(); |
490 | 486 |
curViewer = null; |
487 |
LOG.info("Closed last map"); |
|
491 | 488 |
} |
492 | 489 |
} |
493 | 490 |
|
... | ... | |
497 | 494 |
public void updateControls() { |
498 | 495 |
showOpenThematicMapDialogAction.setEnabled(manager |
499 | 496 |
.getInstallationMapFolder() != null); |
500 |
createCompilationAction |
|
501 |
.setEnabled(manager.getInstallationMapFolder() != null); |
|
502 |
createCompilationFromMapAction.setEnabled(curViewer != null); |
|
503 | 497 |
setZoomToolAction.setEnabled(curViewer != null); |
504 | 498 |
setPanToolAction.setEnabled(curViewer != null); |
505 | 499 |
setMeasuerToolAction.setEnabled(curViewer != null); |
... | ... | |
528 | 522 |
if (curViewer != null) { |
529 | 523 |
curViewer.setTool(MapToolsRegistrant.TOOL_ZOOM_ID); |
530 | 524 |
statusBar.setInfo(""); |
525 |
LOG.info("Selected Tool: {}", curViewer.getCurrentToolId()); |
|
531 | 526 |
} |
532 | 527 |
} |
533 | 528 |
|
... | ... | |
538 | 533 |
if (curViewer != null) { |
539 | 534 |
curViewer.setTool(MapToolsRegistrant.TOOL_PAN_ID); |
540 | 535 |
statusBar.setInfo(""); |
536 |
LOG.info("Selected Tool: {}", curViewer.getCurrentToolId()); |
|
541 | 537 |
} |
542 | 538 |
} |
543 | 539 |
|
... | ... | |
548 | 544 |
if (curViewer != null) { |
549 | 545 |
curViewer.setTool(MapToolsRegistrant.TOOL_INFO_ID); |
550 | 546 |
statusBar.setInfo(""); |
547 |
LOG.info("Selected Tool: {}", curViewer.getCurrentToolId()); |
|
551 | 548 |
} |
552 | 549 |
} |
553 | 550 |
|
... | ... | |
557 | 554 |
public void zoomAll() { |
558 | 555 |
if (curViewer != null) { |
559 | 556 |
curViewer.zoomAll(); |
557 |
LOG.info("Zoom all"); |
|
560 | 558 |
} |
561 | 559 |
} |
562 | 560 |
|
... | ... | |
579 | 577 |
} catch (InterruptedException e) { |
580 | 578 |
// Do nothing |
581 | 579 |
} |
580 |
LOG.info("Application exit"); |
|
582 | 581 |
|
583 | 582 |
// exit app |
584 | 583 |
System.exit(0); |
... | ... | |
590 | 589 |
} |
591 | 590 |
curViewer.setTool(MapToolsRegistrant.TOOL_MEASURE_ID); |
592 | 591 |
statusBar.setInfo(""); |
592 |
LOG.info("Selected Tool: {}", curViewer.getCurrentToolId()); |
|
593 | 593 |
} |
594 | 594 |
|
595 | 595 |
public void setAreaTool() { |
... | ... | |
598 | 598 |
} |
599 | 599 |
curViewer.setTool(MapToolsRegistrant.TOOL_AREA_ID); |
600 | 600 |
statusBar.setInfo(""); |
601 |
LOG.info("Selected Tool: {}", curViewer.getCurrentToolId()); |
|
601 | 602 |
} |
602 | 603 |
|
603 |
public void createCompilation() { |
|
604 |
ThematicMapCompilation compilation = |
|
605 |
manager.createCompilationInstance(); |
|
606 |
|
|
607 |
ThematicMapCompilationEditor editor = |
|
608 |
swingManager.getCopilationEditor(compilation, true); |
|
609 |
|
|
610 |
editor.setListener(new ThematicMapCompilationEditorListener() { |
|
611 |
|
|
612 |
public void finished(ThematicMapCompilationEditor editor) { |
|
613 |
CONFIRM_DIALOG_OPTION resp = |
|
614 |
winManager.showConfirmDialog(mainFrame, |
|
615 |
"Compile thematic map", "Create a compilation", |
|
616 |
CONFIRM_DIALOG_TYPE.YES_NO, |
|
617 |
MESSAGE_DIALOG_TYPE.QUESTION); |
|
618 |
if (resp != CONFIRM_DIALOG_OPTION.OK_YES) { |
|
619 |
winManager.showMessageDialog(mainFrame, |
|
620 |
"Create a compilation", |
|
621 |
"Process finished: no compiled", |
|
622 |
MESSAGE_DIALOG_TYPE.INFO); |
|
623 |
return; |
|
624 |
} |
|
625 |
compileMap(editor.getCompilation()); |
|
626 |
|
|
627 |
} |
|
628 |
|
|
629 |
public void canceled(ThematicMapCompilationEditor editor) { |
|
630 |
// Do nothing |
|
631 |
|
|
632 |
} |
|
633 |
}); |
|
634 |
|
|
635 |
winManager.showCompilationEditor(editor, MODE.WINDOW); |
|
636 |
|
|
637 |
} |
|
638 |
|
|
639 |
public void createCompilationFromMap() { |
|
640 |
ThematicMapCompilation compilation; |
|
641 |
try { |
|
642 |
compilation = |
|
643 |
manager.createCompilationInstanceFromMap(curViewer |
|
644 |
.getThematicMap()); |
|
645 |
} catch (Exception ex) { |
|
646 |
winManager.showMessageDialog(mainFrame, |
|
647 |
"Create Compilation from Thematic Map", |
|
648 |
"Problems creating compilation (show log for more info)", |
|
649 |
MESSAGE_DIALOG_TYPE.ERROR); |
|
650 |
LOG.error("Problems creating compilation from map", ex); |
|
651 |
return; |
|
652 |
} |
|
653 |
|
|
654 |
ThematicMapCompilationEditor editor = |
|
655 |
swingManager.getCopilationEditor(compilation, true); |
|
656 |
|
|
657 |
editor.setListener(new ThematicMapCompilationEditorListener() { |
|
658 |
|
|
659 |
public void finished(ThematicMapCompilationEditor editor) { |
|
660 |
CONFIRM_DIALOG_OPTION resp = |
|
661 |
winManager.showConfirmDialog(mainFrame, |
|
662 |
"Compile thematic map", "Create a compilation", |
|
663 |
CONFIRM_DIALOG_TYPE.YES_NO, |
|
664 |
MESSAGE_DIALOG_TYPE.QUESTION); |
|
665 |
if (resp != CONFIRM_DIALOG_OPTION.OK_YES) { |
|
666 |
winManager.showMessageDialog(mainFrame, |
|
667 |
"Create a compilation", |
|
668 |
"Process finished: no compiled", |
|
669 |
MESSAGE_DIALOG_TYPE.INFO); |
|
670 |
return; |
|
671 |
} |
|
672 |
compileMap(editor.getCompilation()); |
|
673 |
|
|
674 |
} |
|
675 |
|
|
676 |
public void canceled(ThematicMapCompilationEditor editor) { |
|
677 |
// Do nothing |
|
678 |
|
|
679 |
} |
|
680 |
}); |
|
681 |
|
|
682 |
winManager.showCompilationEditor(editor, MODE.WINDOW); |
|
683 |
|
|
684 |
} |
|
685 |
|
|
686 | 604 |
public void installThematicMap() { |
605 |
LOG.info("Opening install dialog"); |
|
687 | 606 |
AbstractInstallerWizard panel; |
688 | 607 |
try { |
689 | 608 |
panel = |
... | ... | |
691 | 610 |
new File(manager.getInstallationMapFolder())); |
692 | 611 |
} catch (InstallPackageWizardException ex) { |
693 | 612 |
LOG.error("Error opening installer panel", ex); |
694 |
winManager.showMessageDialog("Install Thematic Maps", |
|
695 |
"Error opening installer panel", MESSAGE_DIALOG_TYPE.ERROR); |
|
613 |
winManager.showMessageDialog(translate("Install_Thematic_Map"), |
|
614 |
translate("Error_opening_installer_panel"), |
|
615 |
MESSAGE_DIALOG_TYPE.ERROR); |
|
696 | 616 |
return; |
697 | 617 |
|
698 | 618 |
} |
699 | 619 |
|
700 |
winManager.showWindow(panel, "Install Thematic Map", MODE.DIALOG); |
|
620 |
winManager.showWindow(panel, translate("Install_Thematic_Map"), |
|
621 |
MODE.DIALOG); |
|
701 | 622 |
|
702 | 623 |
} |
703 | 624 |
|
704 | 625 |
public void addThematicMapUrl() { |
705 | 626 |
String inUrl = |
706 |
winManager.showInputStringDialog("Input the url",
|
|
707 |
"Add install Thematic Map URL", "http://",
|
|
627 |
winManager.showInputStringDialog(translate("Input_the_url"),
|
|
628 |
translate("Add_a_ThematicMap_install_URL"), "http://",
|
|
708 | 629 |
MESSAGE_DIALOG_TYPE.QUESTION); |
709 | 630 |
URL url; |
710 | 631 |
try { |
711 | 632 |
url = new URL(inUrl); |
712 | 633 |
} catch (Exception ex) { |
713 | 634 |
LOG.error("Invalid URL: ".concat(inUrl).concat("'"), ex); |
714 |
winManager.showMessageDialog("Add install Thematic Map URL", |
|
715 |
"Invalid URL: '".concat(inUrl).concat("'"), |
|
716 |
MESSAGE_DIALOG_TYPE.ERROR); |
|
635 |
winManager.showMessageDialog( |
|
636 |
translate("Add_install_Thematic_Map_URL"), |
|
637 |
translate("Invalid_URL").concat(": '").concat(inUrl) |
|
638 |
.concat("'"), MESSAGE_DIALOG_TYPE.ERROR); |
|
717 | 639 |
return; |
718 | 640 |
} |
719 | 641 |
swingInstallerManager.addDefaultDownloadURL(url); |
642 |
LOG.info("Added install URL: '{}'", url); |
|
720 | 643 |
} |
721 | 644 |
|
722 |
public void compileMap(ThematicMapCompilation compilation) { |
|
723 |
ThematicMapCompiler compiler = manager.createCompilerInstance(); |
|
724 |
compiler.setTargetFolder(manager.getInstallationMapFolder()); |
|
725 |
File workFolder = |
|
726 |
new File(manager.getTemporalFolder() + File.separatorChar |
|
727 |
+ "compiler"); |
|
728 |
workFolder.mkdirs(); |
|
729 |
compiler.setWorkFolder(workFolder.getAbsolutePath() |
|
730 |
+ File.separatorChar); |
|
731 |
|
|
732 |
compiler.setCompilerListener(new CompilerProcessListener(LOG)); |
|
733 |
ThematicMapCompilerStatus resul = compiler.compile(compilation); |
|
734 |
|
|
735 |
if (resul.getStatus() != ThematicMapCompilerStatus.Status.finished_ok) { |
|
736 |
winManager.showMessageDialog(mainFrame, "Compile Thematic Map", |
|
737 |
"Problems found in process (show log for more info)", |
|
738 |
MESSAGE_DIALOG_TYPE.ERROR); |
|
739 |
return; |
|
740 |
|
|
645 |
public String translate(String key) { |
|
646 |
if (resourceBundle == null) { |
|
647 |
try { |
|
648 |
resourceBundle = ResourceBundle.getBundle("mapviewer"); |
|
649 |
} catch (MissingResourceException e) { |
|
650 |
Locale loc = new Locale(Locale.getDefault().getLanguage()); |
|
651 |
LOG.warn("Can't load translation. Trying with ".concat(loc |
|
652 |
.toString()), e); |
|
653 |
try { |
|
654 |
resourceBundle = ResourceBundle.getBundle("mapviewer", loc); |
|
655 |
} catch (MissingResourceException e1) { |
|
656 |
LOG.error("Can't load translation", e1); |
|
657 |
} |
|
658 |
} |
|
659 |
return key; |
|
741 | 660 |
} |
742 |
winManager.showMessageDialog(mainFrame, "Compile Thematic Map", |
|
743 |
"<html>Process successful:<br>" |
|
744 |
+ resul.getGeneratedThematicMapFile().getAbsolutePath() |
|
745 |
+ "</html>", MESSAGE_DIALOG_TYPE.INFO); |
|
746 |
|
|
747 |
CONFIRM_DIALOG_OPTION generatePkg = |
|
748 |
winManager.showConfirmDialog( |
|
749 |
"Would you like to generete a gvSIG pakage file?", |
|
750 |
"Compile Thematic Map", CONFIRM_DIALOG_TYPE.YES_NO, |
|
751 |
MESSAGE_DIALOG_TYPE.QUESTION); |
|
752 |
|
|
753 |
if (generatePkg != CONFIRM_DIALOG_OPTION.OK_YES) { |
|
754 |
return; |
|
755 |
} |
|
756 |
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
|
757 |
int targetFolderAnswere = |
|
758 |
fileChooser.showDialog(mainFrame, |
|
759 |
"Select folder where store the package file"); |
|
760 |
if (targetFolderAnswere != JFileChooser.APPROVE_OPTION) { |
|
761 |
return; |
|
762 |
} |
|
763 |
File gvsigPkg = null; |
|
764 | 661 |
try { |
765 |
gvsigPkg = |
|
766 |
manager.generatePackageFile( |
|
767 |
resul.getGeneratedInstalationThematicMapFolder(), |
|
768 |
fileChooser.getSelectedFile()); |
|
769 |
} catch (Exception ex) { |
|
770 |
LOG.error("Error generating gvSIG package", ex); |
|
771 |
winManager |
|
772 |
.showMessageDialog( |
|
773 |
mainFrame, |
|
774 |
"Compile Thematic Map", |
|
775 |
"Problems found generating gvSIG package (show log for more info)", |
|
776 |
MESSAGE_DIALOG_TYPE.ERROR); |
|
777 |
return; |
|
778 |
|
|
662 |
return resourceBundle.getString(key); |
|
663 |
} catch (MissingResourceException e) { |
|
664 |
LOG.warn("Missing Translation: '".concat(key).concat("'")); |
|
665 |
return key; |
|
666 |
} catch (NullPointerException e) { |
|
667 |
LOG.warn("No bundle for translation: '".concat(key).concat("'")); |
|
668 |
return key; |
|
669 |
} catch (Exception e) { |
|
670 |
LOG.warn("Missing Translation: '".concat(key).concat("'"), e); |
|
671 |
return key; |
|
779 | 672 |
} |
780 |
winManager.showMessageDialog(mainFrame, "Compile Thematic Map", |
|
781 |
"<html>Generated gvSIG package:<br>" + gvsigPkg.getAbsolutePath() |
|
782 |
+ "</html>", MESSAGE_DIALOG_TYPE.INFO); |
|
783 | 673 |
} |
784 |
|
|
785 |
private class CompilerProcessListener implements |
|
786 |
ThematicMapCompilerListener { |
|
787 |
|
|
788 |
private final Logger log; |
|
789 |
|
|
790 |
public CompilerProcessListener(Logger log) { |
|
791 |
this.log = log; |
|
792 |
} |
|
793 |
|
|
794 |
public void updatedStatus(ThematicMapCompilerStatus currentStatus) { |
|
795 |
if (log.isDebugEnabled()) { |
|
796 |
log.debug( |
|
797 |
"Process status:\n\tStatus: {}\n\tStep: {}/{} ({}%)\n\tMessage: '{}'", |
|
798 |
new Object[] { currentStatus.getStatus().name(), |
|
799 |
currentStatus.getCurrentStep(), |
|
800 |
currentStatus.getTotalSteps(), |
|
801 |
currentStatus.getCompleted(), currentStatus.getLabel() }); |
|
802 |
} |
|
803 |
|
|
804 |
} |
|
805 |
|
|
806 |
public void notifyWarning(String message, |
|
807 |
ThematicMapCompilerStatus currentStatus) { |
|
808 |
log.warn("Process warining: {}", message); |
|
809 |
|
|
810 |
} |
|
811 |
|
|
812 |
public void notifyException(ThematicMapCompilerStatus currentStatus) { |
|
813 |
log.error("Process error: {}", currentStatus.getFailMessage()); |
|
814 |
} |
|
815 |
|
|
816 |
} |
|
817 | 674 |
} |
Also available in: Unified diff