svn-gvsig-desktop / 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 @ 35189
History | View | Annotate | Download (7.32 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 javax.swing.ImageIcon; |
36 |
|
37 |
import jwizardcomponent.DefaultJWizardComponents; |
38 |
|
39 |
import org.gvsig.gui.beans.wizard.WizardPanel; |
40 |
import org.gvsig.gui.beans.wizard.WizardPanelActionListener; |
41 |
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo; |
42 |
import org.gvsig.installer.lib.api.InstallerLocator; |
43 |
import org.gvsig.installer.lib.api.PackageInfo; |
44 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
45 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
46 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
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 pluginsFolder, File installFolder) |
83 |
throws InstallPackageServiceException {
|
84 |
super(applicationFolder, pluginsFolder, installFolder);
|
85 |
|
86 |
installerExecutionService = |
87 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
88 |
|
89 |
URL iconURL =
|
90 |
getClass().getClassLoader().getResource( |
91 |
"images/installpackageicon.png");
|
92 |
ImageIcon icon = new ImageIcon(iconURL); |
93 |
wizardPanelWithLogo = new WizardPanelWithLogo(icon);
|
94 |
|
95 |
URL downloadURL =
|
96 |
SwingInstallerLocator.getSwingInstallerManager() |
97 |
.getDefaultDownloadURL(); |
98 |
selectInstallersWizard = new SelectBundlesWizard(this, downloadURL); |
99 |
typicalOrAdvancedWizard = new TypicalOrAdvancedWizard(this); |
100 |
selectPluginsWizard = new SelectPackagesWizard(this); |
101 |
progressWizard = new ProgressWizard(this); |
102 |
downloadProgressWizard = new DownloadProgressWizard(this); |
103 |
|
104 |
addWizards(); |
105 |
|
106 |
// Adding the listeners
|
107 |
wizardPanelWithLogo.setWizardListener(this);
|
108 |
|
109 |
setFinishButtonVisible(false);
|
110 |
|
111 |
this.setLayout(new BorderLayout()); |
112 |
this.add(wizardPanelWithLogo, BorderLayout.CENTER); |
113 |
} |
114 |
|
115 |
public void doAction(int action) { |
116 |
this.wizardPanelWithLogo.doAction(action);
|
117 |
} |
118 |
|
119 |
private void addWizards() { |
120 |
wizardPanelWithLogo.addOptionPanel(selectInstallersWizard); |
121 |
wizardPanelWithLogo.addOptionPanel(typicalOrAdvancedWizard); |
122 |
wizardPanelWithLogo.addOptionPanel(selectPluginsWizard); |
123 |
wizardPanelWithLogo.addOptionPanel(downloadProgressWizard); |
124 |
wizardPanelWithLogo.addOptionPanel(progressWizard); |
125 |
} |
126 |
|
127 |
public DefaultJWizardComponents getWizardComponents() {
|
128 |
return wizardPanelWithLogo.getWizardComponents();
|
129 |
} |
130 |
|
131 |
/**
|
132 |
* @return the installerExecutionService
|
133 |
*/
|
134 |
public InstallPackageService getInstallerExecutionService() {
|
135 |
return installerExecutionService;
|
136 |
} |
137 |
|
138 |
/**
|
139 |
* @return the installersToInstall
|
140 |
*/
|
141 |
public List<PackageInfo> getInstallersToInstall() { |
142 |
return this.selectPluginsWizard.getPackagesToInstall(); |
143 |
} |
144 |
|
145 |
public void setNextButtonEnabled(boolean isEnabled) { |
146 |
getWizardComponents().getNextButton().setEnabled(isEnabled); |
147 |
} |
148 |
|
149 |
public void setFinishButtonVisible(boolean isVisible) { |
150 |
getWizardComponents().getFinishButton().setEnabled(isVisible); |
151 |
} |
152 |
|
153 |
public void setCancelButtonEnabled(boolean isEnabled) { |
154 |
getWizardComponents().getCancelButton().setEnabled(isEnabled); |
155 |
} |
156 |
|
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 |
public void setSelectDefaultPackages(boolean isActivated) { |
182 |
this.selectDefaultPackages = isActivated;
|
183 |
} |
184 |
|
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 |
public boolean getAskTypicalOrCustom() { |
203 |
return askInstallationMode;
|
204 |
} |
205 |
|
206 |
public void setAskTypicalOrCustom(boolean b) { |
207 |
askInstallationMode = true;
|
208 |
} |
209 |
|
210 |
} |