svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / creation / wizard / SelectOutputFileWizard.java @ 37607
History | View | Annotate | Download (4.6 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.creation.wizard; |
29 |
|
30 |
import java.io.File; |
31 |
import java.io.FileNotFoundException; |
32 |
import java.io.FileOutputStream; |
33 |
import java.net.URL; |
34 |
|
35 |
import javax.swing.JOptionPane; |
36 |
import javax.swing.JPanel; |
37 |
|
38 |
import org.slf4j.Logger; |
39 |
import org.slf4j.LoggerFactory; |
40 |
|
41 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
42 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
43 |
import org.gvsig.installer.lib.api.InstallerLocator; |
44 |
import org.gvsig.installer.lib.api.PackageInfo; |
45 |
import org.gvsig.installer.swing.impl.creation.DefaultMakePluginPackageWizard; |
46 |
import org.gvsig.installer.swing.impl.creation.panel.DefaultOutputPanel; |
47 |
|
48 |
/**
|
49 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
50 |
*/
|
51 |
public class SelectOutputFileWizard extends DefaultOutputPanel implements |
52 |
OptionPanel { |
53 |
|
54 |
/**
|
55 |
*
|
56 |
*/
|
57 |
private static final long serialVersionUID = 555020268506822671L; |
58 |
private DefaultMakePluginPackageWizard installerCreationWizard;
|
59 |
private static final Logger logger = LoggerFactory |
60 |
.getLogger(SelectOutputFileWizard.class); |
61 |
|
62 |
public SelectOutputFileWizard(
|
63 |
DefaultMakePluginPackageWizard installerCreationWizard) { |
64 |
super();
|
65 |
this.installerCreationWizard = installerCreationWizard;
|
66 |
} |
67 |
|
68 |
public JPanel getJPanel() { |
69 |
return this; |
70 |
} |
71 |
|
72 |
public String getPanelTitle() { |
73 |
return swingInstallerManager.getText("_output_options"); |
74 |
} |
75 |
|
76 |
public void lastPanel() { |
77 |
|
78 |
} |
79 |
|
80 |
public void nextPanel() throws NotContinueWizardException { |
81 |
try {
|
82 |
File file = getPackageFile();
|
83 |
File filePath = new File(file.getParent()); |
84 |
if (!filePath.exists()) {
|
85 |
JOptionPane
|
86 |
.showMessageDialog( |
87 |
installerCreationWizard, |
88 |
swingInstallerManager |
89 |
.getText("_the_package_file_folder_does_not_exist")
|
90 |
+ ": " + filePath);
|
91 |
throw new NotContinueWizardException("", null, false); |
92 |
} |
93 |
|
94 |
if (isCreatePackageIndex()) {
|
95 |
URL url = getDownloadURL();
|
96 |
if (url == null) { |
97 |
throw new NotContinueWizardException("", null, false); |
98 |
} |
99 |
installerCreationWizard.setDownloadURL(url); |
100 |
File indexFile = getPackageIndexFile();
|
101 |
File indexFilePath = new File(indexFile.getParent()); |
102 |
if (!indexFilePath.exists()) {
|
103 |
JOptionPane
|
104 |
.showMessageDialog( |
105 |
installerCreationWizard, |
106 |
swingInstallerManager |
107 |
.getText("_the_package_index_file_folder_does_not_exist")
|
108 |
+ ": " + indexFilePath);
|
109 |
throw new NotContinueWizardException("", null, false); |
110 |
} |
111 |
installerCreationWizard |
112 |
.setIndexOutputStream(new FileOutputStream(indexFile)); |
113 |
} |
114 |
installerCreationWizard.setOutputStream(new FileOutputStream(file)); |
115 |
} catch (FileNotFoundException e) { |
116 |
logger.info(swingInstallerManager |
117 |
.getText("Create output file exception"), e);
|
118 |
JOptionPane.showMessageDialog(installerCreationWizard,
|
119 |
swingInstallerManager |
120 |
.getText("_create_output_file_exception"));
|
121 |
} |
122 |
} |
123 |
|
124 |
public void updatePanel() { |
125 |
setPackageFile(getDefaultPackageBundleFile()); |
126 |
setPackageIndexFile(getDefaultPackageIndexBundleFile()); |
127 |
} |
128 |
|
129 |
private File getDefaultPackageBundleFile() { |
130 |
File installsFolder = installerCreationWizard.getInstallFolder();
|
131 |
PackageInfo info = installerCreationWizard.getSelectedPackageInfo(); |
132 |
String fileName = InstallerLocator.getInstallerManager()
|
133 |
.getPackageFileName(info); |
134 |
return new File(installsFolder, fileName); |
135 |
} |
136 |
|
137 |
private File getDefaultPackageIndexBundleFile() { |
138 |
File installsFolder = installerCreationWizard.getInstallFolder();
|
139 |
PackageInfo info = installerCreationWizard.getSelectedPackageInfo(); |
140 |
String fileName = InstallerLocator.getInstallerManager()
|
141 |
.getPackageIndexFileName(info); |
142 |
return new File(installsFolder, fileName); |
143 |
} |
144 |
|
145 |
} |