Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / wizard / WizardListenerAdapter.java @ 40560

History | View | Annotate | Download (2.7 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

    
29
package org.gvsig.installer.swing.impl.wizard;
30

    
31
import java.awt.Component;
32

    
33
import javax.swing.JOptionPane;
34

    
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.installer.swing.api.wizard.InstallerWizardPanel;
39
import org.gvsig.tools.task.CancellableTask;
40

    
41
/**
42
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
43
 */
44
public class WizardListenerAdapter implements WizardPanelActionListener {
45

    
46
        private InstallerWizardPanel installerWizardPanel;
47

    
48
        public WizardListenerAdapter(InstallerWizardPanel installerWizardPanel) {
49
                super();
50
                this.installerWizardPanel = installerWizardPanel;
51
        }
52

    
53
        public void cancel(WizardPanel wizardPanel) {
54
                if (installerWizardPanel.getWizardActionListener() != null) {
55
                        for (CancellableTask task : installerWizardPanel
56
                                        .getCancellableTasks()) {
57
                                task.cancelRequest();
58
                        }
59
                        installerWizardPanel.getWizardActionListener().cancel(
60
                                        installerWizardPanel);
61
                }
62
        }
63

    
64
        public void finish(WizardPanel wizardPanel) {
65
                if (installerWizardPanel.getWizardActionListener() != null) {
66
                        installerWizardPanel.getWizardActionListener().finish(
67
                                        installerWizardPanel);
68
                }
69
                
70
                if (installerWizardPanel.needsToRestartApplicationAfterFinish()) {
71

    
72
                    // --------------------------- Suggest restart
73
                    Component parent = null;
74
                    if (installerWizardPanel instanceof Component) {
75
                        parent = (Component) installerWizardPanel;
76
                    }
77
                    JOptionPane.showMessageDialog(
78
                        parent,
79
                        Messages.getText("_gvSIG_must_be_restarted_to_have_changes_applied"),
80
                Messages.getText("_finished"),
81
                        JOptionPane.WARNING_MESSAGE);
82
                }
83
        }
84
}