Statistics
| Revision:

svn-gvsig-desktop / 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 @ 43830

History | View | Annotate | Download (3.83 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2010 {Prodevelop}   {Task}
27
 */
28
package org.gvsig.annotation.swing.impl;
29

    
30
import java.io.File;
31
import javax.swing.JOptionPane;
32

    
33
import org.gvsig.annotation.swing.AnnotationSwingLocator;
34
import org.gvsig.annotation.swing.AnnotationSwingManager;
35
import org.gvsig.gui.beans.wizard.WizardPanel;
36
import org.gvsig.gui.beans.wizard.WizardPanelActionListener;
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;
43
import org.gvsig.tools.task.SimpleTaskStatus;
44
import org.gvsig.tools.task.TaskStatus;
45

    
46
/**
47
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
48
 */
49
public class WizardListenerAdapter implements WizardPanelActionListener {
50

    
51
    private DefaultJAnnotationCreationServicePanel annotationCreationServicePanel;
52
    private AnnotationSwingManager annotationSwingManager = null;
53

    
54
    public WizardListenerAdapter(
55
            DefaultJAnnotationCreationServicePanel annotationCreationServicePanel) {
56
        super();
57
        this.annotationCreationServicePanel = annotationCreationServicePanel;
58
        this.annotationSwingManager = AnnotationSwingLocator.getSwingManager();
59
    }
60

    
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

    
71
    public void finish(WizardPanel wizardPanel) {
72
        if (annotationCreationServicePanel.getAnnotationServicePanelActionListener() != null) {
73
            File file = new File(annotationCreationServicePanel.getDestinationShapeFile());
74

    
75
            boolean continueIfExists = true;
76

    
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
    }
94
}