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