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 / creation / DefaultMakePluginPackageWizard.java @ 33743

History | View | Annotate | Download (7.34 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.creation;
29

    
30
import java.awt.BorderLayout;
31
import java.io.File;
32
import java.io.OutputStream;
33
import java.net.URL;
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.creation.MakePluginPackageService;
45
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
46
import org.gvsig.installer.swing.api.creation.MakePluginPackageWizard;
47
import org.gvsig.installer.swing.impl.creation.wizard.AdvancedModeSelectionWizard;
48
import org.gvsig.installer.swing.impl.creation.wizard.AntScriptWizard;
49
import org.gvsig.installer.swing.impl.creation.wizard.PluginDescriptionWizard;
50
import org.gvsig.installer.swing.impl.creation.wizard.ProgressWizard;
51
import org.gvsig.installer.swing.impl.creation.wizard.SelectFilesWizard;
52
import org.gvsig.installer.swing.impl.creation.wizard.SelectOutputFileWizard;
53
import org.gvsig.installer.swing.impl.creation.wizard.SelectPlugintoInstallWizard;
54
import org.gvsig.installer.swing.impl.wizard.WizardListenerAdapter;
55
import org.gvsig.tools.locator.LocatorException;
56

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

    
63
    private static final long serialVersionUID = 9205891710214122265L;
64
    private WizardPanelWithLogo wizardPanelWithLogo = null;
65
    private MakePluginPackageService makePluginPackageService = null;
66
    private OutputStream outputStream = null;
67
    private PackageInfo selectedPackageInfo = null;
68

    
69
    // Wizards
70
    private AdvancedModeSelectionWizard advancedModeSelectionWizard = null;
71
    private AntScriptWizard antScriptWizard = null;
72
    private PluginDescriptionWizard pluginDescriptionWizard = null;
73
    private ProgressWizard progressWizard = null;
74
    private SelectFilesWizard selectFilesWizard = null;
75
    private SelectOutputFileWizard selectOutputFileWizard = null;
76
    private SelectPlugintoInstallWizard selectPlugintoInstallWizard = null;
77

    
78
    private WizardListenerAdapter wizardListenerAdapter = null;
79

    
80
    public DefaultMakePluginPackageWizard(File applicationFolder,
81
        File pluginsFolder, File installFolder) throws LocatorException,
82
        MakePluginPackageServiceException {
83
        super(applicationFolder, pluginsFolder, installFolder);
84
        URL iconURL =
85
            getClass().getClassLoader().getResource(
86
                "images/makepluginpackageicon.png");
87
        ImageIcon icon = new ImageIcon(iconURL);
88
        wizardPanelWithLogo = new WizardPanelWithLogo(icon);
89

    
90
        advancedModeSelectionWizard = new AdvancedModeSelectionWizard(this);
91
        antScriptWizard = new AntScriptWizard(this);
92
        pluginDescriptionWizard = new PluginDescriptionWizard(this);
93
        progressWizard = new ProgressWizard(this);
94
        selectFilesWizard = new SelectFilesWizard(this);
95
        selectOutputFileWizard = new SelectOutputFileWizard(this);
96
        selectPlugintoInstallWizard = new SelectPlugintoInstallWizard(this);
97

    
98
        addWizards();
99

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

    
103
        setFinishButtonEnabled(false);
104

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

    
108
        makePluginPackageService =
109
            InstallerLocator.getInstallerManager().getMakePluginPackageService(
110
                getPluginsFolder());
111
        selectPlugintoInstallWizard
112
            .setPluginsDirectory(makePluginPackageService);
113
        selectFilesWizard.setApplicationDirectory(applicationFolder);
114
    }
115

    
116
    private void addWizards() {
117
        wizardPanelWithLogo.addOptionPanel(selectPlugintoInstallWizard);
118
        wizardPanelWithLogo.addOptionPanel(pluginDescriptionWizard);
119
        wizardPanelWithLogo.addOptionPanel(advancedModeSelectionWizard);
120
        addLastWizards();
121
    }
122

    
123
    private void addLastWizards() {
124
        wizardPanelWithLogo.addOptionPanel(selectOutputFileWizard);
125
        wizardPanelWithLogo.addOptionPanel(progressWizard);
126
    }
127

    
128
    private void addAdvancedWizards() {
129
        wizardPanelWithLogo.addOptionPanel(selectFilesWizard);
130
        wizardPanelWithLogo.addOptionPanel(antScriptWizard);
131
    }
132

    
133
    private DefaultJWizardComponents getWizardComponents() {
134
        return wizardPanelWithLogo.getWizardComponents();
135
    }
136

    
137
    public void setNextButtonEnabled(boolean isEnabled) {
138
        wizardPanelWithLogo.setNextButtonEnabled(isEnabled);
139
    }
140

    
141
    public void setCancelButtonEnabled(boolean isEnabled) {
142
        wizardPanelWithLogo.setCancelButtonEnabled(isEnabled);
143
    }
144

    
145
    public void setFinishButtonEnabled(boolean isEnabled) {
146
        wizardPanelWithLogo.setFinishButtonEnabled(isEnabled);
147
    }
148

    
149
    public void setAdvancedModeSelected(boolean advancedModeSelected) {
150
        for (int i = getWizardComponents().getWizardPanelList().size() - 1; i >= 3; i--) {
151
            getWizardComponents().removeWizardPanel(i);
152
        }
153
        if (advancedModeSelected) {
154
            addAdvancedWizards();
155
        }
156
        addLastWizards();
157
    }
158

    
159
    /**
160
     * @return the installercreationService
161
     */
162
    public MakePluginPackageService getInstallerCreationService() {
163
        return makePluginPackageService;
164
    }
165

    
166
    /**
167
     * @return the outputStream
168
     */
169
    public OutputStream getOutputStream() {
170
        return outputStream;
171
    }
172

    
173
    /**
174
     * @param outputStream
175
     *            the outputStream to set
176
     */
177
    public void setOutputStream(OutputStream outputStream) {
178
        this.outputStream = outputStream;
179
    }
180

    
181
    public PackageInfo getSelectedPackageInfo() {
182
        return selectedPackageInfo;
183
    }
184

    
185
    public void setSelectedPackageInfo(PackageInfo selectedPackageInfo) {
186
        this.selectedPackageInfo = selectedPackageInfo;
187
    }
188

    
189
    public WizardPanelActionListener getWizardPanelActionListener() {
190
        if (((wizardListenerAdapter == null) && (getWizardActionListener() != null))) {
191
            return new WizardListenerAdapter(this);
192
        }
193
        return wizardListenerAdapter;
194
    }
195

    
196
    public void setWizardPanelActionListener(
197
        WizardPanelActionListener wizardActionListener) {
198
        // TODO Auto-generated method stub
199

    
200
    }
201
}