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 / packagebuilder / options / OutputOption.java @ 42528

History | View | Annotate | Download (3.99 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

    
26
package org.gvsig.installer.swing.impl.packagebuilder.options;
27

    
28
import java.io.File;
29
import java.net.URL;
30

    
31
import javax.swing.JOptionPane;
32
import javax.swing.JPanel;
33

    
34
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
35
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
36
import org.gvsig.i18n.Messages;
37
import org.gvsig.installer.swing.api.SwingInstallerLocator;
38
import org.gvsig.installer.swing.api.SwingInstallerManager;
39
import org.gvsig.installer.swing.api.creation.JOutputPanel;
40
import org.gvsig.installer.swing.impl.packagebuilder.BasePackageWizard;
41

    
42

    
43
public class OutputOption implements OptionPanel {
44

    
45
    private final JOutputPanel outputPanel;
46
    private final BasePackageWizard wizard;
47

    
48
    public OutputOption(BasePackageWizard wizard) {
49
        super();
50
        this.wizard = wizard;
51
        SwingInstallerManager installerManager = SwingInstallerLocator.getSwingInstallerManager();
52

    
53
        outputPanel = installerManager.createOutputPanel();
54
        this.outputPanel.setPackageInfo(wizard.getPackageInfo());
55
    }
56

    
57
    @Override
58
    public JPanel getJPanel() {
59
        return this.outputPanel;
60
    }
61

    
62
    private String getText(String msg) {
63
        return Messages.getText(msg);
64
    }
65

    
66
    @Override
67
    public String getPanelTitle() {
68
        return getText("_output_options");
69
    }
70

    
71
    @Override
72
    public void lastPanel() {
73

    
74
    }
75

    
76
    @Override
77
    public void nextPanel() throws NotContinueWizardException {
78

    
79
        File file = outputPanel.getPackageFile();
80
        File filePath = new File(file.getParent());
81
        if (!filePath.exists()) {
82
            JOptionPane.showMessageDialog(outputPanel,
83
                getText("_the_package_file_folder_does_not_exist") + ": "
84
                    + filePath);
85
            throw new NotContinueWizardException("", null, false);
86
        }
87
        if (outputPanel.isCreatePackageIndex()) {
88
            URL url = outputPanel.getDownloadURL();
89
            if (url == null) {
90
                throw new NotContinueWizardException("", null, false);
91
            }
92
            File indexFile = outputPanel.getPackageIndexFile();
93
            File indexFilePath = new File(indexFile.getParent());
94
            if (!indexFilePath.exists()) {
95
                JOptionPane.showMessageDialog(outputPanel,
96
                    getText("_the_package_index_file_folder_does_not_exist")
97
                        + ": " + indexFilePath);
98
                throw new NotContinueWizardException("", null, false);
99
            }
100
        }
101

    
102
    }
103

    
104
    @Override
105
    public void updatePanel() {
106
        outputPanel.setPackageFile(this.wizard.getDefaultPackageBundleFile());
107
        outputPanel.setPackageIndexFile(this.wizard.getDefaultPackageIndexBundleFile());
108
    }
109

    
110
    public URL getDownloadURL() {
111
        return this.outputPanel.getDownloadURL();
112
    }
113
    
114
    public File getPackageIndexFile() {
115
        return this.outputPanel.getPackageIndexFile();
116
    }
117
    
118
    public boolean shouldCreateIndex() {
119
        return this.outputPanel.isCreatePackageIndex();
120
    }
121
    
122
    public File getPackageFile() {
123
        return this.outputPanel.getPackageFile();
124
    }
125
}