svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / DefaultInstallWizardPanel.java @ 43195
History | View | Annotate | Download (8.57 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 {Prodevelop} {Task}
|
26 |
*/
|
27 |
package org.gvsig.installer.swing.impl.execution; |
28 |
|
29 |
import java.awt.BorderLayout; |
30 |
import java.io.File; |
31 |
import java.util.List; |
32 |
import javax.swing.JComponent; |
33 |
|
34 |
import org.gvsig.installer.lib.api.InstallerLocator; |
35 |
import org.gvsig.installer.lib.api.PackageInfo; |
36 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
37 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
38 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
39 |
import org.gvsig.installer.swing.api.SwingInstallerManager.UrlAndLabel; |
40 |
import org.gvsig.installer.swing.api.execution.PackageFilter; |
41 |
import org.gvsig.installer.swing.impl.execution.panel.SelectBundlesPanel; |
42 |
import org.gvsig.installer.swing.impl.execution.wizard.DownloadProgressWizardPage; |
43 |
import org.gvsig.installer.swing.impl.execution.wizard.AddBundlesWizardPage; |
44 |
import org.gvsig.installer.swing.impl.execution.wizard.InstallersWizardPage; |
45 |
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizardPage; |
46 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectBundlesWizardPage; |
47 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizardPage; |
48 |
import org.gvsig.installer.swing.impl.execution.wizard.TypicalOrAdvancedWizardPage; |
49 |
import org.gvsig.installer.swing.impl.wizard.AbstractInstallerWizardPanel; |
50 |
import org.gvsig.tools.ToolsLocator; |
51 |
import org.gvsig.tools.i18n.I18nManager; |
52 |
import org.slf4j.Logger; |
53 |
import org.slf4j.LoggerFactory; |
54 |
|
55 |
public class DefaultInstallWizardPanel |
56 |
extends
|
57 |
AbstractInstallerWizardPanel |
58 |
implements
|
59 |
InstallWizardPanel_ext { |
60 |
|
61 |
private static final Logger LOG = LoggerFactory.getLogger(DefaultInstallWizardPanel.class); |
62 |
|
63 |
private static final long serialVersionUID = 554068938842141497L; |
64 |
private static final int TYPICAL_MODE = 0; |
65 |
private static final int ADVANCED_MODE = 1; |
66 |
|
67 |
private int installationMode = ADVANCED_MODE; |
68 |
|
69 |
private boolean skipTypicalOrAdvancedWizardPage = false; |
70 |
private boolean skipSelectBundleWizardPage = false; |
71 |
|
72 |
private boolean selectDefaultPackages; |
73 |
|
74 |
private final I18nManager i18nManager; |
75 |
private PackageFilter packageFilter;
|
76 |
|
77 |
|
78 |
private InstallPackageService installerExecutionService = null; |
79 |
|
80 |
// Wizard pages
|
81 |
private SelectBundlesWizardPage selectInstallersWizard = null; |
82 |
private InstallersWizardPage installersWizard = null; |
83 |
private SelectPackagesWizardPage selectPluginsWizard = null; |
84 |
private ProgressWizardPage progressWizard = null; |
85 |
private DownloadProgressWizardPage downloadProgressWizard = null; |
86 |
private TypicalOrAdvancedWizardPage typicalOrAdvancedWizard = null; |
87 |
private AddBundlesWizardPage addBundlesWizard;
|
88 |
|
89 |
|
90 |
public DefaultInstallWizardPanel(File applicationFolder, |
91 |
File installFolder) {
|
92 |
super(applicationFolder, installFolder);
|
93 |
this.i18nManager = ToolsLocator.getI18nManager();
|
94 |
} |
95 |
|
96 |
@Override
|
97 |
public JComponent asJComponent() { |
98 |
if( needInitilization() ) {
|
99 |
initComponents(); |
100 |
} |
101 |
return this; |
102 |
} |
103 |
|
104 |
/**
|
105 |
* @return the installerExecutionService
|
106 |
*/
|
107 |
@Override
|
108 |
public InstallPackageService getInstallerExecutionService() {
|
109 |
if( needInitilization() ) {
|
110 |
initComponents(); |
111 |
} |
112 |
return installerExecutionService;
|
113 |
} |
114 |
|
115 |
private boolean needInitilization() { |
116 |
return selectPluginsWizard == null; |
117 |
} |
118 |
|
119 |
@Override
|
120 |
protected void initComponents() { |
121 |
if( needInitilization() ) {
|
122 |
try {
|
123 |
installerExecutionService = InstallerLocator.getInstallerManager() |
124 |
.getInstallPackageService(); |
125 |
} catch (InstallPackageServiceException ex) {
|
126 |
LOG.warn("Can't create the InstallerExecutionService.",ex);
|
127 |
throw new RuntimeException(ex); |
128 |
} |
129 |
List<UrlAndLabel> downloadURLs = SwingInstallerLocator
|
130 |
.getSwingInstallerManager().getDefaultDownloadUrlAndLabels(); |
131 |
selectInstallersWizard = new SelectBundlesWizardPage(this, downloadURLs); |
132 |
addBundlesWizard = new AddBundlesWizardPage(this); |
133 |
typicalOrAdvancedWizard = new TypicalOrAdvancedWizardPage(this); |
134 |
selectPluginsWizard = new SelectPackagesWizardPage(this); |
135 |
progressWizard = new ProgressWizardPage(this); |
136 |
downloadProgressWizard = new DownloadProgressWizardPage(this); |
137 |
installersWizard = new InstallersWizardPage(this); |
138 |
|
139 |
addWizards(); |
140 |
|
141 |
setFinishButtonEnabled(false);
|
142 |
|
143 |
this.setLayout(new BorderLayout()); |
144 |
super.initComponents();
|
145 |
} |
146 |
} |
147 |
|
148 |
private void addWizards() { |
149 |
this.addOptionPanel(typicalOrAdvancedWizard);
|
150 |
this.addOptionPanel(selectInstallersWizard);
|
151 |
this.addOptionPanel(addBundlesWizard);
|
152 |
this.addOptionPanel(installersWizard);
|
153 |
this.addOptionPanel(selectPluginsWizard);
|
154 |
this.addOptionPanel(downloadProgressWizard);
|
155 |
this.addOptionPanel(progressWizard);
|
156 |
} |
157 |
|
158 |
@Override
|
159 |
public SelectBundlesPanel getBundlesPanel() {
|
160 |
if( needInitilization() ) {
|
161 |
initComponents(); |
162 |
} |
163 |
return this.selectInstallersWizard; |
164 |
} |
165 |
|
166 |
@Override
|
167 |
public void installFromDefaultDirectory() |
168 |
throws InstallPackageServiceException {
|
169 |
if( needInitilization() ) {
|
170 |
initComponents(); |
171 |
} |
172 |
getWizardComponents().removeWizardPanel(0);
|
173 |
installerExecutionService.addBundlesFromDirectory(getInstallFolder(), null);
|
174 |
selectPluginsWizard.updatePanel(); |
175 |
} |
176 |
|
177 |
/**
|
178 |
* @return the installersToInstall
|
179 |
*/
|
180 |
@Override
|
181 |
public List<PackageInfo> getPackagesToInstall() { |
182 |
if( needInitilization() ) {
|
183 |
initComponents(); |
184 |
} |
185 |
return this.selectPluginsWizard.getPackagesToInstall(); |
186 |
} |
187 |
|
188 |
@Override
|
189 |
public void setSelectDefaultPackages(boolean isActivated) { |
190 |
this.selectDefaultPackages = isActivated;
|
191 |
} |
192 |
|
193 |
@Override
|
194 |
public boolean getSelectDefaultPackages() { |
195 |
return this.selectDefaultPackages; |
196 |
} |
197 |
|
198 |
@Override
|
199 |
public void setSkipSelectPackagesWizardPage(boolean skip) { |
200 |
if (skip) {
|
201 |
installationMode = TYPICAL_MODE; |
202 |
selectDefaultPackages = true;
|
203 |
} else {
|
204 |
installationMode = ADVANCED_MODE; |
205 |
} |
206 |
} |
207 |
|
208 |
@Override
|
209 |
public boolean getSkipSelectPackagesWizardPage() { |
210 |
return installationMode == TYPICAL_MODE;
|
211 |
} |
212 |
|
213 |
@Override
|
214 |
public boolean getSkipTypicalOrAdvancedWizardPage() { |
215 |
return skipTypicalOrAdvancedWizardPage;
|
216 |
} |
217 |
|
218 |
@Override
|
219 |
public void setSkipTypicalOrAdvancedWizardPage(boolean skip) { |
220 |
skipTypicalOrAdvancedWizardPage = skip; |
221 |
if (skip) {
|
222 |
this.installationMode = TYPICAL_MODE;
|
223 |
} |
224 |
} |
225 |
|
226 |
@Override
|
227 |
public void setSkipSelectBundleWizardPage(boolean skip) { |
228 |
this.skipSelectBundleWizardPage = skip;
|
229 |
} |
230 |
|
231 |
@Override
|
232 |
public boolean getSkipSelectBundleWizardPage() { |
233 |
if ( !getSkipTypicalOrAdvancedWizardPage() && installationMode == TYPICAL_MODE) {
|
234 |
return true; |
235 |
} |
236 |
return this.skipSelectBundleWizardPage; |
237 |
} |
238 |
|
239 |
@Override
|
240 |
public boolean needsToRestartApplicationAfterFinish() { |
241 |
// installers need to restart
|
242 |
return true; |
243 |
} |
244 |
|
245 |
@Override
|
246 |
public String getTranslation(String key) { |
247 |
return this.i18nManager.getTranslation(key); |
248 |
} |
249 |
|
250 |
@Override
|
251 |
public PackageFilter getPackageFilter() {
|
252 |
return this.packageFilter; |
253 |
} |
254 |
|
255 |
@Override
|
256 |
public void setPackageFilter(PackageFilter type) { |
257 |
this.packageFilter = type;
|
258 |
} |
259 |
} |