Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2042 / extensions / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / DefaultInstallPackageWizard.java @ 37479

History | View | Annotate | Download (7.33 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 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.SwingInstallerLocator;
47
import org.gvsig.installer.swing.api.execution.AbstractInstallPackageWizard;
48
import org.gvsig.installer.swing.impl.execution.wizard.DownloadProgressWizard;
49
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizard;
50
import org.gvsig.installer.swing.impl.execution.wizard.SelectBundlesWizard;
51
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizard;
52
import org.gvsig.installer.swing.impl.execution.wizard.TypicalOrAdvancedWizard;
53
import org.gvsig.installer.swing.impl.wizard.WizardListenerAdapter;
54

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

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

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

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

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

    
79
    private WizardListenerAdapter wizardListenerAdapter = null;
80

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

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

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

    
95
        List<URL> downloadURLs =
96
            SwingInstallerLocator.getSwingInstallerManager()
97
                .getDefaultDownloadURLs();
98
        selectInstallersWizard = new SelectBundlesWizard(this, downloadURLs);
99
        typicalOrAdvancedWizard = new TypicalOrAdvancedWizard(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
    /**
133
     * @return the installerExecutionService
134
     */
135
    public InstallPackageService getInstallerExecutionService() {
136
        return installerExecutionService;
137
    }
138

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

    
146
    public void setNextButtonEnabled(boolean isEnabled) {
147
        getWizardComponents().getNextButton().setEnabled(isEnabled);
148
    }
149

    
150
    public void setFinishButtonVisible(boolean isVisible) {
151
        getWizardComponents().getFinishButton().setEnabled(isVisible);
152
    }
153

    
154
    public void setCancelButtonEnabled(boolean isEnabled) {
155
        getWizardComponents().getCancelButton().setEnabled(isEnabled);
156
    }
157

    
158
    public void setBackButtonEnabled(boolean isEnabled) {
159
        getWizardComponents().getBackButton().setEnabled(isEnabled);
160
    }
161

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

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

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

    
182
    public void setSelectDefaultPackages(boolean isActivated) {
183
        this.selectDefaultPackages = isActivated;
184
    }
185

    
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
    public boolean getAskTypicalOrCustom() {
204
        return askInstallationMode;
205
    }
206

    
207
    public void setAskTypicalOrCustom(boolean b) {
208
        askInstallationMode = true;
209
    }
210

    
211
}