Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / DefaultInstallPackageWizard.java @ 40560

History | View | Annotate | Download (6.72 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2010 {Prodevelop}   {Task}
27
 */
28

    
29
package org.gvsig.installer.swing.impl.execution;
30

    
31
import java.awt.BorderLayout;
32
import java.io.File;
33
import java.net.URL;
34
import java.util.List;
35

    
36
import jwizardcomponent.DefaultJWizardComponents;
37

    
38
import org.gvsig.gui.beans.wizard.WizardPanel;
39
import org.gvsig.gui.beans.wizard.WizardPanelActionListener;
40
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo;
41
import org.gvsig.installer.lib.api.InstallerLocator;
42
import org.gvsig.installer.lib.api.PackageInfo;
43
import org.gvsig.installer.lib.api.execution.InstallPackageService;
44
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
45
import org.gvsig.installer.swing.api.SwingInstallerLocator;
46
import org.gvsig.installer.swing.api.execution.AbstractInstallPackageWizard;
47
import org.gvsig.installer.swing.impl.execution.wizard.DownloadProgressWizard;
48
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizard;
49
import org.gvsig.installer.swing.impl.execution.wizard.SelectBundlesWizard;
50
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizard;
51
import org.gvsig.installer.swing.impl.execution.wizard.TypicalOrAdvancedWizard;
52
import org.gvsig.installer.swing.impl.wizard.WizardListenerAdapter;
53

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

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

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

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

    
71
        // Wizards
72
        private SelectBundlesWizard selectInstallersWizard = 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 installFolder) throws InstallPackageServiceException {
82
                super(applicationFolder, installFolder);
83

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

    
87
                wizardPanelWithLogo = new WizardPanelWithLogo();
88

    
89
                List<URL> downloadURLs = SwingInstallerLocator
90
                                .getSwingInstallerManager().getDefaultDownloadURLs();
91
                selectInstallersWizard = new SelectBundlesWizard(this, downloadURLs);
92
                typicalOrAdvancedWizard = new TypicalOrAdvancedWizard(this);
93
                selectPluginsWizard = new SelectPackagesWizard(this);
94
                progressWizard = new ProgressWizard(this);
95
                downloadProgressWizard = new DownloadProgressWizard(this);
96

    
97
                addWizards();
98

    
99
                // Adding the listeners
100
                wizardPanelWithLogo.setWizardListener(this);
101

    
102
                setFinishButtonVisible(false);
103

    
104
                this.setLayout(new BorderLayout());
105
                this.add(wizardPanelWithLogo, BorderLayout.CENTER);
106
        }
107

    
108
        public void doAction(int action) {
109
                this.wizardPanelWithLogo.doAction(action);
110
        }
111

    
112
        private void addWizards() {
113
                wizardPanelWithLogo.addOptionPanel(selectInstallersWizard);
114
                wizardPanelWithLogo.addOptionPanel(typicalOrAdvancedWizard);
115
                wizardPanelWithLogo.addOptionPanel(selectPluginsWizard);
116
                wizardPanelWithLogo.addOptionPanel(downloadProgressWizard);
117
                wizardPanelWithLogo.addOptionPanel(progressWizard);
118
        }
119

    
120
        public DefaultJWizardComponents getWizardComponents() {
121
                return wizardPanelWithLogo.getWizardComponents();
122
        }
123

    
124
        /**
125
         * @return the installerExecutionService
126
         */
127
        @Override
128
        public InstallPackageService getInstallerExecutionService() {
129
                return installerExecutionService;
130
        }
131

    
132
        /**
133
         * @return the installersToInstall
134
         */
135
        @Override
136
        public List<PackageInfo> getInstallersToInstall() {
137
                return this.selectPluginsWizard.getPackagesToInstall();
138
        }
139

    
140
        @Override
141
        public void setNextButtonEnabled(boolean isEnabled) {
142
                getWizardComponents().getNextButton().setEnabled(isEnabled);
143
        }
144

    
145
        @Override
146
        public void setFinishButtonVisible(boolean isVisible) {
147
                getWizardComponents().getFinishButton().setEnabled(isVisible);
148
        }
149

    
150
        @Override
151
        public void setCancelButtonEnabled(boolean isEnabled) {
152
                getWizardComponents().getCancelButton().setEnabled(isEnabled);
153
        }
154

    
155
        @Override
156
        public void setBackButtonEnabled(boolean isEnabled) {
157
                getWizardComponents().getBackButton().setEnabled(isEnabled);
158
        }
159

    
160
        @Override
161
        public void installFromDefaultDirectory()
162
                        throws InstallPackageServiceException {
163
                getWizardComponents().removeWizardPanel(0);
164
                installerExecutionService.addBundlesFromDirectory(getInstallFolder());
165
                selectPluginsWizard.updatePanel();
166
        }
167

    
168
        public WizardPanelActionListener getWizardPanelActionListener() {
169
                if (((wizardListenerAdapter == null) && (getWizardActionListener() != null))) {
170
                        wizardListenerAdapter = new WizardListenerAdapter(this);
171
                }
172
                return wizardListenerAdapter;
173
        }
174

    
175
        public void setWizardPanelActionListener(
176
                        WizardPanelActionListener wizardActionListener) {
177
                // TODO Auto-generated method stub
178
        }
179

    
180
        @Override
181
        public void setSelectDefaultPackages(boolean isActivated) {
182
                this.selectDefaultPackages = isActivated;
183
        }
184

    
185
        @Override
186
        public boolean getSelectDefaultPackages() {
187
                return this.selectDefaultPackages;
188
        }
189

    
190
        public void setShowSelectPackagesPanel(boolean mode) {
191
                if (mode) {
192
                        installationMode = ADVANCED_MODE;
193
                } else {
194
                        installationMode = TYPICAL_MODE;
195
                        selectDefaultPackages = true;
196
                }
197
        }
198

    
199
        public boolean showSelectPackagesPanel() {
200
                return installationMode == ADVANCED_MODE;
201
        }
202

    
203
        @Override
204
        public boolean getAskTypicalOrCustom() {
205
                return askInstallationMode;
206
        }
207

    
208
        @Override
209
        public void setAskTypicalOrCustom(boolean b) {
210
                askInstallationMode = true;
211
        }
212

    
213
}