Revision 43830 branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.swing/org.gvsig.annotation.swing.impl/src/main/java/org/gvsig/annotation/swing/impl/WizardListenerAdapter.java
WizardListenerAdapter.java | ||
---|---|---|
25 | 25 |
* AUTHORS (In addition to CIT): |
26 | 26 |
* 2010 {Prodevelop} {Task} |
27 | 27 |
*/ |
28 |
|
|
29 | 28 |
package org.gvsig.annotation.swing.impl; |
30 | 29 |
|
31 | 30 |
import java.io.File; |
31 |
import javax.swing.JOptionPane; |
|
32 | 32 |
|
33 | 33 |
import org.gvsig.annotation.swing.AnnotationSwingLocator; |
34 | 34 |
import org.gvsig.annotation.swing.AnnotationSwingManager; |
35 | 35 |
import org.gvsig.gui.beans.wizard.WizardPanel; |
36 | 36 |
import org.gvsig.gui.beans.wizard.WizardPanelActionListener; |
37 | 37 |
import org.gvsig.i18n.Messages; |
38 |
import org.gvsig.tools.ToolsLocator; |
|
39 |
import org.gvsig.tools.i18n.I18nManager; |
|
40 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
41 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
42 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
38 | 43 |
import org.gvsig.tools.task.SimpleTaskStatus; |
39 | 44 |
import org.gvsig.tools.task.TaskStatus; |
40 | 45 |
|
41 |
|
|
42 |
|
|
43 | 46 |
/** |
44 | 47 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
45 | 48 |
*/ |
46 | 49 |
public class WizardListenerAdapter implements WizardPanelActionListener { |
47 |
private DefaultJAnnotationCreationServicePanel annotationCreationServicePanel; |
|
48 |
private AnnotationSwingManager annotationSwingManager = null; |
|
49 | 50 |
|
50 |
public WizardListenerAdapter( |
|
51 |
DefaultJAnnotationCreationServicePanel annotationCreationServicePanel) { |
|
52 |
super(); |
|
53 |
this.annotationCreationServicePanel = annotationCreationServicePanel; |
|
54 |
this.annotationSwingManager = AnnotationSwingLocator.getSwingManager(); |
|
55 |
} |
|
51 |
private DefaultJAnnotationCreationServicePanel annotationCreationServicePanel; |
|
52 |
private AnnotationSwingManager annotationSwingManager = null; |
|
56 | 53 |
|
57 |
public void cancel(WizardPanel wizardPanel) { |
|
58 |
TaskStatus taskStatus = annotationCreationServicePanel.getAnnotationCreationService().getTaskStatus(); |
|
59 |
if(taskStatus instanceof SimpleTaskStatus){ |
|
60 |
((SimpleTaskStatus)taskStatus).cancel(); |
|
61 |
} |
|
62 |
if (annotationCreationServicePanel.getAnnotationServicePanelActionListener() != null){ |
|
63 |
annotationCreationServicePanel.getAnnotationServicePanelActionListener().cancel(annotationCreationServicePanel); |
|
64 |
} |
|
65 |
} |
|
54 |
public WizardListenerAdapter( |
|
55 |
DefaultJAnnotationCreationServicePanel annotationCreationServicePanel) { |
|
56 |
super(); |
|
57 |
this.annotationCreationServicePanel = annotationCreationServicePanel; |
|
58 |
this.annotationSwingManager = AnnotationSwingLocator.getSwingManager(); |
|
59 |
} |
|
66 | 60 |
|
67 |
public void finish(WizardPanel wizardPanel) { |
|
68 |
if (annotationCreationServicePanel.getAnnotationServicePanelActionListener() != null){ |
|
69 |
File file = new File(annotationCreationServicePanel.getDestinationShapeFile()); |
|
61 |
public void cancel(WizardPanel wizardPanel) { |
|
62 |
TaskStatus taskStatus = annotationCreationServicePanel.getAnnotationCreationService().getTaskStatus(); |
|
63 |
if (taskStatus instanceof SimpleTaskStatus) { |
|
64 |
((SimpleTaskStatus) taskStatus).cancel(); |
|
65 |
} |
|
66 |
if (annotationCreationServicePanel.getAnnotationServicePanelActionListener() != null) { |
|
67 |
annotationCreationServicePanel.getAnnotationServicePanelActionListener().cancel(annotationCreationServicePanel); |
|
68 |
} |
|
69 |
} |
|
70 | 70 |
|
71 |
boolean continueIfExists = true; |
|
71 |
public void finish(WizardPanel wizardPanel) { |
|
72 |
if (annotationCreationServicePanel.getAnnotationServicePanelActionListener() != null) { |
|
73 |
File file = new File(annotationCreationServicePanel.getDestinationShapeFile()); |
|
72 | 74 |
|
73 |
if (file.exists()){ |
|
74 |
continueIfExists = annotationSwingManager.getWindowManager().showFileExistsPopup(Messages.getText("guardar"), |
|
75 |
Messages.getText("fichero_ya_existe_seguro_desea_guardarlo")); |
|
76 |
} |
|
75 |
boolean continueIfExists = true; |
|
77 | 76 |
|
78 |
if (continueIfExists){ |
|
79 |
annotationCreationServicePanel.createAnnotation(); |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
77 |
if (file.exists()) { |
|
78 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
79 |
ThreadSafeDialogsManager dialogManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
80 |
continueIfExists = dialogManager.confirmDialog( |
|
81 |
i18n.getTranslation("fichero_ya_existe_seguro_desea_guardarlo"), |
|
82 |
i18n.getTranslation("guardar"), |
|
83 |
JOptionPane.YES_NO_OPTION, |
|
84 |
JOptionPane.WARNING_MESSAGE, |
|
85 |
"annotation_file_already_exists" |
|
86 |
) == JOptionPane.OK_OPTION; |
|
87 |
} |
|
88 |
|
|
89 |
if (continueIfExists) { |
|
90 |
annotationCreationServicePanel.createAnnotation(); |
|
91 |
} |
|
92 |
} |
|
93 |
} |
|
83 | 94 |
} |
84 |
|
Also available in: Unified diff