Revision 32296
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/InstallerInfo.java | ||
---|---|---|
62 | 62 |
public boolean isOfficial(); |
63 | 63 |
|
64 | 64 |
public void setOfficial(boolean official); |
65 |
|
|
66 |
public boolean isAdvancedMode(); |
|
67 |
|
|
68 |
public void setAdvancedMode(boolean isAdvancedMode); |
|
65 | 69 |
|
66 | 70 |
public void addFileToCopy(File file); |
67 | 71 |
|
... | ... | |
71 | 75 |
|
72 | 76 |
public void removeFileToCopy(int index); |
73 | 77 |
|
74 |
// public void setAnScript(String antScript);
|
|
75 |
// |
|
76 |
// public String getAntScript();
|
|
78 |
public void setAnScript(String antScript); |
|
79 |
|
|
80 |
public String getAntScript(); |
|
77 | 81 |
|
78 | 82 |
} |
79 | 83 |
|
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/test/resources/org.gvsig.plugin3/install.xml | ||
---|---|---|
1 |
<project name="org.gvsig.plugin1" default="main" basedir="."> |
|
2 |
<target name="main" depends="copy_files"/> |
|
3 |
<target name="copy_files"> |
|
4 |
<copy todir="${gvsig_dir}"> |
|
5 |
<fileset dir="./files" includes="**"/> |
|
6 |
</copy> |
|
7 |
</target> |
|
8 |
</project> |
|
0 | 9 |
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/resources/install.xml | ||
---|---|---|
1 |
<project name="org.gvsig.plugin1" default="main" basedir="."> |
|
2 |
<target name="main" depends="copy_files"/> |
|
3 |
<target name="copy_files"> |
|
4 |
<copy todir="${gvsig_dir}"> |
|
5 |
<fileset dir="./files" includes="**"/> |
|
6 |
</copy> |
|
7 |
</target> |
|
8 |
</project> |
|
0 | 9 |
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultInstallerInfo.java | ||
---|---|---|
45 | 45 |
protected String state = "Testing"; |
46 | 46 |
protected boolean official; |
47 | 47 |
protected List<File> selectedFiles = null; |
48 |
protected String antScript = null; |
|
49 |
protected boolean isAdvancedMode; |
|
48 | 50 |
|
49 | 51 |
public DefaultInstallerInfo() { |
50 | 52 |
super(); |
... | ... | |
123 | 125 |
selectedFiles.remove(index); |
124 | 126 |
} |
125 | 127 |
|
128 |
public String getAntScript() { |
|
129 |
return antScript; |
|
130 |
} |
|
131 |
|
|
132 |
public void setAnScript(String antScript) { |
|
133 |
this.antScript = antScript; |
|
134 |
} |
|
135 |
|
|
136 |
public boolean isAdvancedMode() { |
|
137 |
return isAdvancedMode; |
|
138 |
} |
|
139 |
|
|
140 |
public void setAdvancedMode(boolean isAdvancedMode) { |
|
141 |
this.isAdvancedMode = isAdvancedMode; |
|
142 |
} |
|
143 |
|
|
126 | 144 |
} |
127 | 145 |
|
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/execution/Decompress.java | ||
---|---|---|
34 | 34 |
import java.io.IOException; |
35 | 35 |
import java.io.InputStream; |
36 | 36 |
import java.util.ArrayList; |
37 |
import java.util.Iterator; |
|
38 | 37 |
import java.util.List; |
39 |
import java.util.Properties; |
|
40 | 38 |
import java.util.zip.ZipEntry; |
41 | 39 |
import java.util.zip.ZipException; |
42 | 40 |
import java.util.zip.ZipInputStream; |
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/creation/DefaultInstallerCreationService.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.installer.lib.impl.creation; |
29 | 29 |
|
30 |
import java.io.ByteArrayInputStream; |
|
30 | 31 |
import java.io.File; |
31 | 32 |
import java.io.FileInputStream; |
32 | 33 |
import java.io.FileOutputStream; |
... | ... | |
41 | 42 |
import org.gvsig.installer.lib.impl.info.InstallerInfoFileException; |
42 | 43 |
import org.gvsig.installer.lib.impl.info.InstallerInfoFileReader; |
43 | 44 |
import org.gvsig.installer.lib.impl.info.InstallerInfoFileWriter; |
45 |
import org.slf4j.Logger; |
|
44 | 46 |
|
45 | 47 |
/** |
46 | 48 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
47 | 49 |
*/ |
48 | 50 |
public class DefaultInstallerCreationService extends DefaultInstallerInfo implements InstallerCreationService { |
49 | 51 |
public static final String INSTALLINFO_FILE_NAME = "install.info"; |
52 |
public static final String ANT_FILE_NAME = "install.xml"; |
|
50 | 53 |
public static final String COPIED_FILES_DIRECTORY_NAME = "files"; |
51 | 54 |
private File pluginDirectory; |
55 |
private static final Logger logger = org.slf4j.LoggerFactory.getLogger(DefaultInstallerCreationService.class); |
|
52 | 56 |
|
53 |
|
|
54 | 57 |
public void createInstaller(OutputStream installerStream) |
55 | 58 |
throws InstallerCreationServiceException { |
56 | 59 |
if (pluginDirectory == null){ |
... | ... | |
60 | 63 |
//Write the install.info file |
61 | 64 |
writeInstallInfo(); |
62 | 65 |
|
63 |
//Copy the selected files |
|
64 |
writeSelectedFiles(); |
|
66 |
if (isAdvancedMode){ |
|
67 |
//Create the ant file |
|
68 |
if (antScript != null){ |
|
69 |
writeAntFile(); |
|
70 |
}else{ |
|
71 |
File antFileModel = new File(getClass().getClassLoader().getResource(ANT_FILE_NAME).getFile()); |
|
72 |
try{ |
|
73 |
copy(antFileModel, new File(getAntFileName())); |
|
74 |
}catch(IOException e){ |
|
75 |
throw new InstallerCreationServiceException("Exception copying the ant file"); |
|
76 |
} |
|
77 |
} |
|
65 | 78 |
|
79 |
//Copy the selected files |
|
80 |
writeSelectedFiles(); |
|
81 |
} |
|
82 |
|
|
66 | 83 |
Compress compress = new Compress(); |
67 | 84 |
compress.compressPlugin(pluginDirectory, installerStream); |
68 | 85 |
} |
69 | 86 |
|
87 |
private void writeAntFile() throws InstallerCreationServiceException { |
|
88 |
try{ |
|
89 |
ByteArrayInputStream in = new ByteArrayInputStream(antScript.getBytes()); |
|
90 |
OutputStream out = new FileOutputStream(getAntFileName()); |
|
91 |
|
|
92 |
// Copy the bits from instream to outstream |
|
93 |
byte[] buf = new byte[1024]; |
|
94 |
int len; |
|
95 |
while ((len = in.read(buf)) > 0) { |
|
96 |
out.write(buf, 0, len); |
|
97 |
} |
|
98 |
in.close(); |
|
99 |
out.close(); |
|
100 |
}catch(IOException e){ |
|
101 |
throw new InstallerCreationServiceException("Exception writing the ant file"); |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
70 | 105 |
private void writeSelectedFiles() throws InstallerCreationServiceException { |
71 | 106 |
try{ |
72 | 107 |
String copiedFilesDirectory = getCopiedFilesDirectoryName(); |
... | ... | |
171 | 206 |
return pluginDirectory + File.separator + INSTALLINFO_FILE_NAME; |
172 | 207 |
} |
173 | 208 |
|
209 |
private String getAntFileName(){ |
|
210 |
return pluginDirectory + File.separator + ANT_FILE_NAME; |
|
211 |
} |
|
212 |
|
|
174 | 213 |
public InstallerInfo getInstallerInfo() { |
175 | 214 |
return this; |
176 | 215 |
} |
... | ... | |
183 | 222 |
FileInputStream fis = new FileInputStream(file); |
184 | 223 |
|
185 | 224 |
InstallerInfoFileReader installerInfoFileReader = new InstallerInfoFileReader(); |
186 |
installerInfoFileReader.read(this, fis); |
|
187 |
|
|
188 |
//Load the files to copy |
|
189 |
String copiedFilesDirectory = getCopiedFilesDirectoryName(); |
|
190 |
File copiedFilesDirectoryfile = new File(copiedFilesDirectory); |
|
225 |
installerInfoFileReader.read(this, fis); |
|
226 |
|
|
227 |
//Load the ant file |
|
228 |
File antFile = new File(getAntFileName()); |
|
229 |
if (antFile.exists()){ |
|
230 |
loadAntFile(antFile); |
|
231 |
} |
|
232 |
|
|
233 |
//Load the files to copy |
|
234 |
File copiedFilesDirectoryfile = new File(getCopiedFilesDirectoryName()); |
|
191 | 235 |
if (copiedFilesDirectoryfile.exists()){ |
192 | 236 |
loadCopiedFiles(copiedFilesDirectoryfile); |
193 | 237 |
} |
... | ... | |
197 | 241 |
} |
198 | 242 |
} |
199 | 243 |
|
244 |
/* (non-Javadoc) |
|
245 |
* @see org.gvsig.installer.lib.impl.DefaultInstallerInfo#getAntScript() |
|
246 |
*/ |
|
247 |
@Override |
|
248 |
public String getAntScript() { |
|
249 |
if (super.getAntScript() != null){ |
|
250 |
return super.getAntScript(); |
|
251 |
} |
|
252 |
if (isAdvancedMode){ |
|
253 |
try { |
|
254 |
loadAntFile(new File(getClass().getClassLoader().getResource(ANT_FILE_NAME).getFile())); |
|
255 |
return antScript; |
|
256 |
} catch (IOException e) { |
|
257 |
logger.error("reading the ant script model", e); |
|
258 |
} |
|
259 |
} |
|
260 |
return null; |
|
261 |
} |
|
262 |
|
|
263 |
private void loadAntFile(File antFile) throws IOException { |
|
264 |
StringBuffer fileData = new StringBuffer(); |
|
265 |
FileInputStream fis = new FileInputStream(antFile); |
|
266 |
byte[] buf = new byte[1024]; |
|
267 |
int numRead = 0; |
|
268 |
while ((numRead = fis.read(buf)) != -1) { |
|
269 |
String readData = new String(buf, 0, numRead); |
|
270 |
fileData.append(readData); |
|
271 |
buf = new byte[1024]; |
|
272 |
} |
|
273 |
fis.close(); |
|
274 |
setAnScript(fileData.toString()); |
|
275 |
} |
|
276 |
|
|
200 | 277 |
private void loadCopiedFiles(File file){ |
201 | 278 |
if (file.isDirectory()){ |
202 | 279 |
File[] files = file.listFiles(); |
... | ... | |
206 | 283 |
}else{ |
207 | 284 |
//Removing the plugin prefix |
208 | 285 |
String pluginFile = file.getAbsolutePath().substring(getCopiedFilesDirectoryName().length(), file.getAbsolutePath().length()); |
209 |
|
|
286 |
|
|
210 | 287 |
//Ading the root directory |
211 | 288 |
pluginFile = pluginDirectory.getParentFile().getAbsolutePath() + pluginFile; |
212 |
|
|
289 |
|
|
213 | 290 |
addFileToCopy(new File(pluginFile)); |
214 | 291 |
} |
215 | 292 |
} |
216 |
|
|
293 |
|
|
217 | 294 |
} |
218 | 295 |
|
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/DefaultInstallerCreationWizard.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
import jwizardcomponent.DefaultJWizardComponents; |
37 | 37 |
|
38 |
import org.gvsig.installer.lib.api.InstallerInfo; |
|
39 | 38 |
import org.gvsig.installer.lib.api.creation.InstallerCreationService; |
40 | 39 |
import org.gvsig.installer.swing.api.creation.InstallerCreationWizard; |
41 | 40 |
import org.gvsig.installer.swing.impl.InstallerWizardContainer; |
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/panel/AntScriptPanel.java | ||
---|---|---|
64 | 64 |
gridBagConstraints.weighty = 1.0; |
65 | 65 |
add(scriptScrollPane, gridBagConstraints); |
66 | 66 |
} |
67 |
|
|
68 |
public String getAntScript(){ |
|
69 |
return scriptEditorPane.getText(); |
|
70 |
} |
|
71 |
|
|
72 |
public void setAntScript(String antScript){ |
|
73 |
scriptEditorPane.setText(antScript); |
|
74 |
} |
|
67 | 75 |
} |
68 | 76 |
|
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/model/SelectFilesTree.java | ||
---|---|---|
32 | 32 |
import java.util.List; |
33 | 33 |
|
34 | 34 |
import javax.swing.JTree; |
35 |
import javax.swing.tree.TreePath; |
|
36 | 35 |
import javax.swing.tree.TreeSelectionModel; |
37 | 36 |
|
38 | 37 |
/** |
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/AdvancedModeSelectionWizard.java | ||
---|---|---|
59 | 59 |
|
60 | 60 |
public void nextPanel() { |
61 | 61 |
installerCreationWizard.setAdvancedModeSelected(isAdvancedModeSelected()); |
62 |
installerCreationWizard.getInstallerCreationService().getInstallerInfo(). |
|
63 |
setAdvancedMode(isAdvancedModeSelected()); |
|
62 | 64 |
} |
63 | 65 |
|
64 | 66 |
public void updatePanel() { |
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/SelectOutputFileWizard.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.installer.swing.impl.creation.wizard; |
29 | 29 |
|
30 |
import java.io.File; |
|
31 | 30 |
import java.io.FileNotFoundException; |
32 | 31 |
import java.io.FileOutputStream; |
33 | 32 |
|
34 | 33 |
import javax.swing.JOptionPane; |
35 | 34 |
import javax.swing.JPanel; |
36 | 35 |
|
37 |
import org.gvsig.installer.lib.api.InstallerInfo; |
|
38 | 36 |
import org.gvsig.installer.swing.impl.InstallerWizardPanel; |
39 | 37 |
import org.gvsig.installer.swing.impl.creation.DefaultInstallerCreationWizard; |
40 | 38 |
import org.gvsig.installer.swing.impl.creation.panel.SelectOutputFilePanel; |
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/SelectFilesWizard.java | ||
---|---|---|
33 | 33 |
import javax.swing.JPanel; |
34 | 34 |
|
35 | 35 |
import org.gvsig.installer.lib.api.InstallerInfo; |
36 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
37 |
import org.gvsig.installer.lib.api.creation.InstallerCreationService; |
|
38 | 36 |
import org.gvsig.installer.swing.impl.InstallerWizardPanel; |
39 | 37 |
import org.gvsig.installer.swing.impl.creation.DefaultInstallerCreationWizard; |
40 | 38 |
import org.gvsig.installer.swing.impl.creation.panel.SelectFilesPanel; |
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/ProgressWizard.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.installer.swing.impl.creation.wizard; |
29 | 29 |
|
30 |
import java.io.OutputStream; |
|
31 |
|
|
32 | 30 |
import javax.swing.JPanel; |
33 | 31 |
|
34 | 32 |
import org.gvsig.installer.lib.api.creation.InstallerCreationService; |
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 | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 22 |
|
23 | 23 |
/* |
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
24 |
* AUTHORS (In addition to CIT):
|
|
25 |
* 2010 {Prodevelop} {Task}
|
|
26 |
*/
|
|
27 |
|
|
28 | 28 |
package org.gvsig.installer.swing.impl.creation.wizard; |
29 | 29 |
|
30 | 30 |
import javax.swing.JPanel; |
31 | 31 |
|
32 |
import org.gvsig.installer.lib.api.InstallerInfo; |
|
32 | 33 |
import org.gvsig.installer.swing.impl.InstallerWizardPanel; |
33 | 34 |
import org.gvsig.installer.swing.impl.creation.DefaultInstallerCreationWizard; |
34 | 35 |
import org.gvsig.installer.swing.impl.creation.panel.AntScriptPanel; |
... | ... | |
38 | 39 |
*/ |
39 | 40 |
public class AntScriptWizard extends AntScriptPanel implements InstallerWizardPanel{ |
40 | 41 |
private DefaultInstallerCreationWizard installerCreationWizard; |
41 |
|
|
42 |
|
|
42 | 43 |
public AntScriptWizard(DefaultInstallerCreationWizard installerCreationWizard) { |
43 | 44 |
super(); |
44 | 45 |
this.installerCreationWizard = installerCreationWizard; |
45 | 46 |
} |
46 |
|
|
47 |
|
|
47 | 48 |
public JPanel getJPanel() { |
48 | 49 |
return this; |
49 | 50 |
} |
... | ... | |
54 | 55 |
|
55 | 56 |
public void lastPanel() { |
56 | 57 |
// TODO Auto-generated method stub |
57 |
|
|
58 |
|
|
58 | 59 |
} |
59 | 60 |
|
60 | 61 |
public void nextPanel() { |
61 |
// TODO Auto-generated method stub |
|
62 |
|
|
62 |
InstallerInfo installerInfo = |
|
63 |
installerCreationWizard.getInstallerCreationService().getInstallerInfo(); |
|
64 |
installerInfo.setAnScript(getAntScript()); |
|
63 | 65 |
} |
64 | 66 |
|
65 | 67 |
public void updatePanel() { |
66 |
// TODO Auto-generated method stub |
|
67 |
|
|
68 |
InstallerInfo installerInfo = |
|
69 |
installerCreationWizard.getInstallerCreationService().getInstallerInfo(); |
|
70 |
setAntScript(installerInfo.getAntScript()); |
|
68 | 71 |
} |
69 | 72 |
|
70 | 73 |
} |
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/SelectPlugintoInstallWizard.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.installer.swing.impl.creation.wizard; |
29 | 29 |
|
30 |
import java.io.File; |
|
31 |
import java.io.FileInputStream; |
|
32 |
|
|
33 | 30 |
import javax.swing.JOptionPane; |
34 | 31 |
import javax.swing.JPanel; |
35 | 32 |
|
Also available in: Unified diff