Revision 32285

View differences:

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/creation/InstallerCreationService.java
35 35
/**
36 36
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
37 37
 */
38
public interface InstallerCreationService extends InstallerInfo{
38
public interface InstallerCreationService {
39 39
	
40 40
	public InstallerInfo getInstallerInfo();
41 41
	
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
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.lib.impl.creation;
29 29

  
30 30
import java.io.File;
31
import java.io.FileInputStream;
31 32
import java.io.OutputStream;
32 33

  
33 34
import org.gvsig.installer.lib.api.InstallerInfo;
34 35
import org.gvsig.installer.lib.api.creation.InstallerCreationService;
35 36
import org.gvsig.installer.lib.api.creation.InstallerCreationServiceException;
36 37
import org.gvsig.installer.lib.impl.DefaultInstallerInfo;
38
import org.gvsig.installer.lib.impl.info.InstallerInfoFileException;
39
import org.gvsig.installer.lib.impl.info.InstallerInfoFileReader;
37 40
import org.gvsig.installer.lib.impl.info.InstallerInfoFileWriter;
38 41

  
39 42
/**
40 43
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
41 44
 */
42 45
public class DefaultInstallerCreationService extends DefaultInstallerInfo implements InstallerCreationService {
46
	private static final String INSTALLINFO_FILE_NAME = "install.info";
43 47
	private File pluginDirectory;
44 48

  
45
	
49

  
46 50
	public void createInstaller(OutputStream installerStream)
47
			throws InstallerCreationServiceException {
51
	throws InstallerCreationServiceException {
48 52
		if (pluginDirectory == null){
49 53
			throw new InstallerCreationServiceException("The plugin directory has to be set");
50 54
		}
51
		InstallerInfoFileWriter installerInfoFileWriter = new InstallerInfoFileWriter();
52
		installerInfoFileWriter.write(this, new File(getInstallInfoFileName(pluginDirectory.getAbsolutePath())));
53
				
55
		
56
		writeInstallInfo();
57

  
54 58
		Compress compress = new Compress();
55 59
		compress.compressPlugin(pluginDirectory, installerStream);			
56 60
	}
57
	
61

  
58 62
	public void setPluginDirectory(File pluginDirectory) throws InstallerCreationServiceException {
59 63
		if (!pluginDirectory.isDirectory()){
60 64
			throw new InstallerCreationServiceException("The plugin directory has to be a directory");
61 65
		}
62 66
		this.pluginDirectory = pluginDirectory;		
67

  
68
		//If the install.info file exists
69
		File file = new File(getInstallerInfoFileName());
70
		if (file.exists()){
71
			readInstallInfo();
72
		}else{
73
			setCode(pluginDirectory.getName());
74
			setName(pluginDirectory.getName());
75
		}
63 76
	}
64 77

  
65
	private String getInstallInfoFileName(String pluginDirectory){
66
		return pluginDirectory + File.separator + "install.info";
78
	private void readInstallInfo() throws InstallerInfoFileException{
79
		InstallerInfoFileReader installerInfoFileReader = new InstallerInfoFileReader();
80
		installerInfoFileReader.read(this, getInstallerInfoFileName());
81
	}	
82
	
83
	private void writeInstallInfo() throws InstallerInfoFileException{
84
		InstallerInfoFileWriter installerInfoFileWriter = new InstallerInfoFileWriter();
85
		installerInfoFileWriter.write(this, new File(getInstallerInfoFileName()));
67 86
	}
68 87

  
88
	private String getInstallerInfoFileName(){
89
		return pluginDirectory + File.separator + INSTALLINFO_FILE_NAME;
90
	}
91

  
69 92
	public InstallerInfo getInstallerInfo() {
70 93
		return this;
71 94
	}
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
28 28
package org.gvsig.installer.lib.impl;
29 29

  
30 30
import java.io.File;
31
import java.io.InputStream;
32
import java.io.OutputStream;
31 33

  
32 34
import org.gvsig.installer.lib.api.InstallerInfo;
33 35

  
......
118 120
		// TODO Auto-generated method stub
119 121
		
120 122
	}
123

  
121 124
}
122 125

  
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
import jwizardcomponent.DefaultJWizardComponents;
36 36

  
37 37
import org.gvsig.installer.lib.api.InstallerInfo;
38
import org.gvsig.installer.lib.api.creation.InstallerCreationService;
38 39
import org.gvsig.installer.swing.api.creation.InstallerCreationWizard;
39 40
import org.gvsig.installer.swing.impl.InstallerWizardContainer;
40 41
import org.gvsig.installer.swing.impl.creation.wizard.AdvancedModeSelectionWizard;
......
51 52
 */
52 53
public class DefaultInstallerCreationWizard extends InstallerCreationWizard{
53 54
	private WizardPanelWithLogo wizardPanelWithLogo = null;
54
	private InstallerInfo installerInfoResource = null;
55
	private InstallerCreationService installercreationService = null;
55 56

  
56 57
	//Wizards
57 58
	private AdvancedModeSelectionWizard advancedModeSelectionWizard = null;
......
127 128
	}	
128 129

  
129 130

  
130
	/**
131
	 * @return the installerInfoResource
132
	 */
133
	public InstallerInfo getInstallerInfoResource() {
134
		return installerInfoResource;
135
	}
136 131

  
137
	/**
138
	 * @param installerInfoResource the installerInfoResource to set
139
	 */
140
	public void setInstallerInfoResource(InstallerInfo installerInfoResource) {
141
		this.installerInfoResource = installerInfoResource;
142
	}
143

  
144 132
	public void setAdvancedModeSelected(boolean advancedModeSelected) {
145 133
		for (int i=getWizardComponents().getWizardPanelList().size()-1 ; i>=3 ; i--){
146 134
			getWizardComponents().removeWizardPanel(i);
......
150 138
		}
151 139
		addLastWizards();
152 140
	}
141
	
142

  
143
	/**
144
	 * @return the installercreationService
145
	 */
146
	public InstallerCreationService getInstallerCreationService() {
147
		return installercreationService;
148
	}
149

  
150
	/**
151
	 * @param installercreationService the installercreationService to set
152
	 */
153
	public void setInstallerCreationService(
154
			InstallerCreationService installercreationService) {
155
		this.installercreationService = installercreationService;
156
	}
153 157
}
154 158

  
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/PluginDescriptionWizard.java
65 65

  
66 66
	public void updatePanel() {
67 67
		InstallerInfo installerInfoResource = 
68
			installerCreationWizard.getInstallerInfoResource();		
68
			installerCreationWizard.getInstallerCreationService().getInstallerInfo();		
69 69
		setCode(installerInfoResource.getCode());
70 70
		setName(installerInfoResource.getName());
71 71
		setVersion(installerInfoResource.getVersion());
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
63 63
	}
64 64

  
65 65
	public void updatePanel() {
66
		setPluginText(installerCreationWizard.getInstallerInfoResource().getName());	
66
		setPluginText(installerCreationWizard.getInstallerCreationService().getInstallerInfo().getName());	
67 67
		//Write the InfoResource file
68 68
		
69 69
		//Compress the plugin
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
import javax.swing.JOptionPane;
30 34
import javax.swing.JPanel;
31 35

  
36
import org.gvsig.installer.lib.api.InstallerLocator;
37
import org.gvsig.installer.lib.api.creation.InstallerCreationService;
32 38
import org.gvsig.installer.swing.impl.InstallerWizardPanel;
33 39
import org.gvsig.installer.swing.impl.creation.DefaultInstallerCreationWizard;
34 40
import org.gvsig.installer.swing.impl.creation.panel.SelectPluginToInstallPanel;
......
63 69
	}
64 70

  
65 71
	public void nextPanel() {
66
//		try {
67
//			InstallerInfo installerInfoResource = 
68
//				InstallerLocator.getInstallerManager().createInstallerInfoResource();
69
//			//If the install.info file exists
70
//			File file = new File(getSelectedPlugin() + File.separator + "install.info");
71
//			if (file.exists()){
72
//				installerInfoResource.read(new FileInputStream(file));
73
//			}else{
74
//				installerInfoResource.setCode(getSelectedPlugin());
75
//				installerInfoResource.setName(getSelectedPlugin());
76
//			}
77
//			installerCreationWizard.setInstallerInfoResource(installerInfoResource);
78
//		} catch (Exception e) {
79
//			logger.error(swingInstallerManager.getText("installer_infofile_exception"), e);
80
//			JOptionPane.showMessageDialog(installerCreationWizard, 
81
//					swingInstallerManager.getText("installer_infofile_exception"));
82
//		} 
72
		try {
73
			InstallerCreationService installerCreationService =
74
				InstallerLocator.getInstallerManager().getInstallerCreationService();			
75
			installerCreationService.setPluginDirectory(new File(getSelectedPlugin()));
76
			installerCreationWizard.setInstallerCreationService(installerCreationService);
77
		} catch (Exception e) {
78
			logger.error(swingInstallerManager.getText("installer_infofile_exception"), e);
79
			JOptionPane.showMessageDialog(installerCreationWizard, 
80
					swingInstallerManager.getText("installer_infofile_exception"));
81
		} 
83 82
	}
84 83
	
85 84

  

Also available in: Unified diff