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