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 / SelectFilesWizard.java @ 40560

History | View | Annotate | Download (3.53 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
import java.util.List;
33

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

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

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

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

    
53
        public SelectFilesWizard(
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("_files_to_copy");
65
        }
66

    
67
        public void lastPanel() {
68
                // Do nothing
69

    
70
        }
71

    
72
        public void nextPanel() {
73

    
74
                PackageInfo packageInfo = installerCreationWizard
75
                                .getSelectedPackageInfo();
76

    
77
                packageInfo.clearFilesToCopy();
78
                List<File> selectedFiles = getSelectedFiles();
79

    
80
                for (int i = 0; i < selectedFiles.size(); i++) {
81
                        packageInfo.addFileToCopy(selectedFiles.get(i));
82
                }
83
        }
84

    
85
        public void updatePanel() {
86

    
87
                InstallerManager manager = InstallerLocator.getInstallerManager();
88
                String pluginName = installerCreationWizard.getSelectedPackageInfo()
89
                                .getCode();
90
                File pluginLocation = manager.getAddonFolder(pluginName);
91
                File folder = null;
92

    
93
                if (pluginLocation != null) {
94
                        String path = pluginLocation.getAbsolutePath() + File.separator
95
                                        + "install" + File.separator + "files";
96
                        folder = new File(path);
97
                }
98

    
99
                if (folder != null && folder.exists() && folder.isDirectory()) {
100
                        String msg = Messages
101
                                        .getText("_the_folder_install/files_already_exists_do_you_want_to_delete_it_before_proceeding?");
102

    
103
                        int resp = JOptionPane.showConfirmDialog(null, msg, Messages
104
                                        .getText("_select_an_option"), JOptionPane.YES_NO_OPTION);
105

    
106
                        if (resp == JOptionPane.OK_OPTION) {
107
                                PackageInfo packageInfo = installerCreationWizard
108
                                                .getSelectedPackageInfo();
109

    
110
                                if (!packageInfo.removeFilesFolder(folder)) {
111
                                        JOptionPane.showMessageDialog(null, Messages
112
                                                        .getText("_Couldn't_delete_the_directory"));
113
                                }
114
                        }
115

    
116
                }
117

    
118
        }
119

    
120
}