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 / execution / wizard / SelectBundlesWizard.java @ 40560

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

    
31
import java.io.File;
32
import java.net.MalformedURLException;
33
import java.net.URL;
34
import java.util.List;
35

    
36
import javax.swing.JPanel;
37

    
38
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
39
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
40
import org.gvsig.installer.lib.api.execution.InstallPackageService;
41
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
42
import org.gvsig.installer.swing.impl.execution.DefaultInstallPackageWizard;
43
import org.gvsig.installer.swing.impl.execution.panel.SelectBundlesPanel;
44
import org.slf4j.Logger;
45
import org.slf4j.LoggerFactory;
46

    
47
/**
48
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
49
 */
50
public class SelectBundlesWizard extends SelectBundlesPanel implements
51
                OptionPanel {
52

    
53
        private static final long serialVersionUID = -3694039665800882085L;
54
        private DefaultInstallPackageWizard installerExecutionWizard;
55
        private static final Logger LOG = LoggerFactory
56
                        .getLogger(SelectBundlesWizard.class);
57

    
58
        public SelectBundlesWizard(
59
                        DefaultInstallPackageWizard installerExecutionWizard,
60
                        List<URL> defaultDownloadURL) {
61
                super(defaultDownloadURL, installerExecutionWizard.getInstallFolder());
62
                this.installerExecutionWizard = installerExecutionWizard;
63
                updatePanel();
64
        }
65

    
66
        public JPanel getJPanel() {
67
                return this;
68
        }
69

    
70
        public String getPanelTitle() {
71
                return swingInstallerManager.getText("_select_installation_source");
72
        }
73

    
74
        public void lastPanel() {
75
        }
76

    
77
        public void nextPanel() throws NotContinueWizardException {
78
                InstallPackageService installerExecutionService = installerExecutionWizard
79
                                .getInstallerExecutionService();
80
                installerExecutionService.reset();
81

    
82
                try {
83
                        if (isStandardSelected()) {
84
                                installerExecutionService
85
                                                .addBundlesFromDirectory(installerExecutionWizard
86
                                                                .getInstallFolder());
87
                        } else {
88
                                if (isURLSelected()) {
89
                                        installerExecutionService.addBundle(getSelectedURL());
90
                                } else {
91
                                        File file = getSelectedFile();
92
                                        if ((file != null) && (file.exists())) {
93
                                                installerExecutionService.addBundle(file);
94
                                        } else {
95
                                                LOG.error(swingInstallerManager.getText(""
96
                                                                + "_the_selected_file_does_not_exist"));
97
                                        }
98
                                }
99
                        }
100
                } catch (InstallPackageServiceException e) {
101
                        throw new NotContinueWizardException(swingInstallerManager
102
                                        .getText("_execute_adding_error"), e, this);
103
                } catch (MalformedURLException e) {
104
                        throw new NotContinueWizardException(swingInstallerManager
105
                                        .getText("_execute_adding_error"), e, this);
106
                }
107

    
108
        }
109

    
110
        public void updatePanel() {
111
                if (installerExecutionWizard != null) {
112
                        installerExecutionWizard.setBackButtonEnabled(false);
113
                }
114
        }
115

    
116
        @Override
117
        protected void checkNextButtonEnabled() {
118
                if (installerExecutionWizard != null) {
119
                        installerExecutionWizard
120
                                        .setNextButtonEnabled(isNextButtonEnabled());
121
                }
122
        }
123

    
124
}