Statistics
| Revision:

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 @ 32632

History | View | Annotate | Download (5.16 KB)

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