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

History | View | Annotate | Download (7.62 KB)

1 40560 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3 40435 jjdelcerro
 *
4 40560 jjdelcerro
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6 40435 jjdelcerro
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8 40560 jjdelcerro
 * as published by the Free Software Foundation; either version 3
9 40435 jjdelcerro
 * of the License, or (at your option) any later version.
10 40560 jjdelcerro
 *
11 40435 jjdelcerro
 * 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 40560 jjdelcerro
 *
16 40435 jjdelcerro
 * 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 40560 jjdelcerro
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 40435 jjdelcerro
 * MA  02110-1301, USA.
20 40560 jjdelcerro
 *
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 40435 jjdelcerro
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2010 {Prodevelop}   {Task}
27
 */
28
29
package org.gvsig.installer.swing.impl.creation;
30
31
import java.awt.BorderLayout;
32
import java.io.File;
33
import java.io.OutputStream;
34
import java.net.URL;
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.creation.MakePluginPackageService;
46
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
47
import org.gvsig.installer.swing.api.creation.MakePluginPackageWizard;
48
import org.gvsig.installer.swing.impl.creation.wizard.AdvancedModeSelectionWizard;
49
import org.gvsig.installer.swing.impl.creation.wizard.AntScriptWizard;
50
import org.gvsig.installer.swing.impl.creation.wizard.PackageInfoWizard;
51
import org.gvsig.installer.swing.impl.creation.wizard.ProgressWizard;
52
import org.gvsig.installer.swing.impl.creation.wizard.SelectFilesWizard;
53
import org.gvsig.installer.swing.impl.creation.wizard.SelectOutputFileWizard;
54
import org.gvsig.installer.swing.impl.creation.wizard.SelectPlugintoInstallWizard;
55
import org.gvsig.installer.swing.impl.wizard.WizardListenerAdapter;
56
import org.gvsig.tools.locator.LocatorException;
57
58
/**
59
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
60
 */
61
public class DefaultMakePluginPackageWizard extends MakePluginPackageWizard
62
                implements WizardPanel {
63
64
        private static final long serialVersionUID = 9205891710214122265L;
65
        private WizardPanelWithLogo wizardPanelWithLogo = null;
66
        private MakePluginPackageService makePluginPackageService = null;
67
        private OutputStream outputStream = null;
68
        private OutputStream indexOutputStream;
69
        private PackageInfo selectedPackageInfo = null;
70
        private File originalPluginFolder = null;
71
72
        // Wizards
73
        private AdvancedModeSelectionWizard advancedModeSelectionWizard = null;
74
        private AntScriptWizard antScriptWizard = null;
75
        private PackageInfoWizard pluginDescriptionWizard = null;
76
        private ProgressWizard progressWizard = null;
77
        private SelectFilesWizard selectFilesWizard = null;
78
        private SelectOutputFileWizard selectOutputFileWizard = null;
79
        private SelectPlugintoInstallWizard selectPlugintoInstallWizard = null;
80
81
        private WizardListenerAdapter wizardListenerAdapter = null;
82
        private URL downloadURL;
83
84
        public DefaultMakePluginPackageWizard(File applicationFolder,
85
                        File installFolder) throws LocatorException,
86
                        MakePluginPackageServiceException {
87
                super(applicationFolder, installFolder);
88
                URL iconURL = getClass().getClassLoader().getResource(
89
                                "images/makepluginpackageicon.png");
90
                ImageIcon icon = new ImageIcon(iconURL);
91
                wizardPanelWithLogo = new WizardPanelWithLogo(icon);
92
93
                advancedModeSelectionWizard = new AdvancedModeSelectionWizard(this);
94
                antScriptWizard = new AntScriptWizard(this);
95
                pluginDescriptionWizard = new PackageInfoWizard(this);
96
                progressWizard = new ProgressWizard(this);
97
                selectFilesWizard = new SelectFilesWizard(this);
98
                selectOutputFileWizard = new SelectOutputFileWizard(this);
99
                selectPlugintoInstallWizard = new SelectPlugintoInstallWizard(this);
100
101
                addWizards();
102
103
                // Adding the listeners
104
                wizardPanelWithLogo.setWizardListener(this);
105
106
                setFinishButtonEnabled(false);
107
108
                this.setLayout(new BorderLayout());
109
                this.add(wizardPanelWithLogo, BorderLayout.CENTER);
110
111
                makePluginPackageService = InstallerLocator.getInstallerManager()
112
                                .getMakePluginPackageService();
113
                selectPlugintoInstallWizard
114
                                .setPluginsDirectory(makePluginPackageService);
115
                selectFilesWizard.setApplicationDirectory(applicationFolder);
116
        }
117
118
        public MakePluginPackageService getMakePluginPackageService() {
119
                return makePluginPackageService;
120
        }
121
122
        private void addWizards() {
123
                wizardPanelWithLogo.addOptionPanel(selectPlugintoInstallWizard);
124
                wizardPanelWithLogo.addOptionPanel(pluginDescriptionWizard);
125
                wizardPanelWithLogo.addOptionPanel(advancedModeSelectionWizard);
126
                addLastWizards();
127
        }
128
129
        private void addLastWizards() {
130
                wizardPanelWithLogo.addOptionPanel(selectOutputFileWizard);
131
                wizardPanelWithLogo.addOptionPanel(progressWizard);
132
        }
133
134
        private void addAdvancedWizards() {
135
                wizardPanelWithLogo.addOptionPanel(selectFilesWizard);
136
                wizardPanelWithLogo.addOptionPanel(antScriptWizard);
137
        }
138
139
        private DefaultJWizardComponents getWizardComponents() {
140
                return wizardPanelWithLogo.getWizardComponents();
141
        }
142
143
        public void setNextButtonEnabled(boolean isEnabled) {
144
                wizardPanelWithLogo.setNextButtonEnabled(isEnabled);
145
        }
146
147
        public void setCancelButtonEnabled(boolean isEnabled) {
148
                wizardPanelWithLogo.setCancelButtonEnabled(isEnabled);
149
        }
150
151
        public void setFinishButtonEnabled(boolean isEnabled) {
152
                wizardPanelWithLogo.setFinishButtonEnabled(isEnabled);
153
        }
154
155
        public void setBackButtonEnabled(boolean isEnabled) {
156
                wizardPanelWithLogo.setBackButtonEnabled(isEnabled);
157
        }
158
159
        public void setAdvancedModeSelected(boolean advancedModeSelected) {
160
                for (int i = getWizardComponents().getWizardPanelList().size() - 1; i >= 3; i--) {
161
                        getWizardComponents().removeWizardPanel(i);
162
                }
163
                if (advancedModeSelected) {
164
                        addAdvancedWizards();
165
                }
166
                addLastWizards();
167
        }
168
169
        /**
170
         * @return the installercreationService
171
         */
172
        public MakePluginPackageService getInstallerCreationService() {
173
                return makePluginPackageService;
174
        }
175
176
        /**
177
         * @return the outputStream
178
         */
179
        public OutputStream getOutputStream() {
180
                return outputStream;
181
        }
182
183
        /**
184
         * @param outputStream
185
         *            the outputStream to set
186
         */
187
        public void setOutputStream(OutputStream outputStream) {
188
                this.outputStream = outputStream;
189
        }
190
191
        public OutputStream getIndexOutputStream() {
192
                return indexOutputStream;
193
        }
194
195
        public void setIndexOutputStream(OutputStream outputStream) {
196
                this.indexOutputStream = outputStream;
197
        }
198
199
        public PackageInfo getSelectedPackageInfo() {
200
                return selectedPackageInfo;
201
        }
202
203
        public void setSelectedPackageInfo(PackageInfo selectedPackageInfo) {
204
                this.selectedPackageInfo = selectedPackageInfo;
205
        }
206
207
        public void setOriginalPluginFolder(File originalPluginFolder) {
208
                this.originalPluginFolder = originalPluginFolder;
209
        }
210
211
        public File getOriginalPluginFolder() {
212
                return this.originalPluginFolder;
213
        }
214
215
        public WizardPanelActionListener getWizardPanelActionListener() {
216
                if (((wizardListenerAdapter == null) && (getWizardActionListener() != null))) {
217
                        return new WizardListenerAdapter(this);
218
                }
219
                return wizardListenerAdapter;
220
        }
221
222
        public void setWizardPanelActionListener(
223
                        WizardPanelActionListener wizardActionListener) {
224
                // TODO Auto-generated method stub
225
226
        }
227
228
        public void setDownloadURL(URL downloadURL) {
229
                this.downloadURL = downloadURL;
230
        }
231
232
        public URL getDownloadURL() {
233
                return downloadURL;
234
        }
235
236
}