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 / wizard / AntScriptWizard.java @ 40560

History | View | Annotate | Download (3.53 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2010 {Prodevelop}   {Task}
27
 */
28

    
29
package org.gvsig.installer.swing.impl.creation.wizard;
30

    
31
import java.io.ByteArrayInputStream;
32

    
33
import javax.swing.JPanel;
34
import javax.xml.parsers.DocumentBuilder;
35
import javax.xml.parsers.DocumentBuilderFactory;
36

    
37
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39

    
40
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
41
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
42
import org.gvsig.installer.lib.api.PackageInfo;
43
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
44
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
45
import org.gvsig.installer.swing.impl.creation.DefaultMakePluginPackageWizard;
46
import org.gvsig.installer.swing.impl.creation.panel.AntScriptPanel;
47

    
48
/**
49
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
50
 */
51
public class AntScriptWizard extends AntScriptPanel implements OptionPanel {
52

    
53
        /**
54
     * 
55
     */
56
        private static final long serialVersionUID = -4741237867123090223L;
57
        private DefaultMakePluginPackageWizard installerCreationWizard;
58
        private static final Logger log = LoggerFactory
59
                        .getLogger(AntScriptWizard.class);
60

    
61
        public AntScriptWizard(
62
                        DefaultMakePluginPackageWizard installerCreationWizard) {
63
                super();
64
                this.installerCreationWizard = installerCreationWizard;
65
        }
66

    
67
        public JPanel getJPanel() {
68
                return this;
69
        }
70

    
71
        public String getPanelTitle() {
72
                return swingInstallerManager.getText("_ant_script");
73
        }
74

    
75
        public void lastPanel() {
76
                // TODO Auto-generated method stub
77

    
78
        }
79

    
80
        public void nextPanel() throws NotContinueWizardException {
81
                DocumentBuilder documentBuilder;
82
                try {
83
                        documentBuilder = DocumentBuilderFactory.newInstance()
84
                                        .newDocumentBuilder();
85
                        documentBuilder.parse(new ByteArrayInputStream(getAntScript()
86
                                        .getBytes()));
87
                } catch (Exception e) {
88
                        throw new NotContinueWizardException("not_valid_xml", e,
89
                                        installerCreationWizard);
90
                }
91
                PackageInfo packageInfo = installerCreationWizard
92
                                .getSelectedPackageInfo();
93
                packageInfo.setAntScript(getAntScript());
94
        }
95

    
96
        public void updatePanel() {
97
                PackageInfo installerInfo;
98
                try {
99
                        MakePluginPackageService installerCreationService = installerCreationWizard
100
                                        .getInstallerCreationService();
101
                        installerInfo = installerCreationWizard.getSelectedPackageInfo();
102
                        if (installerInfo.getAntScript() != null) {
103
                                setAntScript(installerInfo.getAntScript());
104
                        } else {
105
                                setAntScript(installerCreationService.getDefaultAntScript());
106
                        }
107
                } catch (MakePluginPackageServiceException e) {
108
                        log.error("There is not a selected installer info", e);
109
                }
110
        }
111

    
112
}