Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.symbology.app / org.gvsig.symbology.app.symbolinstaller / src / main / java / org / gvsig / symbology / app / symbolinstaller / creation / wizard / OutputWizard.java @ 37171

History | View | Annotate | Download (4.81 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.symbology.app.symbolinstaller.creation.wizard;
29

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

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

    
36
import org.gvsig.andami.PluginsLocator;
37
import org.gvsig.andami.PluginsManager;
38
import org.gvsig.gui.beans.wizard.WizardPanel;
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.InstallerLocator;
42
import org.gvsig.installer.lib.api.PackageInfo;
43
import org.gvsig.installer.swing.api.SwingInstallerLocator;
44
import org.gvsig.installer.swing.api.creation.JOutputPanel;
45

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

    
51
    /**
52
     * 
53
     */
54
    private static final long serialVersionUID = 555020268506822671L;
55
    // private WizardPanel wizard;
56
    private JOutputPanel outputPanel;
57
    private PackageInfo packageInfo;
58

    
59
    // private static final Logger logger =
60
    // LoggerFactory.getLogger(OutputWizard.class);
61

    
62
    public OutputWizard(WizardPanel wizardPanel, PackageInfo packageInfo) {
63
        super();
64
        // this.wizard = wizardPanel;
65
        outputPanel =
66
            SwingInstallerLocator.getSwingInstallerManager()
67
                .createOutputPanel();
68
        this.packageInfo = packageInfo;
69
    }
70

    
71
    public JPanel getJPanel() {
72
        return this.outputPanel;
73
    }
74

    
75
    private String getText(String msg) {
76
        return msg; // FIXME
77
    }
78

    
79
    public String getPanelTitle() {
80
        return getText("output_options");
81
    }
82

    
83
    public void lastPanel() {
84

    
85
    }
86

    
87
    public void nextPanel() throws NotContinueWizardException {
88
        // try {
89
        File file = outputPanel.getPackageFile();
90
        File filePath = new File(file.getParent());
91
        if (!filePath.exists()) {
92
            JOptionPane
93
                .showMessageDialog(outputPanel,
94
                    getText("The_package_file_folder_does_not_exist: _")
95
                        + filePath);
96
            throw new NotContinueWizardException("", null, false);
97
        }
98
        if (outputPanel.isCreatePackageIndex()) {
99
            URL url = outputPanel.getDownloadURL();
100
            if (url == null) {
101
                throw new NotContinueWizardException("", null, false);
102
            }
103
            File indexFile = outputPanel.getPackageIndexFile();
104
            File indexFilePath = new File(indexFile.getParent());
105
            if (!indexFilePath.exists()) {
106
                JOptionPane.showMessageDialog(outputPanel,
107
                    getText("The_package_index_file_folder_does_not_exist: _")
108
                        + indexFilePath);
109
                throw new NotContinueWizardException("", null, false);
110
            }
111
        }
112
        // } catch (FileNotFoundException e) {
113
        // logger.info(
114
        // getText("create_output_file_exception"), e);
115
        // JOptionPane.showMessageDialog(wizard,
116
        // getText("create_output_file_exception"));
117
        // }
118
    }
119

    
120
    public void updatePanel() {
121
        outputPanel.setPackageFile(getDefaultPackageBundleFile());
122
        outputPanel.setPackageIndexFile(getDefaultPackageIndexBundleFile());
123
    }
124

    
125
    private File getDefaultPackageBundleFile() {
126
        PluginsManager manager = PluginsLocator.getManager();
127
        File installsFolder = manager.getInstallFolder();
128
        String fileName =
129
            InstallerLocator.getInstallerManager().getPackageFileName(
130
                packageInfo);
131
        return new File(installsFolder, fileName);
132
    }
133

    
134
    private File getDefaultPackageIndexBundleFile() {
135
        PluginsManager manager = PluginsLocator.getManager();
136
        File installsFolder = manager.getInstallFolder();
137
        String fileName =
138
            InstallerLocator.getInstallerManager().getPackageIndexFileName(
139
                packageInfo);
140
        return new File(installsFolder, fileName);
141
    }
142

    
143
}