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 @ 37296

History | View | Annotate | Download (4.82 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.panel.NotContinueWizardException;
39
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
40
import org.gvsig.i18n.Messages;
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
import org.gvsig.symbology.app.symbolinstaller.creation.DefaultMakeSymbolPackageWizard;
46

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

    
52
    private JOutputPanel outputPanel;
53
    private PackageInfo packageInfo;
54

    
55
    // private DefaultMakeSymbolPackageWizard wizard;
56

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

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

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

    
74
    private String getText(String msg) {
75
        return Messages.getText(msg);
76
    }
77

    
78
    public String getPanelTitle() {
79
        return getText("_output_options");
80
    }
81

    
82
    public void lastPanel() {
83

    
84
    }
85

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

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

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

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

    
141
}