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 @ 32635
History | View | Annotate | Download (5.15 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.util.ArrayList; |
33 |
import java.util.List; |
34 |
|
35 |
import javax.swing.ImageIcon; |
36 |
|
37 |
import jwizardcomponent.DefaultJWizardComponents; |
38 |
|
39 |
import org.gvsig.installer.lib.api.InstallerLocator; |
40 |
import org.gvsig.installer.lib.api.PackageInfo; |
41 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
42 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
43 |
import org.gvsig.installer.swing.api.execution.InstallPackageWizard; |
44 |
import org.gvsig.installer.swing.impl.InstallerWizardContainer; |
45 |
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizard; |
46 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectBundlesWizard; |
47 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizard; |
48 |
import org.gvsig.installer.swing.impl.wizard.WizardPanelCancelAction; |
49 |
import org.gvsig.installer.swing.impl.wizard.WizardPanelFinishAction; |
50 |
import org.gvsig.installer.swing.impl.wizard.WizardPanelWithLogo; |
51 |
import org.slf4j.Logger; |
52 |
import org.slf4j.LoggerFactory; |
53 |
|
54 |
/**
|
55 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
56 |
*/
|
57 |
public class DefaultInstallPackageWizard extends InstallPackageWizard{ |
58 |
private WizardPanelWithLogo wizardPanelWithLogo = null; |
59 |
private InstallPackageService installerExecutionService = null; |
60 |
private static final Logger logger = LoggerFactory.getLogger(DefaultInstallPackageWizard.class); |
61 |
private List<PackageInfo> installersToInstall = null; |
62 |
|
63 |
//Wizards
|
64 |
private SelectBundlesWizard selectInstallersWizard = null; |
65 |
private SelectPackagesWizard selectPluginsWizard = null; |
66 |
private ProgressWizard progressWizard = null; |
67 |
|
68 |
public DefaultInstallPackageWizard(File applicationDirectory) throws InstallPackageServiceException |
69 |
{ |
70 |
super(applicationDirectory);
|
71 |
wizardPanelWithLogo = new WizardPanelWithLogo(new ImageIcon(getClass().getClassLoader().getResource("images/makepluginpackageicon.png").getFile())); |
72 |
|
73 |
selectInstallersWizard = new SelectBundlesWizard(this); |
74 |
selectPluginsWizard = new SelectPackagesWizard(this); |
75 |
progressWizard = new ProgressWizard(this); |
76 |
|
77 |
installersToInstall = new ArrayList<PackageInfo>(); |
78 |
|
79 |
addWizards(); |
80 |
|
81 |
//Adding the listeners
|
82 |
getWizardComponents().setFinishAction(new WizardPanelFinishAction(getWizardComponents(), this)); |
83 |
getWizardComponents().setCancelAction(new WizardPanelCancelAction(getWizardComponents(), this)); |
84 |
|
85 |
setFinishButtonVisible(false);
|
86 |
|
87 |
this.setLayout(new BorderLayout()); |
88 |
this.add(wizardPanelWithLogo, BorderLayout.CENTER); |
89 |
|
90 |
installerExecutionService = |
91 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
92 |
} |
93 |
|
94 |
private void addWizards(){ |
95 |
getWizardComponents().addWizardPanel( |
96 |
new InstallerWizardContainer(getWizardComponents(),
|
97 |
selectInstallersWizard)); |
98 |
|
99 |
getWizardComponents().addWizardPanel( |
100 |
new InstallerWizardContainer(getWizardComponents(),
|
101 |
selectPluginsWizard)); |
102 |
getWizardComponents().addWizardPanel( |
103 |
new InstallerWizardContainer(getWizardComponents(),
|
104 |
progressWizard)); |
105 |
} |
106 |
|
107 |
public DefaultJWizardComponents getWizardComponents()
|
108 |
{ |
109 |
return wizardPanelWithLogo.getWizardComponents();
|
110 |
} |
111 |
|
112 |
/**
|
113 |
* @return the installerExecutionService
|
114 |
*/
|
115 |
public InstallPackageService getInstallerExecutionService() {
|
116 |
return installerExecutionService;
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* @return the installersToInstall
|
121 |
*/
|
122 |
public List<PackageInfo> getInstallersToInstall() { |
123 |
return installersToInstall;
|
124 |
} |
125 |
|
126 |
public void setNextButtonEnabled(boolean isEnabled){ |
127 |
getWizardComponents().getNextButton().setEnabled(isEnabled); |
128 |
} |
129 |
|
130 |
public void setFinishButtonVisible(boolean isVisible){ |
131 |
getWizardComponents().getFinishButton().setEnabled(isVisible); |
132 |
} |
133 |
|
134 |
public void setCancelButtonEnabled(boolean isEnabled){ |
135 |
getWizardComponents().getCancelButton().setEnabled(isEnabled); |
136 |
} |
137 |
|
138 |
@Override
|
139 |
public void installFromDefaultDirectory() throws InstallPackageServiceException { |
140 |
getWizardComponents().removeWizardPanel(0);
|
141 |
installerExecutionService.addBundlesFromDirectory(getDefaultInstallersDirectory()); |
142 |
selectPluginsWizard.updatePanel(); |
143 |
} |
144 |
|
145 |
public File getDefaultInstallersDirectory() |
146 |
{ |
147 |
return new File(applicationDirectory.getAbsolutePath() + File.separator + "install"); |
148 |
} |
149 |
} |