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 / wizard / AntScriptWizard.java @ 37591
History | View | Annotate | Download (3.49 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.wizard; |
29 |
|
30 |
import java.io.ByteArrayInputStream; |
31 |
|
32 |
import javax.swing.JPanel; |
33 |
import javax.xml.parsers.DocumentBuilder; |
34 |
import javax.xml.parsers.DocumentBuilderFactory; |
35 |
|
36 |
import org.slf4j.Logger; |
37 |
import org.slf4j.LoggerFactory; |
38 |
|
39 |
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException; |
40 |
import org.gvsig.gui.beans.wizard.panel.OptionPanel; |
41 |
import org.gvsig.installer.lib.api.PackageInfo; |
42 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
43 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
44 |
import org.gvsig.installer.swing.impl.creation.DefaultMakePluginPackageWizard; |
45 |
import org.gvsig.installer.swing.impl.creation.panel.AntScriptPanel; |
46 |
|
47 |
/**
|
48 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
49 |
*/
|
50 |
public class AntScriptWizard extends AntScriptPanel implements OptionPanel { |
51 |
|
52 |
/**
|
53 |
*
|
54 |
*/
|
55 |
private static final long serialVersionUID = -4741237867123090223L; |
56 |
private DefaultMakePluginPackageWizard installerCreationWizard;
|
57 |
private static final Logger log = LoggerFactory |
58 |
.getLogger(AntScriptWizard.class); |
59 |
|
60 |
public AntScriptWizard(
|
61 |
DefaultMakePluginPackageWizard installerCreationWizard) { |
62 |
super();
|
63 |
this.installerCreationWizard = installerCreationWizard;
|
64 |
} |
65 |
|
66 |
public JPanel getJPanel() { |
67 |
return this; |
68 |
} |
69 |
|
70 |
public String getPanelTitle() { |
71 |
return swingInstallerManager.getText("ant_script"); |
72 |
} |
73 |
|
74 |
public void lastPanel() { |
75 |
// TODO Auto-generated method stub
|
76 |
|
77 |
} |
78 |
|
79 |
public void nextPanel() throws NotContinueWizardException { |
80 |
DocumentBuilder documentBuilder;
|
81 |
try {
|
82 |
documentBuilder = DocumentBuilderFactory.newInstance()
|
83 |
.newDocumentBuilder(); |
84 |
documentBuilder.parse(new ByteArrayInputStream(getAntScript() |
85 |
.getBytes())); |
86 |
} catch (Exception e) { |
87 |
throw new NotContinueWizardException("not_valid_xml", e, |
88 |
installerCreationWizard); |
89 |
} |
90 |
PackageInfo packageInfo = installerCreationWizard |
91 |
.getSelectedPackageInfo(); |
92 |
packageInfo.setAntScript(getAntScript()); |
93 |
} |
94 |
|
95 |
public void updatePanel() { |
96 |
PackageInfo installerInfo; |
97 |
try {
|
98 |
MakePluginPackageService installerCreationService = installerCreationWizard |
99 |
.getInstallerCreationService(); |
100 |
installerInfo = installerCreationWizard.getSelectedPackageInfo(); |
101 |
if (installerInfo.getAntScript() != null) { |
102 |
setAntScript(installerInfo.getAntScript()); |
103 |
} else {
|
104 |
setAntScript(installerCreationService.getDefaultAntScript()); |
105 |
} |
106 |
} catch (MakePluginPackageServiceException e) {
|
107 |
log.error("There is not a selected installer info", e);
|
108 |
} |
109 |
} |
110 |
|
111 |
} |