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

History | View | Annotate | Download (7.04 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.net.URL;
33
import java.util.List;
34

    
35
import jwizardcomponent.DefaultJWizardComponents;
36

    
37
import org.gvsig.gui.beans.wizard.WizardPanel;
38
import org.gvsig.gui.beans.wizard.WizardPanelActionListener;
39
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo;
40
import org.gvsig.installer.lib.api.InstallerLocator;
41
import org.gvsig.installer.lib.api.PackageInfo;
42
import org.gvsig.installer.lib.api.execution.InstallPackageService;
43
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
44
import org.gvsig.installer.swing.api.SwingInstallerLocator;
45
import org.gvsig.installer.swing.api.execution.AbstractInstallPackageWizard;
46
import org.gvsig.installer.swing.impl.execution.wizard.DownloadProgressWizard;
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.execution.wizard.TypicalOrAdvancedWizard;
51
import org.gvsig.installer.swing.impl.wizard.WizardListenerAdapter;
52

    
53
/**
54
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
55
 */
56
public class DefaultInstallPackageWizard extends AbstractInstallPackageWizard
57
                implements WizardPanel {
58

    
59
        private static final long serialVersionUID = 554068938842141497L;
60
        private static final int TYPICAL_MODE = 0;
61
        private static final int ADVANCED_MODE = 1;
62

    
63
        private int installationMode = ADVANCED_MODE;
64
        private boolean askInstallationMode = false;
65
        private boolean selectDefaultPackages;
66

    
67
        private WizardPanelWithLogo wizardPanelWithLogo = null;
68
        private InstallPackageService installerExecutionService = null;
69

    
70
        // Wizards
71
        private SelectBundlesWizard selectInstallersWizard = null;
72
        private SelectPackagesWizard selectPluginsWizard = null;
73
        // private SelectPackagesWizard selectPluginsWizard = null;
74
        private ProgressWizard progressWizard = null;
75
        private DownloadProgressWizard downloadProgressWizard = null;
76
        private TypicalOrAdvancedWizard typicalOrAdvancedWizard = null;
77

    
78
        private WizardListenerAdapter wizardListenerAdapter = null;
79

    
80
        public DefaultInstallPackageWizard(File applicationFolder,
81
                        File pluginsFolder, File installFolder)
82
                        throws InstallPackageServiceException {
83
                super(applicationFolder, pluginsFolder, installFolder);
84

    
85
                installerExecutionService = InstallerLocator.getInstallerManager()
86
                                .getInstallPackageService();
87

    
88
                // URL iconURL =
89
                // getClass().getClassLoader().getResource(
90
                // "images/installpackageicon.png");
91
                // ImageIcon icon = new ImageIcon(iconURL);
92
                // wizardPanelWithLogo = new WizardPanelWithLogo(icon);
93
                wizardPanelWithLogo = new WizardPanelWithLogo();
94

    
95
                List<URL> downloadURLs = SwingInstallerLocator
96
                                .getSwingInstallerManager().getDefaultDownloadURLs();
97
                selectInstallersWizard = new SelectBundlesWizard(this, downloadURLs);
98
                typicalOrAdvancedWizard = new TypicalOrAdvancedWizard(this);
99
                // selectPluginsWizard = new SelectPackagesWizard(this);
100
                selectPluginsWizard = new SelectPackagesWizard(this);
101
                progressWizard = new ProgressWizard(this);
102
                downloadProgressWizard = new DownloadProgressWizard(this);
103

    
104
                addWizards();
105

    
106
                // Adding the listeners
107
                wizardPanelWithLogo.setWizardListener(this);
108

    
109
                setFinishButtonVisible(false);
110

    
111
                this.setLayout(new BorderLayout());
112
                this.add(wizardPanelWithLogo, BorderLayout.CENTER);
113
        }
114

    
115
        public void doAction(int action) {
116
                this.wizardPanelWithLogo.doAction(action);
117
        }
118

    
119
        private void addWizards() {
120
                wizardPanelWithLogo.addOptionPanel(selectInstallersWizard);
121
                wizardPanelWithLogo.addOptionPanel(typicalOrAdvancedWizard);
122
                wizardPanelWithLogo.addOptionPanel(selectPluginsWizard);
123
                wizardPanelWithLogo.addOptionPanel(downloadProgressWizard);
124
                wizardPanelWithLogo.addOptionPanel(progressWizard);
125
        }
126

    
127
        public DefaultJWizardComponents getWizardComponents() {
128
                return wizardPanelWithLogo.getWizardComponents();
129
        }
130

    
131
        /**
132
         * @return the installerExecutionService
133
         */
134
        @Override
135
        public InstallPackageService getInstallerExecutionService() {
136
                return installerExecutionService;
137
        }
138

    
139
        /**
140
         * @return the installersToInstall
141
         */
142
        @Override
143
        public List<PackageInfo> getInstallersToInstall() {
144
                return this.selectPluginsWizard.getPackagesToInstall();
145
        }
146

    
147
        @Override
148
        public void setNextButtonEnabled(boolean isEnabled) {
149
                getWizardComponents().getNextButton().setEnabled(isEnabled);
150
        }
151

    
152
        @Override
153
        public void setFinishButtonVisible(boolean isVisible) {
154
                getWizardComponents().getFinishButton().setEnabled(isVisible);
155
        }
156

    
157
        @Override
158
        public void setCancelButtonEnabled(boolean isEnabled) {
159
                getWizardComponents().getCancelButton().setEnabled(isEnabled);
160
        }
161

    
162
        @Override
163
        public void setBackButtonEnabled(boolean isEnabled) {
164
                getWizardComponents().getBackButton().setEnabled(isEnabled);
165
        }
166

    
167
        @Override
168
        public void installFromDefaultDirectory()
169
                        throws InstallPackageServiceException {
170
                getWizardComponents().removeWizardPanel(0);
171
                installerExecutionService.addBundlesFromDirectory(getInstallFolder());
172
                selectPluginsWizard.updatePanel();
173
        }
174

    
175
        public WizardPanelActionListener getWizardPanelActionListener() {
176
                if (((wizardListenerAdapter == null) && (getWizardActionListener() != null))) {
177
                        wizardListenerAdapter = new WizardListenerAdapter(this);
178
                }
179
                return wizardListenerAdapter;
180
        }
181

    
182
        public void setWizardPanelActionListener(
183
                        WizardPanelActionListener wizardActionListener) {
184
                // TODO Auto-generated method stub
185
        }
186

    
187
        @Override
188
        public void setSelectDefaultPackages(boolean isActivated) {
189
                this.selectDefaultPackages = isActivated;
190
        }
191

    
192
        @Override
193
        public boolean getSelectDefaultPackages() {
194
                return this.selectDefaultPackages;
195
        }
196

    
197
        public void setShowSelectPackagesPanel(boolean mode) {
198
                if (mode) {
199
                        installationMode = ADVANCED_MODE;
200
                } else {
201
                        installationMode = TYPICAL_MODE;
202
                        selectDefaultPackages = true;
203
                }
204
        }
205

    
206
        public boolean showSelectPackagesPanel() {
207
                return installationMode == ADVANCED_MODE;
208
        }
209

    
210
        @Override
211
        public boolean getAskTypicalOrCustom() {
212
                return askInstallationMode;
213
        }
214

    
215
        @Override
216
        public void setAskTypicalOrCustom(boolean b) {
217
                askInstallationMode = true;
218
        }
219

    
220
}