Statistics
| Revision:

root / tags / v2_0_0_Build_2051 / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / wizard / WizardListenerAdapter.java @ 38753

History | View | Annotate | Download (2.66 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

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

    
30
import java.awt.Component;
31

    
32
import javax.swing.JOptionPane;
33

    
34
import org.gvsig.gui.beans.wizard.WizardPanel;
35
import org.gvsig.gui.beans.wizard.WizardPanelActionListener;
36
import org.gvsig.i18n.Messages;
37
import org.gvsig.installer.swing.api.wizard.InstallerWizardPanel;
38
import org.gvsig.tools.task.CancellableTask;
39

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

    
45
        private InstallerWizardPanel installerWizardPanel;
46

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

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

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

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