Statistics
| Revision:

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

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

    
36
import javax.swing.ImageIcon;
37

    
38
import jwizardcomponent.DefaultJWizardComponents;
39

    
40
import org.gvsig.gui.beans.wizard.WizardPanel;
41
import org.gvsig.gui.beans.wizard.WizardPanelActionListener;
42
import org.gvsig.gui.beans.wizard.WizardPanelWithLogo;
43
import org.gvsig.installer.lib.api.InstallerLocator;
44
import org.gvsig.installer.lib.api.PackageInfo;
45
import org.gvsig.installer.lib.api.execution.InstallPackageService;
46
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
47
import org.gvsig.installer.swing.api.SwingInstallerLocator;
48
import org.gvsig.installer.swing.api.execution.InstallPackageWizard;
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.wizard.WizardListenerAdapter;
53

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

    
60
    private static final long serialVersionUID = 554068938842141497L;
61
    private WizardPanelWithLogo wizardPanelWithLogo = null;
62
    private InstallPackageService installerExecutionService = null;
63
    private List<PackageInfo> installersToInstall = null;
64

    
65
    // Wizards
66
    private SelectBundlesWizard selectInstallersWizard = null;
67
    private SelectPackagesWizard selectPluginsWizard = null;
68
    private ProgressWizard progressWizard = null;
69

    
70
    private WizardListenerAdapter wizardListenerAdapter = null;
71

    
72
    public DefaultInstallPackageWizard(File applicationFolder,
73
        File pluginsFolder, File installFolder)
74
        throws InstallPackageServiceException {
75
        super(applicationFolder, pluginsFolder, installFolder);
76

    
77
        installerExecutionService =
78
            InstallerLocator.getInstallerManager().getInstallPackageService();
79

    
80
        URL iconURL =
81
            getClass().getClassLoader().getResource(
82
                "images/installpackageicon.png");
83
        ImageIcon icon = new ImageIcon(iconURL);
84
        wizardPanelWithLogo = new WizardPanelWithLogo(icon);
85

    
86
        URL downloadURL =
87
            SwingInstallerLocator.getSwingInstallerManager()
88
                .getDefaultDownloadURL();
89
        selectInstallersWizard = new SelectBundlesWizard(this, downloadURL);
90
        selectPluginsWizard = new SelectPackagesWizard(this);
91
        progressWizard = new ProgressWizard(this);
92

    
93
        installersToInstall = new ArrayList<PackageInfo>();
94

    
95
        addWizards();
96

    
97
        // Adding the listeners
98
        wizardPanelWithLogo.setWizardListener(this);
99

    
100
        setFinishButtonVisible(false);
101

    
102
        this.setLayout(new BorderLayout());
103
        this.add(wizardPanelWithLogo, BorderLayout.CENTER);
104
    }
105

    
106
    private void addWizards() {
107
        wizardPanelWithLogo.addOptionPanel(selectInstallersWizard);
108
        wizardPanelWithLogo.addOptionPanel(selectPluginsWizard);
109
        wizardPanelWithLogo.addOptionPanel(progressWizard);
110
    }
111

    
112
    public DefaultJWizardComponents getWizardComponents() {
113
        return wizardPanelWithLogo.getWizardComponents();
114
    }
115

    
116
    /**
117
     * @return the installerExecutionService
118
     */
119
    public InstallPackageService getInstallerExecutionService() {
120
        return installerExecutionService;
121
    }
122

    
123
    /**
124
     * @return the installersToInstall
125
     */
126
    public List<PackageInfo> getInstallersToInstall() {
127
        return installersToInstall;
128
    }
129

    
130
    public void setNextButtonEnabled(boolean isEnabled) {
131
        getWizardComponents().getNextButton().setEnabled(isEnabled);
132
    }
133

    
134
    public void setFinishButtonVisible(boolean isVisible) {
135
        getWizardComponents().getFinishButton().setEnabled(isVisible);
136
    }
137

    
138
    public void setCancelButtonEnabled(boolean isEnabled) {
139
        getWizardComponents().getCancelButton().setEnabled(isEnabled);
140
    }
141

    
142
    public void setBackButtonEnabled(boolean isEnabled) {
143
        getWizardComponents().getBackButton().setEnabled(isEnabled);
144
    }
145

    
146
    @Override
147
    public void installFromDefaultDirectory()
148
        throws InstallPackageServiceException {
149
        getWizardComponents().removeWizardPanel(0);
150
        installerExecutionService.addBundlesFromDirectory(getInstallFolder());
151
        selectPluginsWizard.updatePanel();
152
    }
153

    
154
    public WizardPanelActionListener getWizardPanelActionListener() {
155
        if (((wizardListenerAdapter == null) && (getWizardActionListener() != null))) {
156
            return new WizardListenerAdapter(this);
157
        }
158
        return wizardListenerAdapter;
159
    }
160

    
161
    public void setWizardPanelActionListener(
162
        WizardPanelActionListener wizardActionListener) {
163
        // TODO Auto-generated method stub
164

    
165
    }
166
}