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

History | View | Annotate | Download (6.35 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

    
34
import javax.swing.ImageIcon;
35

    
36
import jwizardcomponent.DefaultJWizardComponents;
37

    
38
import org.gvsig.installer.lib.api.InstallerLocator;
39
import org.gvsig.installer.lib.api.PackageInfo;
40
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
41
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
42
import org.gvsig.installer.swing.api.creation.MakePluginPackageWizard;
43
import org.gvsig.installer.swing.impl.InstallerWizardContainer;
44
import org.gvsig.installer.swing.impl.creation.wizard.AdvancedModeSelectionWizard;
45
import org.gvsig.installer.swing.impl.creation.wizard.AntScriptWizard;
46
import org.gvsig.installer.swing.impl.creation.wizard.PluginDescriptionWizard;
47
import org.gvsig.installer.swing.impl.creation.wizard.ProgressWizard;
48
import org.gvsig.installer.swing.impl.creation.wizard.SelectFilesWizard;
49
import org.gvsig.installer.swing.impl.creation.wizard.SelectOutputFileWizard;
50
import org.gvsig.installer.swing.impl.creation.wizard.SelectPlugintoInstallWizard;
51
import org.gvsig.installer.swing.impl.wizard.WizardPanelWithLogo;
52
import org.gvsig.tools.locator.LocatorException;
53

    
54
/**
55
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
56
 */
57
public class DefaultMakePluginPackageWizard extends MakePluginPackageWizard{
58
        private WizardPanelWithLogo wizardPanelWithLogo = null;
59
        private MakePluginPackageService makePluginPackageService = null;
60
        private OutputStream outputStream = null;
61
        private File pluginsDirectory = null;
62
        private PackageInfo selectedPackageInfo = null;
63

    
64
        //Wizards
65
        private AdvancedModeSelectionWizard advancedModeSelectionWizard = null;
66
        private AntScriptWizard antScriptWizard = null;
67
        private PluginDescriptionWizard pluginDescriptionWizard = null;
68
        private ProgressWizard progressWizard = null;
69
        private SelectFilesWizard selectFilesWizard = null;
70
        private SelectOutputFileWizard selectOutputFileWizard = null;
71
        private SelectPlugintoInstallWizard selectPlugintoInstallWizard = null;
72

    
73
        public DefaultMakePluginPackageWizard(File applicationDirectory) throws LocatorException, MakePluginPackageServiceException
74
        {                
75
                super(applicationDirectory);
76
                wizardPanelWithLogo = new WizardPanelWithLogo(new ImageIcon(getClass().getClassLoader().getResource("images/createplugininstallicon.png").getFile()));        
77

    
78
                advancedModeSelectionWizard = new AdvancedModeSelectionWizard(this);
79
                antScriptWizard = new AntScriptWizard(this);
80
                pluginDescriptionWizard = new PluginDescriptionWizard(this);
81
                progressWizard = new ProgressWizard(this);
82
                selectFilesWizard = new SelectFilesWizard(this);
83
                selectOutputFileWizard = new SelectOutputFileWizard(this);
84
                selectPlugintoInstallWizard = new SelectPlugintoInstallWizard(this);
85

    
86
                addWizards();
87

    
88
                this.setLayout(new BorderLayout());
89
                this.add(wizardPanelWithLogo, BorderLayout.CENTER);
90
                
91
                pluginsDirectory = new File(applicationDirectory.getAbsolutePath() + File.separator + "gvSIG" + File.separator + "extensiones");
92
                
93
                makePluginPackageService = InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory);
94
                selectPlugintoInstallWizard.setPluginsDirectory(makePluginPackageService);        
95
                selectFilesWizard.setApplicationDirectory(applicationDirectory);
96
        }
97

    
98
        private void addWizards(){
99
                getWizardComponents().addWizardPanel(
100
                                new InstallerWizardContainer(getWizardComponents(), 
101
                                                selectPlugintoInstallWizard));        
102
                getWizardComponents().addWizardPanel(
103
                                new InstallerWizardContainer(getWizardComponents(), 
104
                                                pluginDescriptionWizard));        
105
                getWizardComponents().addWizardPanel(
106
                                new InstallerWizardContainer(getWizardComponents(), 
107
                                                advancedModeSelectionWizard));        
108
                addLastWizards();                
109
        }
110

    
111
        private void addLastWizards(){
112
                getWizardComponents().addWizardPanel(
113
                                new InstallerWizardContainer(getWizardComponents(), 
114
                                                selectOutputFileWizard));        
115
                getWizardComponents().addWizardPanel(
116
                                new InstallerWizardContainer(getWizardComponents(), 
117
                                                progressWizard));        
118
        }
119
        
120
        private void addAdvancedWizards(){
121
                getWizardComponents().addWizardPanel(
122
                                new InstallerWizardContainer(getWizardComponents(), 
123
                                                selectFilesWizard));        
124
                getWizardComponents().addWizardPanel(
125
                                new InstallerWizardContainer(getWizardComponents(), 
126
                                                antScriptWizard));        
127
        }
128

    
129

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

    
135
        public void setNextButtonEnabled(boolean isEnabled){
136
                getWizardComponents().getNextButton().setEnabled(isEnabled);
137
        }
138

    
139

    
140
        public void setAdvancedModeSelected(boolean advancedModeSelected) {
141
                for (int i=getWizardComponents().getWizardPanelList().size()-1 ; i>=3 ; i--){
142
                        getWizardComponents().removeWizardPanel(i);
143
                }                
144
                if (advancedModeSelected){
145
                        addAdvancedWizards();
146
                }
147
                addLastWizards();
148
        }        
149

    
150
        /**
151
         * @return the installercreationService
152
         */
153
        public MakePluginPackageService getInstallerCreationService() {
154
                return makePluginPackageService;
155
        }        
156

    
157
        /**
158
         * @return the outputStream
159
         */
160
        public OutputStream getOutputStream() {
161
                return outputStream;
162
        }
163

    
164
        /**
165
         * @param outputStream the outputStream to set
166
         */
167
        public void setOutputStream(OutputStream outputStream) {
168
                this.outputStream = outputStream;
169
        }        
170

    
171
        public PackageInfo getSelectedPackageInfo() {
172
                return selectedPackageInfo;
173
        }
174

    
175
        public void setSelectedPackageInfo(PackageInfo selectedPackageInfo) {
176
                this.selectedPackageInfo = selectedPackageInfo;
177
        }
178
}
179