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 / DefaultInstallerExecutionWizard.java @ 32401
History | View | Annotate | Download (4.81 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.BufferedInputStream; |
32 |
import java.io.File; |
33 |
import java.io.InputStream; |
34 |
import java.util.ArrayList; |
35 |
import java.util.List; |
36 |
|
37 |
import javax.swing.ImageIcon; |
38 |
|
39 |
import jwizardcomponent.DefaultJWizardComponents; |
40 |
|
41 |
import org.gvsig.installer.lib.api.InstallerInfo; |
42 |
import org.gvsig.installer.lib.api.InstallerLocator; |
43 |
import org.gvsig.installer.lib.api.execution.InstallerExecutionService; |
44 |
import org.gvsig.installer.lib.api.execution.InstallerExecutionServiceException; |
45 |
import org.gvsig.installer.swing.api.execution.InstallerExecutionWizard; |
46 |
import org.gvsig.installer.swing.impl.InstallerWizardContainer; |
47 |
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizard; |
48 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectInstallersWizard; |
49 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectPluginsWizard; |
50 |
import org.gvsig.installer.swing.impl.wizard.WizardPanelWithLogo; |
51 |
import org.gvsig.tools.locator.LocatorException; |
52 |
import org.slf4j.Logger; |
53 |
import org.slf4j.LoggerFactory; |
54 |
|
55 |
/**
|
56 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
57 |
*/
|
58 |
public class DefaultInstallerExecutionWizard extends InstallerExecutionWizard{ |
59 |
private WizardPanelWithLogo wizardPanelWithLogo = null; |
60 |
private InstallerExecutionService installerExecutionService = null; |
61 |
private File applicationDirectory = null; |
62 |
private static final Logger logger = LoggerFactory.getLogger(DefaultInstallerExecutionWizard.class); |
63 |
private List<InstallerInfo> installersToInstall = null; |
64 |
|
65 |
//Wizards
|
66 |
private SelectInstallersWizard selectInstallersWizard = null; |
67 |
private SelectPluginsWizard selectPluginsWizard = null; |
68 |
private ProgressWizard progressWizard = null; |
69 |
|
70 |
public DefaultInstallerExecutionWizard()
|
71 |
{ |
72 |
wizardPanelWithLogo = new WizardPanelWithLogo(new ImageIcon(getClass().getClassLoader().getResource("images/createplugininstallicon.png").getFile())); |
73 |
|
74 |
selectInstallersWizard = new SelectInstallersWizard(this); |
75 |
selectPluginsWizard = new SelectPluginsWizard(this); |
76 |
progressWizard = new ProgressWizard(this); |
77 |
|
78 |
installersToInstall = new ArrayList<InstallerInfo>(); |
79 |
|
80 |
addWizards(); |
81 |
|
82 |
this.setLayout(new BorderLayout()); |
83 |
this.add(wizardPanelWithLogo, BorderLayout.CENTER); |
84 |
} |
85 |
|
86 |
private void addWizards(){ |
87 |
getWizardComponents().addWizardPanel( |
88 |
new InstallerWizardContainer(getWizardComponents(),
|
89 |
selectInstallersWizard)); |
90 |
getWizardComponents().addWizardPanel( |
91 |
new InstallerWizardContainer(getWizardComponents(),
|
92 |
selectPluginsWizard)); |
93 |
getWizardComponents().addWizardPanel( |
94 |
new InstallerWizardContainer(getWizardComponents(),
|
95 |
progressWizard)); |
96 |
} |
97 |
|
98 |
public DefaultJWizardComponents getWizardComponents()
|
99 |
{ |
100 |
return wizardPanelWithLogo.getWizardComponents();
|
101 |
} |
102 |
|
103 |
private void checkInstallerExceutionService() throws InstallerExecutionServiceException{ |
104 |
if (installerExecutionService == null){ |
105 |
try {
|
106 |
installerExecutionService = |
107 |
InstallerLocator.getInstallerManager().getInstallerExecutionService(); |
108 |
} catch (LocatorException e) {
|
109 |
throw new InstallerExecutionServiceException("Error getting the execution service", e); |
110 |
} |
111 |
} |
112 |
} |
113 |
|
114 |
@Override
|
115 |
public void setInstaller(InputStream inputStream) throws InstallerExecutionServiceException { |
116 |
checkInstallerExceutionService(); |
117 |
installerExecutionService.addInstaller(inputStream); |
118 |
} |
119 |
|
120 |
@Override
|
121 |
public void setApplicationDirectory(File applicationDirectory) throws InstallerExecutionServiceException { |
122 |
checkInstallerExceutionService(); |
123 |
installerExecutionService.setApplicationDirectory(applicationDirectory); |
124 |
} |
125 |
|
126 |
/**
|
127 |
* @return the installerExecutionService
|
128 |
*/
|
129 |
public InstallerExecutionService getInstallerExecutionService() {
|
130 |
return installerExecutionService;
|
131 |
} |
132 |
|
133 |
|
134 |
/**
|
135 |
* @return the installersToInstall
|
136 |
*/
|
137 |
public List<InstallerInfo> getInstallersToInstall() { |
138 |
return installersToInstall;
|
139 |
} |
140 |
} |