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 @ 43126
History | View | Annotate | Download (7.62 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.gui.beans.wizard.WizardPanelWithLogo; |
35 |
import org.gvsig.installer.lib.api.InstallerLocator; |
36 |
import org.gvsig.installer.lib.api.PackageInfo; |
37 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
38 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
39 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
40 |
import org.gvsig.installer.swing.api.SwingInstallerManager.UrlAndLabel; |
41 |
import org.gvsig.installer.swing.api.execution.PackageFilter; |
42 |
import org.gvsig.installer.swing.impl.execution.panel.SelectBundlesPanel; |
43 |
import org.gvsig.installer.swing.impl.execution.wizard.DownloadProgressWizardPage; |
44 |
import org.gvsig.installer.swing.impl.execution.wizard.AddBundlesWizardPage; |
45 |
import org.gvsig.installer.swing.impl.execution.wizard.InstallersWizardPage; |
46 |
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizardPage; |
47 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectBundlesWizardPage; |
48 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizardPage; |
49 |
import org.gvsig.installer.swing.impl.execution.wizard.TypicalOrAdvancedWizardPage; |
50 |
import org.gvsig.installer.swing.impl.wizard.AbstractInstallerWizardPanel; |
51 |
import org.gvsig.tools.ToolsLocator; |
52 |
import org.gvsig.tools.i18n.I18nManager; |
53 |
|
54 |
public class DefaultInstallWizardPanel |
55 |
extends
|
56 |
AbstractInstallerWizardPanel |
57 |
implements
|
58 |
InstallWizardPanel_ext { |
59 |
|
60 |
private static final long serialVersionUID = 554068938842141497L; |
61 |
private static final int TYPICAL_MODE = 0; |
62 |
private static final int ADVANCED_MODE = 1; |
63 |
|
64 |
private int installationMode = ADVANCED_MODE; |
65 |
|
66 |
private boolean skipTypicalOrAdvancedWizardPage = false; |
67 |
private boolean skipSelectBundleWizardPage = false; |
68 |
|
69 |
private boolean selectDefaultPackages; |
70 |
|
71 |
private InstallPackageService installerExecutionService = null; |
72 |
|
73 |
// Wizard pages
|
74 |
private SelectBundlesWizardPage selectInstallersWizard = null; |
75 |
private InstallersWizardPage installersWizard = null; |
76 |
private SelectPackagesWizardPage selectPluginsWizard = null; |
77 |
private ProgressWizardPage progressWizard = null; |
78 |
private DownloadProgressWizardPage downloadProgressWizard = null; |
79 |
private TypicalOrAdvancedWizardPage typicalOrAdvancedWizard = null; |
80 |
private final AddBundlesWizardPage addBundlesWizard; |
81 |
|
82 |
private final I18nManager i18nManager; |
83 |
private PackageFilter packageFilter;
|
84 |
|
85 |
public DefaultInstallWizardPanel(File applicationFolder, |
86 |
File installFolder) throws InstallPackageServiceException { |
87 |
super(applicationFolder, installFolder);
|
88 |
|
89 |
installerExecutionService = InstallerLocator.getInstallerManager() |
90 |
.getInstallPackageService(); |
91 |
|
92 |
this.i18nManager = ToolsLocator.getI18nManager();
|
93 |
|
94 |
List<UrlAndLabel> downloadURLs = SwingInstallerLocator
|
95 |
.getSwingInstallerManager().getDefaultDownloadUrlAndLabels(); |
96 |
selectInstallersWizard = new SelectBundlesWizardPage(this, downloadURLs); |
97 |
addBundlesWizard = new AddBundlesWizardPage(this); |
98 |
typicalOrAdvancedWizard = new TypicalOrAdvancedWizardPage(this); |
99 |
selectPluginsWizard = new SelectPackagesWizardPage(this); |
100 |
progressWizard = new ProgressWizardPage(this); |
101 |
downloadProgressWizard = new DownloadProgressWizardPage(this); |
102 |
installersWizard = new InstallersWizardPage(this); |
103 |
|
104 |
addWizards(); |
105 |
|
106 |
setFinishButtonEnabled(false);
|
107 |
|
108 |
this.setLayout(new BorderLayout()); |
109 |
super.initComponents();
|
110 |
} |
111 |
|
112 |
@Override
|
113 |
public SelectBundlesPanel getBundlesPanel() {
|
114 |
return this.selectInstallersWizard; |
115 |
} |
116 |
|
117 |
private void addWizards() { |
118 |
this.addOptionPanel(typicalOrAdvancedWizard);
|
119 |
this.addOptionPanel(selectInstallersWizard);
|
120 |
this.addOptionPanel(addBundlesWizard);
|
121 |
this.addOptionPanel(installersWizard);
|
122 |
this.addOptionPanel(selectPluginsWizard);
|
123 |
this.addOptionPanel(downloadProgressWizard);
|
124 |
this.addOptionPanel(progressWizard);
|
125 |
} |
126 |
|
127 |
/**
|
128 |
* @return the installerExecutionService
|
129 |
*/
|
130 |
@Override
|
131 |
public InstallPackageService getInstallerExecutionService() {
|
132 |
return installerExecutionService;
|
133 |
} |
134 |
|
135 |
/**
|
136 |
* @return the installersToInstall
|
137 |
*/
|
138 |
@Override
|
139 |
public List<PackageInfo> getPackagesToInstall() { |
140 |
return this.selectPluginsWizard.getPackagesToInstall(); |
141 |
} |
142 |
|
143 |
@Override
|
144 |
public void installFromDefaultDirectory() |
145 |
throws InstallPackageServiceException {
|
146 |
getWizardComponents().removeWizardPanel(0);
|
147 |
installerExecutionService.addBundlesFromDirectory(getInstallFolder(), null);
|
148 |
selectPluginsWizard.updatePanel(); |
149 |
} |
150 |
|
151 |
@Override
|
152 |
public void setSelectDefaultPackages(boolean isActivated) { |
153 |
this.selectDefaultPackages = isActivated;
|
154 |
} |
155 |
|
156 |
@Override
|
157 |
public boolean getSelectDefaultPackages() { |
158 |
return this.selectDefaultPackages; |
159 |
} |
160 |
|
161 |
@Override
|
162 |
public void setSkipSelectPackagesWizardPage(boolean skip) { |
163 |
if (skip) {
|
164 |
installationMode = TYPICAL_MODE; |
165 |
selectDefaultPackages = true;
|
166 |
} else {
|
167 |
installationMode = ADVANCED_MODE; |
168 |
} |
169 |
} |
170 |
|
171 |
@Override
|
172 |
public boolean getSkipSelectPackagesWizardPage() { |
173 |
return installationMode == TYPICAL_MODE;
|
174 |
} |
175 |
|
176 |
@Override
|
177 |
public boolean getSkipTypicalOrAdvancedWizardPage() { |
178 |
return skipTypicalOrAdvancedWizardPage;
|
179 |
} |
180 |
|
181 |
@Override
|
182 |
public void setSkipTypicalOrAdvancedWizardPage(boolean skip) { |
183 |
skipTypicalOrAdvancedWizardPage = skip; |
184 |
if( skip ) {
|
185 |
this.installationMode = TYPICAL_MODE;
|
186 |
} |
187 |
} |
188 |
|
189 |
@Override
|
190 |
public void setSkipSelectBundleWizardPage(boolean skip) { |
191 |
this.skipSelectBundleWizardPage = skip;
|
192 |
} |
193 |
|
194 |
@Override
|
195 |
public boolean getSkipSelectBundleWizardPage() { |
196 |
if (installationMode == TYPICAL_MODE) {
|
197 |
return true; |
198 |
} |
199 |
return this.skipSelectBundleWizardPage; |
200 |
} |
201 |
|
202 |
@Override
|
203 |
public boolean needsToRestartApplicationAfterFinish() { |
204 |
// installers need to restart
|
205 |
return true; |
206 |
} |
207 |
|
208 |
@Override
|
209 |
public String getTranslation(String key) { |
210 |
return this.i18nManager.getTranslation(key); |
211 |
} |
212 |
|
213 |
@Override
|
214 |
public JComponent asJComponent() { |
215 |
return this; |
216 |
} |
217 |
|
218 |
@Override
|
219 |
public PackageFilter getPackageFilter() {
|
220 |
return this.packageFilter; |
221 |
} |
222 |
|
223 |
@Override
|
224 |
public void setPackageFilter(PackageFilter type) { |
225 |
this.packageFilter = type;
|
226 |
} |
227 |
} |