Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2021 / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / wizard / SelectBundlesWizard.java @ 34107

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

    
30
import java.io.File;
31
import java.net.MalformedURLException;
32
import java.net.URL;
33

    
34
import javax.swing.JPanel;
35

    
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

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

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

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

    
60
    public SelectBundlesWizard(
61
        DefaultInstallPackageWizard installerExecutionWizard,
62
        URL defaultDownloadURL) {
63
        super(defaultDownloadURL);
64
        this.installerExecutionWizard = installerExecutionWizard;
65
        updatePanel();
66
    }
67

    
68
    public JPanel getJPanel() {
69
        return this;
70
    }
71

    
72
    public String getPanelTitle() {
73
        return swingInstallerManager.getText("select_installer");
74
    }
75

    
76
    public void lastPanel() {
77
        // TODO Auto-generated method stub
78

    
79
    }
80

    
81
    public void nextPanel() throws NotContinueWizardException {
82
        InstallPackageService installerExecutionService =
83
            installerExecutionWizard.getInstallerExecutionService();
84
        try {
85
            if (isStandardSelected()) {
86
                installerExecutionService
87
                    .addBundlesFromDirectory(installerExecutionWizard
88
                        .getInstallFolder());
89
            } else {
90
                if (isURLSelected()) {
91
                    installerExecutionService.addBundle(getSelectedURL());
92
                } else {
93
                    File file = getSelectedFile();
94
                    if ((file != null) && (file.exists())) {
95
                        installerExecutionService.addBundle(getSelectedFile());
96
                    } else {
97
                        LOG.error("The selected file doesn't exist");
98
                    }
99
                }
100
            }
101
        } catch (InstallPackageServiceException e) {
102
            throw new NotContinueWizardException(
103
                swingInstallerManager.getText("execute_adding_error"), e, this);
104
        } catch (MalformedURLException e) {
105
            throw new NotContinueWizardException(
106
                swingInstallerManager.getText("execute_adding_error"), e, this);
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
}