svn-gvsig-desktop / tags / v2_0_0_Build_2042 / 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 @ 37479
History | View | Annotate | Download (4.29 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 |
/**
|
53 |
*
|
54 |
*/
|
55 |
private static final long serialVersionUID = -3694039665800882085L; |
56 |
private DefaultInstallPackageWizard installerExecutionWizard;
|
57 |
private static final Logger LOG = |
58 |
LoggerFactory.getLogger(SelectBundlesWizard.class); |
59 |
|
60 |
public SelectBundlesWizard(
|
61 |
DefaultInstallPackageWizard installerExecutionWizard, |
62 |
List<URL> defaultDownloadURL) { |
63 |
super(defaultDownloadURL);
|
64 |
this.installerExecutionWizard = installerExecutionWizard;
|
65 |
updatePanel(); |
66 |
} |
67 |
|
68 |
public JPanel getJPanel() { |
69 |
return this; |
70 |
} |
71 |
|
72 |
public String getPanelTitle() { |
73 |
return swingInstallerManager.getText("select_installer"); |
74 |
} |
75 |
|
76 |
public void lastPanel() { |
77 |
// TODO Auto-generated method stub
|
78 |
|
79 |
} |
80 |
|
81 |
public void nextPanel() throws NotContinueWizardException { |
82 |
InstallPackageService installerExecutionService = |
83 |
installerExecutionWizard.getInstallerExecutionService(); |
84 |
installerExecutionService.reset(); |
85 |
|
86 |
try {
|
87 |
if (isStandardSelected()) {
|
88 |
installerExecutionService |
89 |
.addBundlesFromDirectory(installerExecutionWizard |
90 |
.getInstallFolder()); |
91 |
} else {
|
92 |
if (isURLSelected()) {
|
93 |
installerExecutionService.addBundle(getSelectedURL()); |
94 |
} else {
|
95 |
File file = getSelectedFile();
|
96 |
if ((file != null) && (file.exists())) { |
97 |
installerExecutionService.addBundle(file); |
98 |
} else {
|
99 |
LOG.error("The selected file doesn't exist");
|
100 |
} |
101 |
} |
102 |
} |
103 |
} catch (InstallPackageServiceException e) {
|
104 |
throw new NotContinueWizardException(swingInstallerManager |
105 |
.getText("execute_adding_error"), e, this); |
106 |
} catch (MalformedURLException e) { |
107 |
throw new NotContinueWizardException(swingInstallerManager |
108 |
.getText("execute_adding_error"), e, this); |
109 |
} |
110 |
|
111 |
} |
112 |
|
113 |
public void updatePanel() { |
114 |
if (installerExecutionWizard != null) { |
115 |
installerExecutionWizard.setBackButtonEnabled(false);
|
116 |
} |
117 |
} |
118 |
|
119 |
@Override
|
120 |
protected void checkNextButtonEnabled() { |
121 |
if (installerExecutionWizard != null) { |
122 |
installerExecutionWizard |
123 |
.setNextButtonEnabled(isNextButtonEnabled()); |
124 |
} |
125 |
} |
126 |
|
127 |
} |