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 @ 37186
History | View | Annotate | Download (4.91 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á</a>
|
49 |
*/
|
50 |
public class OutputWizard implements OptionPanel { |
51 |
|
52 |
/**
|
53 |
*
|
54 |
*/
|
55 |
private static final long serialVersionUID = 555020268506822671L; |
56 |
private JOutputPanel outputPanel;
|
57 |
private PackageInfo packageInfo;
|
58 |
|
59 |
// private DefaultMakeSymbolPackageWizard wizard;
|
60 |
|
61 |
// private static final Logger logger =
|
62 |
// LoggerFactory.getLogger(OutputWizard.class);
|
63 |
|
64 |
public OutputWizard(DefaultMakeSymbolPackageWizard wizard,
|
65 |
PackageInfo packageInfo) { |
66 |
super();
|
67 |
// this.wizard = wizard;
|
68 |
outputPanel = |
69 |
SwingInstallerLocator.getSwingInstallerManager() |
70 |
.createOutputPanel(); |
71 |
this.packageInfo = packageInfo;
|
72 |
} |
73 |
|
74 |
public JPanel getJPanel() { |
75 |
return this.outputPanel; |
76 |
} |
77 |
|
78 |
private String getText(String msg) { |
79 |
return Messages.getText(msg);
|
80 |
} |
81 |
|
82 |
public String getPanelTitle() { |
83 |
return getText("_output_options"); |
84 |
} |
85 |
|
86 |
public void lastPanel() { |
87 |
|
88 |
} |
89 |
|
90 |
public void nextPanel() throws NotContinueWizardException { |
91 |
// try {
|
92 |
File file = outputPanel.getPackageFile();
|
93 |
File filePath = new File(file.getParent()); |
94 |
if (!filePath.exists()) {
|
95 |
JOptionPane.showMessageDialog(outputPanel,
|
96 |
getText("_the_package_file_folder_does_not_exist") + ": " |
97 |
+ filePath); |
98 |
throw new NotContinueWizardException("", null, false); |
99 |
} |
100 |
if (outputPanel.isCreatePackageIndex()) {
|
101 |
URL url = outputPanel.getDownloadURL();
|
102 |
if (url == null) { |
103 |
throw new NotContinueWizardException("", null, false); |
104 |
} |
105 |
File indexFile = outputPanel.getPackageIndexFile();
|
106 |
File indexFilePath = new File(indexFile.getParent()); |
107 |
if (!indexFilePath.exists()) {
|
108 |
JOptionPane.showMessageDialog(outputPanel,
|
109 |
getText("_the_package_index_file_folder_does_not_exist")
|
110 |
+ ": " + indexFilePath);
|
111 |
throw new NotContinueWizardException("", null, false); |
112 |
} |
113 |
} |
114 |
// } catch (FileNotFoundException e) {
|
115 |
// logger.info(
|
116 |
// getText("create_output_file_exception"), e);
|
117 |
// JOptionPane.showMessageDialog(wizard,
|
118 |
// getText("create_output_file_exception"));
|
119 |
// }
|
120 |
} |
121 |
|
122 |
public void updatePanel() { |
123 |
outputPanel.setPackageFile(getDefaultPackageBundleFile()); |
124 |
outputPanel.setPackageIndexFile(getDefaultPackageIndexBundleFile()); |
125 |
} |
126 |
|
127 |
private File getDefaultPackageBundleFile() { |
128 |
PluginsManager manager = PluginsLocator.getManager(); |
129 |
File installsFolder = manager.getInstallFolder();
|
130 |
String fileName =
|
131 |
InstallerLocator.getInstallerManager().getPackageFileName( |
132 |
packageInfo); |
133 |
return new File(installsFolder, fileName); |
134 |
} |
135 |
|
136 |
private File getDefaultPackageIndexBundleFile() { |
137 |
PluginsManager manager = PluginsLocator.getManager(); |
138 |
File installsFolder = manager.getInstallFolder();
|
139 |
String fileName =
|
140 |
InstallerLocator.getInstallerManager().getPackageIndexFileName( |
141 |
packageInfo); |
142 |
return new File(installsFolder, fileName); |
143 |
} |
144 |
|
145 |
} |