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

History | View | Annotate | Download (7.51 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.SelectPackagesWizard2;
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 SelectPackagesWizard2 selectPluginsWizard = null;
75
    // private SelectPackagesWizard selectPluginsWizard = null;
76
    private ProgressWizard progressWizard = null;
77
    private DownloadProgressWizard downloadProgressWizard = null;
78
    private TypicalOrAdvancedWizard typicalOrAdvancedWizard = null;
79

    
80
    private WizardListenerAdapter wizardListenerAdapter = null;
81

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

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

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

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

    
107
        addWizards();
108

    
109
        // Adding the listeners
110
        wizardPanelWithLogo.setWizardListener(this);
111

    
112
        setFinishButtonVisible(false);
113

    
114
        this.setLayout(new BorderLayout());
115
        this.add(wizardPanelWithLogo, BorderLayout.CENTER);
116
    }
117

    
118
    public void doAction(int action) {
119
        this.wizardPanelWithLogo.doAction(action);
120
    }
121

    
122
    private void addWizards() {
123
        wizardPanelWithLogo.addOptionPanel(selectInstallersWizard);
124
        wizardPanelWithLogo.addOptionPanel(typicalOrAdvancedWizard);
125
        wizardPanelWithLogo.addOptionPanel(selectPluginsWizard);
126
        wizardPanelWithLogo.addOptionPanel(downloadProgressWizard);
127
        wizardPanelWithLogo.addOptionPanel(progressWizard);
128
    }
129

    
130
    public DefaultJWizardComponents getWizardComponents() {
131
        return wizardPanelWithLogo.getWizardComponents();
132
    }
133

    
134
    /**
135
     * @return the installerExecutionService
136
     */
137
    public InstallPackageService getInstallerExecutionService() {
138
        return installerExecutionService;
139
    }
140

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

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

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

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

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

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

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

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

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

    
188
    public boolean getSelectDefaultPackages() {
189
        return this.selectDefaultPackages;
190
    }
191

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

    
201
    public boolean showSelectPackagesPanel() {
202
        return installationMode == ADVANCED_MODE;
203
    }
204

    
205
    public boolean getAskTypicalOrCustom() {
206
        return askInstallationMode;
207
    }
208

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

    
213
}