Revision 36350
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/execution/wizard/DownloadProgressWizard.java | ||
---|---|---|
56 | 56 |
OptionPanel { |
57 | 57 |
|
58 | 58 |
private static final long serialVersionUID = -7064334977678611609L; |
59 |
private static Logger logger = LoggerFactory.getLogger(DownloadProgressWizard.class); |
|
59 |
private static Logger logger = |
|
60 |
LoggerFactory.getLogger(DownloadProgressWizard.class); |
|
60 | 61 |
private AbstractInstallPackageWizard installPackageWizard; |
61 | 62 |
// private DefaultInstallPackageWizard defaultInstallPackageWizard; |
62 | 63 |
public JButton startDownload; |
... | ... | |
116 | 117 |
public void updatePanel() { |
117 | 118 |
boolean thereIsDownloablePackage = false; |
118 | 119 |
|
119 |
InstallPackageService service = installPackageWizard.getInstallerExecutionService(); |
|
120 |
InstallPackageService service = |
|
121 |
installPackageWizard.getInstallerExecutionService(); |
|
120 | 122 |
service.getPackageCount(); |
121 |
|
|
123 |
|
|
122 | 124 |
for (int i = 0; i < installPackageWizard.getInstallersToInstall() |
123 | 125 |
.size(); i++) { |
124 | 126 |
|
... | ... | |
153 | 155 |
|
154 | 156 |
@Override |
155 | 157 |
public synchronized void run() { |
156 |
List<PackageInfo> installersToInstall = |
|
157 |
this.panel.installPackageWizard.getInstallersToInstall(); |
|
158 |
this.panel.startDownload.setEnabled(false); |
|
159 |
this.panel.installPackageWizard.setBackButtonEnabled(false); |
|
160 |
InstallPackageService installerService = |
|
161 |
this.panel.installPackageWizard |
|
162 |
.getInstallerExecutionService(); |
|
163 |
SimpleTaskStatus taskStatus = |
|
164 |
(SimpleTaskStatus) this.getTaskStatus(); |
|
165 |
for (int i = 0; i < installersToInstall.size(); i++) { |
|
166 |
taskStatus.setCurValue(0); |
|
167 |
PackageInfo installerInfo = installersToInstall.get(i); |
|
168 |
taskStatus.message(installerInfo.getName() + " " + (i + 1) |
|
169 |
+ " / " + installersToInstall.size()); |
|
170 |
if (installerInfo.getDownloadURL() != null) { |
|
171 |
try { |
|
172 |
installerService.downloadPackage(installerInfo, |
|
173 |
taskStatus); |
|
174 |
} catch (Exception e) { |
|
175 |
String msg = panel.swingInstallerManager.getText("_Cant_download_package_files")+" "+installerInfo.getName(); |
|
176 |
logger.info(msg, e); |
|
177 |
int resp = JOptionPane.showOptionDialog( |
|
178 |
null, |
|
179 |
msg + "\n"+panel.swingInstallerManager.getText("do_you_want_to_continue"), |
|
180 |
panel.swingInstallerManager.getText("_Downloading_error"), |
|
181 |
JOptionPane.YES_NO_OPTION, |
|
182 |
JOptionPane.ERROR_MESSAGE, |
|
183 |
null, |
|
184 |
null, |
|
185 |
null); |
|
186 |
if (resp==JOptionPane.NO_OPTION){ |
|
187 |
taskStatus.cancelRequest(); |
|
188 |
} |
|
189 |
} |
|
190 |
} |
|
191 |
if (taskStatus.isCancellationRequested()) { |
|
192 |
break; |
|
193 |
} |
|
194 |
} |
|
195 |
// Set the finished text |
|
196 |
taskStatus.message(panel.getText("finished")); |
|
197 |
taskStatus.terminate(); |
|
198 |
taskStatus.remove(); |
|
199 |
if (!taskStatus.isCancellationRequested()) { |
|
200 |
this.panel.installPackageWizard.setNextButtonEnabled(true); |
|
201 |
} |
|
202 |
this.panel.installPackageWizard.setBackButtonEnabled(true); |
|
158 |
List<PackageInfo> installersToInstall = |
|
159 |
this.panel.installPackageWizard.getInstallersToInstall(); |
|
160 |
this.panel.startDownload.setEnabled(false); |
|
161 |
this.panel.installPackageWizard.setBackButtonEnabled(false); |
|
162 |
InstallPackageService installerService = |
|
163 |
this.panel.installPackageWizard.getInstallerExecutionService(); |
|
164 |
SimpleTaskStatus taskStatus = |
|
165 |
(SimpleTaskStatus) this.getTaskStatus(); |
|
166 |
for (int i = 0; i < installersToInstall.size(); i++) { |
|
167 |
taskStatus.setCurValue(0); |
|
168 |
PackageInfo installerInfo = installersToInstall.get(i); |
|
169 |
taskStatus.message(installerInfo.getName() + " " + (i + 1) |
|
170 |
+ " / " + installersToInstall.size()); |
|
171 |
if (installerInfo.getDownloadURL() != null) { |
|
172 |
try { |
|
173 |
installerService.downloadPackage(installerInfo, |
|
174 |
taskStatus); |
|
175 |
} catch (Exception e) { |
|
176 |
String msg = |
|
177 |
panel.swingInstallerManager |
|
178 |
.getText("_Cant_download_package_files") |
|
179 |
+ " " + installerInfo.getName(); |
|
180 |
logger.info(msg, e); |
|
181 |
int resp = |
|
182 |
JOptionPane.showOptionDialog(null, msg |
|
183 |
+ "\n" |
|
184 |
+ panel.swingInstallerManager |
|
185 |
.getText("do_you_want_to_continue"), |
|
186 |
panel.swingInstallerManager |
|
187 |
.getText("_Downloading_error"), |
|
188 |
JOptionPane.YES_NO_OPTION, |
|
189 |
JOptionPane.ERROR_MESSAGE, null, null, null); |
|
190 |
if (resp == JOptionPane.NO_OPTION) { |
|
191 |
taskStatus.cancelRequest(); |
|
192 |
} |
|
193 |
} |
|
194 |
} |
|
195 |
if (taskStatus.isCancellationRequested()) { |
|
196 |
break; |
|
197 |
} |
|
198 |
} |
|
199 |
// Set the finished text |
|
200 |
taskStatus.message(panel.getText("finished")); |
|
201 |
taskStatus.terminate(); |
|
202 |
taskStatus.remove(); |
|
203 |
if (!taskStatus.isCancellationRequested()) { |
|
204 |
this.panel.installPackageWizard.setNextButtonEnabled(true); |
|
205 |
} |
|
206 |
this.panel.installPackageWizard.setBackButtonEnabled(true); |
|
203 | 207 |
} |
204 | 208 |
|
205 | 209 |
} |
Also available in: Unified diff