svn-gvsig-desktop / tags / v2_0_0_Build_2050 / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / wizard / SelectBundlesWizard.java @ 38692
History | View | Annotate | Download (3.8 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.execution.wizard; |
29 |
|
30 |
import java.io.File; |
31 |
import java.net.MalformedURLException; |
32 |
import java.net.URL; |
33 |
import java.util.List; |
34 |
|
35 |
import javax.swing.JPanel; |
36 |
|
37 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
38 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
39 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
40 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
41 |
import org.gvsig.installer.swing.impl.execution.DefaultInstallPackageWizard; |
42 |
import org.gvsig.installer.swing.impl.execution.panel.SelectBundlesPanel; |
43 |
import org.slf4j.Logger; |
44 |
import org.slf4j.LoggerFactory; |
45 |
|
46 |
/**
|
47 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
48 |
*/
|
49 |
public class SelectBundlesWizard extends SelectBundlesPanel implements |
50 |
OptionPanel { |
51 |
|
52 |
private static final long serialVersionUID = -3694039665800882085L; |
53 |
private DefaultInstallPackageWizard installerExecutionWizard;
|
54 |
private static final Logger LOG = LoggerFactory |
55 |
.getLogger(SelectBundlesWizard.class); |
56 |
|
57 |
public SelectBundlesWizard(
|
58 |
DefaultInstallPackageWizard installerExecutionWizard, |
59 |
List<URL> defaultDownloadURL) { |
60 |
super(defaultDownloadURL, installerExecutionWizard.getInstallFolder());
|
61 |
this.installerExecutionWizard = installerExecutionWizard;
|
62 |
updatePanel(); |
63 |
} |
64 |
|
65 |
public JPanel getJPanel() { |
66 |
return this; |
67 |
} |
68 |
|
69 |
public String getPanelTitle() { |
70 |
return swingInstallerManager.getText("_select_installation_source"); |
71 |
} |
72 |
|
73 |
public void lastPanel() { |
74 |
} |
75 |
|
76 |
public void nextPanel() throws NotContinueWizardException { |
77 |
InstallPackageService installerExecutionService = installerExecutionWizard |
78 |
.getInstallerExecutionService(); |
79 |
installerExecutionService.reset(); |
80 |
|
81 |
try {
|
82 |
if (isStandardSelected()) {
|
83 |
installerExecutionService |
84 |
.addBundlesFromDirectory(installerExecutionWizard |
85 |
.getInstallFolder()); |
86 |
} else {
|
87 |
if (isURLSelected()) {
|
88 |
installerExecutionService.addBundle(getSelectedURL()); |
89 |
} else {
|
90 |
File file = getSelectedFile();
|
91 |
if ((file != null) && (file.exists())) { |
92 |
installerExecutionService.addBundle(file); |
93 |
} else {
|
94 |
LOG.error(swingInstallerManager.getText(""
|
95 |
+ "_the_selected_file_does_not_exist"));
|
96 |
} |
97 |
} |
98 |
} |
99 |
} catch (InstallPackageServiceException e) {
|
100 |
throw new NotContinueWizardException(swingInstallerManager |
101 |
.getText("_execute_adding_error"), e, this); |
102 |
} catch (MalformedURLException e) { |
103 |
throw new NotContinueWizardException(swingInstallerManager |
104 |
.getText("_execute_adding_error"), e, this); |
105 |
} |
106 |
|
107 |
} |
108 |
|
109 |
public void updatePanel() { |
110 |
if (installerExecutionWizard != null) { |
111 |
installerExecutionWizard.setBackButtonEnabled(false);
|
112 |
} |
113 |
} |
114 |
|
115 |
@Override
|
116 |
protected void checkNextButtonEnabled() { |
117 |
if (installerExecutionWizard != null) { |
118 |
installerExecutionWizard |
119 |
.setNextButtonEnabled(isNextButtonEnabled()); |
120 |
} |
121 |
} |
122 |
|
123 |
} |