root / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / DefaultInstallPackageWizard.java @ 38608
History | View | Annotate | Download (6.68 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; |
29 |
|
30 |
import java.awt.BorderLayout; |
31 |
import java.io.File; |
32 |
import java.net.URL; |
33 |
import java.util.List; |
34 |
|
35 |
import jwizardcomponent.DefaultJWizardComponents; |
36 |
|
37 |
import org.gvsig.gui.beans.wizard.WizardPanel; |
38 |
import org.gvsig.gui.beans.wizard.WizardPanelActionListener; |
39 |
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo; |
40 |
import org.gvsig.installer.lib.api.InstallerLocator; |
41 |
import org.gvsig.installer.lib.api.PackageInfo; |
42 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
43 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
44 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
45 |
import org.gvsig.installer.swing.api.execution.AbstractInstallPackageWizard; |
46 |
import org.gvsig.installer.swing.impl.execution.wizard.DownloadProgressWizard; |
47 |
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizard; |
48 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectBundlesWizard; |
49 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizard; |
50 |
import org.gvsig.installer.swing.impl.execution.wizard.TypicalOrAdvancedWizard; |
51 |
import org.gvsig.installer.swing.impl.wizard.WizardListenerAdapter; |
52 |
|
53 |
/**
|
54 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
55 |
*/
|
56 |
public class DefaultInstallPackageWizard extends AbstractInstallPackageWizard |
57 |
implements WizardPanel {
|
58 |
|
59 |
private static final long serialVersionUID = 554068938842141497L; |
60 |
private static final int TYPICAL_MODE = 0; |
61 |
private static final int ADVANCED_MODE = 1; |
62 |
|
63 |
private int installationMode = ADVANCED_MODE; |
64 |
private boolean askInstallationMode = false; |
65 |
private boolean selectDefaultPackages; |
66 |
|
67 |
private WizardPanelWithLogo wizardPanelWithLogo = null; |
68 |
private InstallPackageService installerExecutionService = null; |
69 |
|
70 |
// Wizards
|
71 |
private SelectBundlesWizard selectInstallersWizard = null; |
72 |
private SelectPackagesWizard selectPluginsWizard = null; |
73 |
private ProgressWizard progressWizard = null; |
74 |
private DownloadProgressWizard downloadProgressWizard = null; |
75 |
private TypicalOrAdvancedWizard typicalOrAdvancedWizard = null; |
76 |
|
77 |
private WizardListenerAdapter wizardListenerAdapter = null; |
78 |
|
79 |
public DefaultInstallPackageWizard(File applicationFolder, |
80 |
File installFolder) throws InstallPackageServiceException { |
81 |
super(applicationFolder, installFolder);
|
82 |
|
83 |
installerExecutionService = InstallerLocator.getInstallerManager() |
84 |
.getInstallPackageService(); |
85 |
|
86 |
wizardPanelWithLogo = new WizardPanelWithLogo();
|
87 |
|
88 |
List<URL> downloadURLs = SwingInstallerLocator |
89 |
.getSwingInstallerManager().getDefaultDownloadURLs(); |
90 |
selectInstallersWizard = new SelectBundlesWizard(this, downloadURLs); |
91 |
typicalOrAdvancedWizard = new TypicalOrAdvancedWizard(this); |
92 |
selectPluginsWizard = new SelectPackagesWizard(this); |
93 |
progressWizard = new ProgressWizard(this); |
94 |
downloadProgressWizard = new DownloadProgressWizard(this); |
95 |
|
96 |
addWizards(); |
97 |
|
98 |
// Adding the listeners
|
99 |
wizardPanelWithLogo.setWizardListener(this);
|
100 |
|
101 |
setFinishButtonVisible(false);
|
102 |
|
103 |
this.setLayout(new BorderLayout()); |
104 |
this.add(wizardPanelWithLogo, BorderLayout.CENTER); |
105 |
} |
106 |
|
107 |
public void doAction(int action) { |
108 |
this.wizardPanelWithLogo.doAction(action);
|
109 |
} |
110 |
|
111 |
private void addWizards() { |
112 |
wizardPanelWithLogo.addOptionPanel(selectInstallersWizard); |
113 |
wizardPanelWithLogo.addOptionPanel(typicalOrAdvancedWizard); |
114 |
wizardPanelWithLogo.addOptionPanel(selectPluginsWizard); |
115 |
wizardPanelWithLogo.addOptionPanel(downloadProgressWizard); |
116 |
wizardPanelWithLogo.addOptionPanel(progressWizard); |
117 |
} |
118 |
|
119 |
public DefaultJWizardComponents getWizardComponents() {
|
120 |
return wizardPanelWithLogo.getWizardComponents();
|
121 |
} |
122 |
|
123 |
/**
|
124 |
* @return the installerExecutionService
|
125 |
*/
|
126 |
@Override
|
127 |
public InstallPackageService getInstallerExecutionService() {
|
128 |
return installerExecutionService;
|
129 |
} |
130 |
|
131 |
/**
|
132 |
* @return the installersToInstall
|
133 |
*/
|
134 |
@Override
|
135 |
public List<PackageInfo> getInstallersToInstall() { |
136 |
return this.selectPluginsWizard.getPackagesToInstall(); |
137 |
} |
138 |
|
139 |
@Override
|
140 |
public void setNextButtonEnabled(boolean isEnabled) { |
141 |
getWizardComponents().getNextButton().setEnabled(isEnabled); |
142 |
} |
143 |
|
144 |
@Override
|
145 |
public void setFinishButtonVisible(boolean isVisible) { |
146 |
getWizardComponents().getFinishButton().setEnabled(isVisible); |
147 |
} |
148 |
|
149 |
@Override
|
150 |
public void setCancelButtonEnabled(boolean isEnabled) { |
151 |
getWizardComponents().getCancelButton().setEnabled(isEnabled); |
152 |
} |
153 |
|
154 |
@Override
|
155 |
public void setBackButtonEnabled(boolean isEnabled) { |
156 |
getWizardComponents().getBackButton().setEnabled(isEnabled); |
157 |
} |
158 |
|
159 |
@Override
|
160 |
public void installFromDefaultDirectory() |
161 |
throws InstallPackageServiceException {
|
162 |
getWizardComponents().removeWizardPanel(0);
|
163 |
installerExecutionService.addBundlesFromDirectory(getInstallFolder()); |
164 |
selectPluginsWizard.updatePanel(); |
165 |
} |
166 |
|
167 |
public WizardPanelActionListener getWizardPanelActionListener() {
|
168 |
if (((wizardListenerAdapter == null) && (getWizardActionListener() != null))) { |
169 |
wizardListenerAdapter = new WizardListenerAdapter(this); |
170 |
} |
171 |
return wizardListenerAdapter;
|
172 |
} |
173 |
|
174 |
public void setWizardPanelActionListener( |
175 |
WizardPanelActionListener wizardActionListener) { |
176 |
// TODO Auto-generated method stub
|
177 |
} |
178 |
|
179 |
@Override
|
180 |
public void setSelectDefaultPackages(boolean isActivated) { |
181 |
this.selectDefaultPackages = isActivated;
|
182 |
} |
183 |
|
184 |
@Override
|
185 |
public boolean getSelectDefaultPackages() { |
186 |
return this.selectDefaultPackages; |
187 |
} |
188 |
|
189 |
public void setShowSelectPackagesPanel(boolean mode) { |
190 |
if (mode) {
|
191 |
installationMode = ADVANCED_MODE; |
192 |
} else {
|
193 |
installationMode = TYPICAL_MODE; |
194 |
selectDefaultPackages = true;
|
195 |
} |
196 |
} |
197 |
|
198 |
public boolean showSelectPackagesPanel() { |
199 |
return installationMode == ADVANCED_MODE;
|
200 |
} |
201 |
|
202 |
@Override
|
203 |
public boolean getAskTypicalOrCustom() { |
204 |
return askInstallationMode;
|
205 |
} |
206 |
|
207 |
@Override
|
208 |
public void setAskTypicalOrCustom(boolean b) { |
209 |
askInstallationMode = true;
|
210 |
} |
211 |
|
212 |
} |