root / tags / v2_0_0_Build_2051 / 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 @ 38753
History | View | Annotate | Download (3.8 KB)
1 | 32401 | jpiera | /* 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 | 33982 | cordinyana | import java.net.MalformedURLException; |
32 | 34003 | cordinyana | import java.net.URL; |
33 | 37417 | fdiaz | import java.util.List; |
34 | 32401 | jpiera | |
35 | import javax.swing.JPanel; |
||
36 | |||
37 | 34005 | cordinyana | import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
38 | 33260 | jpiera | import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
39 | 32565 | jpiera | 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 | 32635 | jpiera | import org.gvsig.installer.swing.impl.execution.panel.SelectBundlesPanel; |
43 | 37417 | fdiaz | import org.slf4j.Logger; |
44 | import org.slf4j.LoggerFactory; |
||
45 | 32401 | jpiera | |
46 | /**
|
||
47 | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
||
48 | */
|
||
49 | 33729 | cordinyana | public class SelectBundlesWizard extends SelectBundlesPanel implements |
50 | 37598 | nfrancisco | OptionPanel { |
51 | 32401 | jpiera | |
52 | 37598 | nfrancisco | private static final long serialVersionUID = -3694039665800882085L; |
53 | private DefaultInstallPackageWizard installerExecutionWizard;
|
||
54 | private static final Logger LOG = LoggerFactory |
||
55 | .getLogger(SelectBundlesWizard.class); |
||
56 | 32401 | jpiera | |
57 | 37598 | nfrancisco | public SelectBundlesWizard(
|
58 | DefaultInstallPackageWizard installerExecutionWizard, |
||
59 | List<URL> defaultDownloadURL) { |
||
60 | 38234 | vacevedo | super(defaultDownloadURL, installerExecutionWizard.getInstallFolder());
|
61 | 37598 | nfrancisco | this.installerExecutionWizard = installerExecutionWizard;
|
62 | updatePanel(); |
||
63 | } |
||
64 | 32401 | jpiera | |
65 | 37598 | nfrancisco | public JPanel getJPanel() { |
66 | return this; |
||
67 | } |
||
68 | 32401 | jpiera | |
69 | 37598 | nfrancisco | public String getPanelTitle() { |
70 | 37610 | nfrancisco | return swingInstallerManager.getText("_select_installation_source"); |
71 | 37598 | nfrancisco | } |
72 | 32401 | jpiera | |
73 | 37598 | nfrancisco | public void lastPanel() { |
74 | } |
||
75 | 32401 | jpiera | |
76 | 37598 | nfrancisco | public void nextPanel() throws NotContinueWizardException { |
77 | InstallPackageService installerExecutionService = installerExecutionWizard |
||
78 | .getInstallerExecutionService(); |
||
79 | installerExecutionService.reset(); |
||
80 | 32435 | jpiera | |
81 | 37598 | nfrancisco | 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 | 35189 | nfrancisco | |
107 | 37598 | nfrancisco | } |
108 | 35189 | nfrancisco | |
109 | 37598 | nfrancisco | public void updatePanel() { |
110 | if (installerExecutionWizard != null) { |
||
111 | installerExecutionWizard.setBackButtonEnabled(false);
|
||
112 | } |
||
113 | } |
||
114 | 33729 | cordinyana | |
115 | 37598 | nfrancisco | @Override
|
116 | protected void checkNextButtonEnabled() { |
||
117 | if (installerExecutionWizard != null) { |
||
118 | installerExecutionWizard |
||
119 | .setNextButtonEnabled(isNextButtonEnabled()); |
||
120 | } |
||
121 | } |
||
122 | 33729 | cordinyana | |
123 | 32401 | jpiera | } |