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 @ 33260
History | View | Annotate | Download (5.21 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.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.execution.InstallPackageWizard; |
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.wizard.WizardListenerAdapter; |
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 implements WizardPanel{ |
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 |
private WizardListenerAdapter wizardListenerAdapter = null; |
69 |
|
70 |
public DefaultInstallPackageWizard(File applicationDirectory) throws InstallPackageServiceException |
71 |
{ |
72 |
super(applicationDirectory);
|
73 |
wizardPanelWithLogo = new WizardPanelWithLogo(new ImageIcon(getClass().getClassLoader().getResource("images/makepluginpackageicon.png").getFile())); |
74 |
|
75 |
selectInstallersWizard = new SelectBundlesWizard(this); |
76 |
selectPluginsWizard = new SelectPackagesWizard(this); |
77 |
progressWizard = new ProgressWizard(this); |
78 |
|
79 |
installersToInstall = new ArrayList<PackageInfo>(); |
80 |
|
81 |
addWizards(); |
82 |
|
83 |
//Adding the listeners
|
84 |
wizardPanelWithLogo.setWizardListener(this);
|
85 |
|
86 |
setFinishButtonVisible(false);
|
87 |
|
88 |
this.setLayout(new BorderLayout()); |
89 |
this.add(wizardPanelWithLogo, BorderLayout.CENTER); |
90 |
|
91 |
installerExecutionService = |
92 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
93 |
} |
94 |
|
95 |
private void addWizards(){ |
96 |
wizardPanelWithLogo.addOptionPanel(selectInstallersWizard); |
97 |
wizardPanelWithLogo.addOptionPanel(selectPluginsWizard); |
98 |
wizardPanelWithLogo.addOptionPanel(progressWizard); |
99 |
} |
100 |
|
101 |
public DefaultJWizardComponents getWizardComponents()
|
102 |
{ |
103 |
return wizardPanelWithLogo.getWizardComponents();
|
104 |
} |
105 |
|
106 |
/**
|
107 |
* @return the installerExecutionService
|
108 |
*/
|
109 |
public InstallPackageService getInstallerExecutionService() {
|
110 |
return installerExecutionService;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* @return the installersToInstall
|
115 |
*/
|
116 |
public List<PackageInfo> getInstallersToInstall() { |
117 |
return installersToInstall;
|
118 |
} |
119 |
|
120 |
public void setNextButtonEnabled(boolean isEnabled){ |
121 |
getWizardComponents().getNextButton().setEnabled(isEnabled); |
122 |
} |
123 |
|
124 |
public void setFinishButtonVisible(boolean isVisible){ |
125 |
getWizardComponents().getFinishButton().setEnabled(isVisible); |
126 |
} |
127 |
|
128 |
public void setCancelButtonEnabled(boolean isEnabled){ |
129 |
getWizardComponents().getCancelButton().setEnabled(isEnabled); |
130 |
} |
131 |
|
132 |
@Override
|
133 |
public void installFromDefaultDirectory() throws InstallPackageServiceException { |
134 |
getWizardComponents().removeWizardPanel(0);
|
135 |
installerExecutionService.addBundlesFromDirectory(getDefaultInstallersDirectory()); |
136 |
selectPluginsWizard.updatePanel(); |
137 |
} |
138 |
|
139 |
public File getDefaultInstallersDirectory() |
140 |
{ |
141 |
return new File(applicationDirectory.getAbsolutePath() + File.separator + "install"); |
142 |
} |
143 |
|
144 |
public WizardPanelActionListener getWizardPanelActionListener() {
|
145 |
if ((wizardListenerAdapter == null && (getWizardActionListener() != null))){ |
146 |
return new WizardListenerAdapter(this); |
147 |
} |
148 |
return wizardListenerAdapter;
|
149 |
} |
150 |
|
151 |
public void setWizardPanelActionListener( |
152 |
WizardPanelActionListener wizardActionListener) { |
153 |
// TODO Auto-generated method stub
|
154 |
|
155 |
} |
156 |
} |