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 / DefaultInstallerExecutionWizard.java @ 32517

History | View | Annotate | Download (4.95 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.io.InputStream;
33
import java.util.ArrayList;
34
import java.util.List;
35

    
36
import javax.swing.ImageIcon;
37

    
38
import jwizardcomponent.DefaultJWizardComponents;
39

    
40
import org.gvsig.installer.lib.api.InstallerInfo;
41
import org.gvsig.installer.lib.api.InstallerLocator;
42
import org.gvsig.installer.lib.api.execution.InstallerExecutionService;
43
import org.gvsig.installer.lib.api.execution.InstallerExecutionServiceException;
44
import org.gvsig.installer.swing.api.execution.InstallerExecutionWizard;
45
import org.gvsig.installer.swing.impl.InstallerWizardContainer;
46
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizard;
47
import org.gvsig.installer.swing.impl.execution.wizard.SelectInstallersWizard;
48
import org.gvsig.installer.swing.impl.execution.wizard.SelectPluginsWizard;
49
import org.gvsig.installer.swing.impl.wizard.WizardPanelWithLogo;
50
import org.gvsig.tools.locator.LocatorException;
51
import org.slf4j.Logger;
52
import org.slf4j.LoggerFactory;
53

    
54
/**
55
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
56
 */
57
public class DefaultInstallerExecutionWizard extends InstallerExecutionWizard{
58
        private WizardPanelWithLogo wizardPanelWithLogo = null;
59
        private InstallerExecutionService installerExecutionService = null;
60
        private File applicationDirectory = null;
61
        private static final Logger logger = LoggerFactory.getLogger(DefaultInstallerExecutionWizard.class);
62
        private List<InstallerInfo> installersToInstall = null;        
63
                
64
        //Wizards
65
        private SelectInstallersWizard selectInstallersWizard = null;
66
        private SelectPluginsWizard selectPluginsWizard = null;
67
        private ProgressWizard progressWizard = null;
68
        
69
        public DefaultInstallerExecutionWizard()
70
        {
71
                wizardPanelWithLogo = new WizardPanelWithLogo(new ImageIcon(getClass().getClassLoader().getResource("images/createplugininstallicon.png").getFile()));                
72
                
73
                selectInstallersWizard = new SelectInstallersWizard(this);
74
                selectPluginsWizard = new SelectPluginsWizard(this);
75
                progressWizard = new ProgressWizard(this);
76
                
77
                installersToInstall = new ArrayList<InstallerInfo>();
78
                
79
                addWizards();
80

    
81
                this.setLayout(new BorderLayout());
82
                this.add(wizardPanelWithLogo, BorderLayout.CENTER);
83
        }
84
        
85
        private void addWizards(){
86
                getWizardComponents().addWizardPanel(
87
                                new InstallerWizardContainer(getWizardComponents(), 
88
                                        selectInstallersWizard));
89
                
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 setApplicationDirectory(File applicationDirectory) throws InstallerExecutionServiceException {
116
                checkInstallerExceutionService();
117
                installerExecutionService.setApplicationDirectory(applicationDirectory);
118
        }        
119
        
120
        /**
121
         * @return the installerExecutionService
122
         */
123
        public InstallerExecutionService getInstallerExecutionService() {
124
                return installerExecutionService;
125
        }
126
        
127
        
128
        /**
129
         * @return the installersToInstall
130
         */
131
        public List<InstallerInfo> getInstallersToInstall() {
132
                return installersToInstall;
133
        }
134
        
135
        public void setNextButtonEnabled(boolean isEnabled){
136
                getWizardComponents().getNextButton().setEnabled(isEnabled);
137
        }
138

    
139
        @Override
140
        public void installFromDefaultDirectory() throws InstallerExecutionServiceException {
141
                getWizardComponents().removeWizardPanel(0);
142
                installerExecutionService.addInstallersFromInstallDirectory();
143
                selectPluginsWizard.updatePanel();
144
        }
145
}