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 / creation / wizard / AdvancedModeSelectionWizard.java @ 40560

History | View | Annotate | Download (3.46 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.creation.wizard;
30

    
31
import java.io.File;
32

    
33
import javax.swing.JOptionPane;
34
import javax.swing.JPanel;
35

    
36
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
37
import org.gvsig.i18n.Messages;
38
import org.gvsig.installer.lib.api.InstallerLocator;
39
import org.gvsig.installer.lib.api.InstallerManager;
40
import org.gvsig.installer.lib.api.PackageInfo;
41
import org.gvsig.installer.swing.impl.creation.DefaultMakePluginPackageWizard;
42
import org.gvsig.installer.swing.impl.creation.panel.AdvancedModeSelectionPanel;
43

    
44
/**
45
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
46
 */
47
public class AdvancedModeSelectionWizard extends AdvancedModeSelectionPanel
48
                implements OptionPanel {
49

    
50
        private static final long serialVersionUID = 257540289911849694L;
51
        private DefaultMakePluginPackageWizard installerCreationWizard;
52

    
53
        public AdvancedModeSelectionWizard(
54
                        DefaultMakePluginPackageWizard installerCreationWizard) {
55
                super();
56
                this.installerCreationWizard = installerCreationWizard;
57
        }
58

    
59
        public JPanel getJPanel() {
60
                return this;
61
        }
62

    
63
        public String getPanelTitle() {
64
                return swingInstallerManager.getText("_advanced_options");
65
        }
66

    
67
        public void lastPanel() {
68
                // TODO Auto-generated method stub
69
        }
70

    
71
        public void nextPanel() {
72

    
73
                if (!isAdvancedModeSelected()) {
74

    
75
                        InstallerManager manager = InstallerLocator.getInstallerManager();
76
                        String pluginName = installerCreationWizard
77
                                        .getSelectedPackageInfo().getCode();
78
                        File pluginLocation = manager.getAddonFolder(pluginName);
79
                        File folder = null;
80

    
81
                        if (pluginLocation != null) {
82
                                String path = pluginLocation.getAbsolutePath() + File.separator
83
                                                + "install";
84
                                folder = new File(path);
85
                        }
86

    
87
                        if (folder != null && folder.exists()) {
88
                                String msg = Messages
89
                                                .getText("_the_folder_install_already_exists._do_you_want_to_delete_it_before_proceeding?");
90

    
91
                                int resp = JOptionPane.showConfirmDialog(null, msg, Messages
92
                                                .getText("_select_an_option"),
93
                                                JOptionPane.YES_NO_OPTION);
94

    
95
                                if (resp == JOptionPane.OK_OPTION) {
96
                                        PackageInfo packageInfo = installerCreationWizard
97
                                                        .getSelectedPackageInfo();
98
                                        boolean success = packageInfo.removeInstallFolder(folder);
99

    
100
                                        if (!success) {
101
                                                JOptionPane.showMessageDialog(null, Messages
102
                                                                .getText("_Couldn't_delete_the_directory"));
103
                                        }
104
                                }
105
                        }
106
                }
107
                installerCreationWizard
108
                                .setAdvancedModeSelected(isAdvancedModeSelected());
109
        }
110

    
111
        public void updatePanel() {
112
                // TODO Auto-generated method stub
113

    
114
        }
115

    
116
}