Revision 34444

View differences:

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/DefaultInstallerProviderManager.java
53 53
    public static final String PROVIDERS_DESCRIPTION = "Installer providers";
54 54
    public DynObjectManager dynObjectManager = null;
55 55

  
56
    private static final String INSTALL_INFO_FILE = "package.info";
57

  
56 58
    public DefaultInstallerProviderManager() {
57 59
        super();
58 60
        this.dynObjectManager = ToolsLocator.getDynObjectManager();
......
93 95
        return new DefaultInstallerProviderServices();
94 96
    }
95 97

  
98
    public String getPackageInfoFileName() {
99
        return INSTALL_INFO_FILE;
100
    }
96 101
}
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/DefaultPackageInfo.java
235 235
        return this;
236 236
    }
237 237

  
238
    @Override
239
    public Object clone() throws CloneNotSupportedException {
240
        DefaultPackageInfo clone = (DefaultPackageInfo) super.clone();
241
        clone.selectedFiles = new ArrayList<File>(selectedFiles);
242
        return clone;
243
    }
238 244
}
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/DefaultInstallerManager.java
56 56
	private ExtensionPointManager extensionPoints = ToolsLocator
57 57
			.getExtensionPointManager();
58 58

  
59
	private String packageSetNameFormat = "gvSIG-desktop-{0}-{1}-{2}-{3,number,#}-{4}-{5}-{6}-{7}.gvspks";
59
    private String packageSetNameFormat =
60
        "gvSIG-desktop-{0}-{1}-{2}-{3,number,#}-{4}-{5}-{6}-{7}.gvspks";
60 61

  
61
	private String packageNameFormat = "gvSIG-desktop-{0}-{1}-{2}-{3,number,#}-{4}-{5}-{6}-{7}.gvspkg";
62
    private String packageNameFormat =
63
        "gvSIG-desktop-{0}-{1}-{2}-{3,number,#}-{4}-{5}-{6}-{7}.gvspkg";
62 64

  
65
    private String packageIndexNameFormat =
66
        "gvSIG-desktop-{0}-{1}-{2}-{3,number,#}-{4}-{5}-{6}-{7}.gvspki";
67

  
63 68
	public DefaultInstallerManager() {
64 69
		super(new DefaultInstallerProviderManager());
65 70
	}
......
80 85
		this.packageNameFormat = packageNameFormat;
81 86
	}
82 87

  
83
	public MakePluginPackageService getMakePluginPackageService(
88
    public String getPackageIndexNameFormat() {
89
        return packageIndexNameFormat;
90
    }
91

  
92
    public void setPackageIndexNameFormat(String packageIndexNameFormat) {
93
        this.packageIndexNameFormat = packageIndexNameFormat;
94
    }
95

  
96
    public MakePluginPackageService getMakePluginPackageService(
84 97
			File pluginsDirectory) throws MakePluginPackageServiceException {
85 98
		ExtensionPoint ep = extensionPoints
86 99
				.add(INSTALLER_MANAGER_EXTENSION_POINT);
......
139 152
		return MessageFormat.format(getPackageNameFormat(), parameters);
140 153
	}
141 154

  
155
    public String getPackageIndexFileName(PackageInfo info) {
156
        Object[] parameters = getPackageNameFormatParameters(info);
157
        return MessageFormat.format(getPackageIndexNameFormat(), parameters);
158
    }
159

  
142 160
	private Object[] getPackageNameFormatParameters(PackageInfo info) {
143 161
		Object[] parameters = new Object[8];
144 162
		parameters[PACKAGE_FILE_NAME_FIELDS.GVSIG_VERSION] = info
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/utils/Decompress.java
48 48
import org.gvsig.installer.lib.impl.DefaultPackageInfo;
49 49
import org.gvsig.installer.lib.impl.info.InstallerInfoFileReader;
50 50
import org.gvsig.installer.lib.spi.InstallerInfoFileException;
51
import org.gvsig.installer.lib.spi.InstallerProviderLocator;
51 52

  
52 53
/**
53 54
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
......
208 209
        throws ZipException, IOException, InstallerInfoFileException {
209 210
        ZipEntry entry = null;
210 211
        int installerInfoNumber = zipEntriesMap.size();
211

  
212
        String packageInfoName = getPackageInfoFileName();
213
        String unixPackageInfoPath = "/".concat(packageInfoName);
214
        String windowsPackageInfoPath = "\\".concat(packageInfoName);
212 215
        while ((entry = zipInputStream.getNextEntry()) != null) {
213 216
            logger.debug("Extracting: " + entry.getName());
214 217

  
215 218
            String name = entry.getName();
216
            if (name.endsWith("/package.info")
217
                || name.endsWith("\\package.info")) {
219
            // Just in case, but we are going to create them always using
220
            // the unix file separator
221
            if (name.endsWith(unixPackageInfoPath)
222
                || name.endsWith(windowsPackageInfoPath)) {
218 223
                PackageInfo installerInfo = readInstallInfo(zipInputStream);
219 224
                zipEntriesMap.put(installerInfo, zipEntryName);
220 225
                readedIinstallerInfos.add(installerInfo);
......
318 323

  
319 324
        return installerInfo;
320 325
    }
326

  
327
    private String getPackageInfoFileName() {
328
        return InstallerProviderLocator.getProviderManager()
329
            .getPackageInfoFileName();
330
    }
321 331
}
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/utils/Compress.java
38 38
import java.util.zip.ZipEntry;
39 39
import java.util.zip.ZipOutputStream;
40 40

  
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

  
44 41
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
42
import org.gvsig.installer.lib.spi.InstallerProviderLocator;
45 43

  
46 44
/**
47 45
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
48 46
 */
49 47
public class Compress {
50 48

  
51
    static final int BUFFER = 2048;
52
    private static final Logger logger = LoggerFactory
53
        .getLogger(Compress.class);
49
    private static final int BUFFER = 2048;
54 50

  
55
    public Compress() {
56
        super();
57
    }
58

  
59 51
    public void compressPluginAsPackageSet(File file, String fileName,
60 52
        OutputStream os) throws MakePluginPackageServiceException {
61 53
        List<File> files = new ArrayList<File>();
......
92 84
            }
93 85
            zos.close();
94 86
        } catch (Exception e) {
95
            logger.error("Error compressing the plugin");
96 87
            throw new MakePluginPackageServiceException(
97
                "Error writing the plugin", e);
88
                "Error compressing as package set the plugin files: " + files,
89
                e);
98 90
        }
99 91
    }
100 92

  
......
108 100
            zos.close();
109 101
        } catch (IOException e) {
110 102
            throw new MakePluginPackageServiceException(
111
                "Error compressing the plugin folder: " + folder, e);
103
                "Error compressing as package the plugin folder: " + folder, e);
112 104
        }
113 105
    }
114 106

  
107
    public void compressPluginAsPackageIndex(File folder, OutputStream os)
108
        throws MakePluginPackageServiceException {
109
        ZipOutputStream zos = new ZipOutputStream(os);
110
        try {
111
            int parentFileLength = folder.getParentFile().toString().length();
112
            String folderName =
113
                folder.toString()
114
                    .substring(parentFileLength + 1, folder.toString().length());
115
            
116
            File infoFile =
117
                new File(folder, getPackageInfoFileName() + ".index");
118

  
119
            byte[] buf = new byte[1024];
120
            int len;
121

  
122
            ZipEntry zipEntry =
123
                new ZipEntry(folderName + File.separator
124
                    + getPackageInfoFileName());
125
            zos.putNextEntry(zipEntry);
126

  
127
            FileInputStream fin = new FileInputStream(infoFile);
128
            BufferedInputStream in = new BufferedInputStream(fin);
129
            while ((len = in.read(buf)) >= 0) {
130
                zos.write(buf, 0, len);
131
            }
132
            in.close();
133
            zos.closeEntry();
134
            zos.flush();
135
            zos.close();
136
        } catch (IOException e) {
137
            throw new MakePluginPackageServiceException(
138
                "Error compressing as package index the plugin folder: "
139
                    + folder, e);
140
        }
141
    }
142

  
115 143
    private void compressPluginFiles(File fileOrFolder, ZipOutputStream zos)
116 144
        throws IOException {
117 145
        int parentFileLenght = fileOrFolder.getParentFile().toString().length();
......
157 185
            zosPlugin.closeEntry();
158 186
        }
159 187
    }
188

  
189
    private String getPackageInfoFileName() {
190
        return InstallerProviderLocator.getProviderManager()
191
            .getPackageInfoFileName();
192
    }
160 193
}
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/DefaultInstallerProviderServices.java
53 53
import org.gvsig.installer.lib.impl.utils.Decompress;
54 54
import org.gvsig.installer.lib.spi.InstallPackageProviderServices;
55 55
import org.gvsig.installer.lib.spi.InstallerInfoFileException;
56
import org.gvsig.installer.lib.spi.InstallerProviderLocator;
56 57
import org.gvsig.tools.service.spi.AbstractProviderServices;
57 58

  
58 59
/**
......
64 65
	private static final Logger LOG = LoggerFactory
65 66
			.getLogger(DefaultInstallerProviderServices.class);
66 67

  
67
	private static final String INSTALL_INFO_FILE = "package.info";
68

  
69 68
	public void decompress(InputStream is, File outputDirectory)
70 69
			throws InstallPackageServiceException {
71 70
		Decompress decompress = new Decompress();
......
95 94
		compress.compressPluginAsPackage(folder, os);
96 95
	}
97 96

  
97
    public void compressPackageIndex(File folder, OutputStream os)
98
        throws MakePluginPackageServiceException {
99
        Compress compress = new Compress();
100
        compress.compressPluginAsPackageIndex(folder, os);
101
    }
102

  
98 103
	public void readPackageInfo(File directory, PackageInfo installerInfo)
99 104
			throws InstallerInfoFileException {
100 105
		File installInfoFile = new File(directory + File.separator
101
				+ INSTALL_INFO_FILE);
106
 + getPackageInfoFileName());
102 107
		if (installInfoFile.exists()) {
103 108
			InstallerInfoFileReader reader = new InstallerInfoFileReader();
104 109
			reader.read(installerInfo, installInfoFile.getAbsolutePath());
......
112 117
		}
113 118
	}
114 119

  
115
	public void writePackageInfo(File directory, PackageInfo installerInfo)
120
    private String getPackageInfoFileName() {
121
        return InstallerProviderLocator.getProviderManager()
122
            .getPackageInfoFileName();
123
    }
124

  
125
    public void writePackageInfo(File directory, PackageInfo packageInfo)
116 126
			throws InstallerInfoFileException {
117
		if (!directory.exists()) {
118
			throw new InstallerInfoFileException("The directory doesn't exist");
119
		}
120
		InstallerInfoFileWriter installerInfoFileWriter = new InstallerInfoFileWriter();
121
		installerInfoFileWriter.write(installerInfo, directory + File.separator
122
				+ INSTALL_INFO_FILE);
127
        writePackageInfoFile(directory, getPackageInfoFileName(), packageInfo);
123 128
	}
124 129

  
125
	public InputStream searchPackage(InputStream is, String zipEntry)
130
    public void writePackageInfoForIndex(File directory, PackageInfo packageInfo)
131
        throws InstallerInfoFileException {
132
        writePackageInfoFile(directory, getPackageInfoFileName() + ".index",
133
            packageInfo);
134
    }
135

  
136
    private void writePackageInfoFile(File directory, String fileName,
137
        PackageInfo installerInfo) throws InstallerInfoFileException {
138
        if (!directory.exists()) {
139
            throw new InstallerInfoFileException("The directory doesn't exist");
140
        }
141
        InstallerInfoFileWriter installerInfoFileWriter =
142
            new InstallerInfoFileWriter();
143
        installerInfoFileWriter.write(installerInfo, directory + File.separator
144
            + fileName);
145
    }
146

  
147
    public InputStream searchPackage(InputStream is, String zipEntry)
126 148
			throws InstallPackageServiceException {
127 149
		Decompress decompress = new Decompress();
128 150
		return decompress.searchPlugin(is, zipEntry);
......
260 282
		// not found
261 283
		return null;
262 284
	}
263

  
264 285
}
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/DefaultMakePluginPackageService.java
195 195
				getAbsolutePluginPackageDirectory(packageInfo), packageStream);
196 196
	}
197 197

  
198
    public void createPackageIndex(PackageInfo packageInfo,
199
        OutputStream packageStream) throws MakePluginPackageServiceException {
200
        LOG.debug("Creating package index of the package info: \n{0}",
201
            packageInfo);
202

  
203
        installerProviderServices.compressPackageIndex(
204
            getAbsolutePluginPackageDirectory(packageInfo), packageStream);
205
    }
206

  
198 207
	private void writePackageInfo(PackageInfo packageInfo)
199 208
			throws MakePluginPackageServiceException {
200 209
		writePackageInfo(packageInfo,
......
206 215
		installerProviderServices.writePackageInfo(folder, packageInfo);
207 216
	}
208 217

  
218
    public void writePackageInfoForIndex(PackageInfo packageInfo, File folder)
219
        throws MakePluginPackageServiceException {
220
        installerProviderServices.writePackageInfoForIndex(folder, packageInfo);
221
    }
222

  
209 223
	private void writeAntFile(PackageInfo packageInfo)
210 224
			throws MakePluginPackageServiceException {
211 225
		try {
......
415 429
			throws MakePluginPackageServiceException {
416 430
		return installerInfos.toArray(new PackageInfo[installerInfos.size()]);
417 431
	}
432

  
433
    public File getPluginFolder(PackageInfo packageInfo)
434
        throws MakePluginPackageServiceException {
435
        return getAbsolutePluginPackageDirectory(packageInfo);
436
    }
418 437
}
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/MakePluginPackageService.java
125 125
        OutputStream packageStream) throws MakePluginPackageServiceException;
126 126

  
127 127
    /**
128
     * It creates the index for a package of a plugin. This file may be used
129
     * to be included in the main gvSIG remote index, or downloaded as it is.
130
     * 
131
     * @param packageInfo
132
     *            the information of the plugin that has to be included in the
133
     *            package index
134
     * @param packageStream
135
     *            the stream where the the package index will be created
136
     * @throws MakePluginPackageServiceException
137
     *             it is thrown when there is an exception creating the
138
     *             package
139
     */
140
    public void createPackageIndex(PackageInfo packageInfo,
141
        OutputStream packageStream) throws MakePluginPackageServiceException;
142

  
143
    /**
128 144
     * Writes a package info file with the information provided.
129 145
     * 
130 146
     * @param packageInfo
......
138 154
        throws MakePluginPackageServiceException;
139 155

  
140 156
    /**
157
     * Writes a package info file with the information provided.
158
     * 
159
     * @param packageInfo
160
     *            the package that has to be written into the file
161
     * @param folder
162
     *            the folder where the file is to be created
163
     * @throws MakePluginPackageServiceException
164
     *             it is thrown when there is an exception writing the file
165
     */
166
    public void writePackageInfoForIndex(PackageInfo packageInfo, File folder)
167
        throws MakePluginPackageServiceException;
168

  
169
    /**
141 170
     * It returns the number of plugin packages that are installed in the folder
142 171
     * that has been added using the constructor. It can be used in an iteration
143 172
     * process combined with the {@link #getPluginPackageInfo(int)} method to
......
201 230
     */
202 231
    public PackageInfo[] getInstalledPackages()
203 232
        throws MakePluginPackageServiceException;
233

  
234
    /**
235
     * Returns the folder where a plugin is located.
236
     * 
237
     * @param selectedPackageInfo
238
     *            the info of theplugin to look for
239
     * @return the plugin's folder
240
     * @throws MakePluginPackageServiceException
241
     *             if there is an error locating
242
     *             the folder
243
     */
244
    public File getPluginFolder(PackageInfo packageInfo)
245
        throws MakePluginPackageServiceException;
204 246
}
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/PackageInfo.java
34 34
import org.gvsig.installer.lib.api.InstallerManager.JVM;
35 35
import org.gvsig.installer.lib.api.InstallerManager.OS;
36 36
import org.gvsig.installer.lib.api.InstallerManager.STATE;
37
import org.gvsig.tools.lang.Cloneable;
37 38

  
38 39
/**
39 40
 * Information of a package that is used on the installation process.
......
54 55
 * 
55 56
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
56 57
 */
57
public interface PackageInfo {
58
public interface PackageInfo extends Cloneable {
58 59

  
59 60
    /**
60 61
     * @return
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/InstallerManager.java
232 232
    public String getPackageFileName(PackageInfo info);
233 233

  
234 234
    /**
235
     * Returns the name of the package index file for a given package info.
236
     * 
237
     * @param info
238
     *            of the plugin
239
     * @return the name of the package index file
240
     */
241
    public String getPackageIndexFileName(PackageInfo info);
242

  
243
    /**
235 244
     * It registers a class that implements the service for the installation
236 245
     * of a package that is inside a bundle. This class has to implement
237 246
     * the {@link InstallPackageService} interface.
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.spi/src/main/java/org/gvsig/installer/lib/spi/InstallPackageProviderServices.java
95 95
        throws MakePluginPackageServiceException;
96 96

  
97 97
    /**
98
     * Compress a plugin folder using the plugin's name as a package, only
99
     * with the files needed by the package index.
100
     * 
101
     * @param folder
102
     *            the directory to compress.
103
     * @param os
104
     *            output stream to write the output.
105
     * @throws MakePluginPackageServiceException
106
     *             if there is any problem compressing.
107
     */
108
    public void compressPackageIndex(File folder, OutputStream os)
109
        throws MakePluginPackageServiceException;
110

  
111
    /**
98 112
     * Reads the package.info file from a directory a fills the the properties
99 113
     * of the {@link PackageInfo} object.
100 114
     * 
......
160 174
        throws InstallerInfoFileException;
161 175

  
162 176
    /**
177
     * Writes the package.info file in a concrete directory to be used in
178
     * a package index.
179
     * 
180
     * @param directory
181
     *            the directory.
182
     * @param packageInfo
183
     *            the information to write.
184
     * @throws InstallerInfoFileException
185
     *             if there is any problem writing the package.info file.
186
     */
187
    public void writePackageInfoForIndex(File directory, PackageInfo packageInfo)
188
        throws InstallerInfoFileException;
189

  
190
    /**
163 191
     * It search a package inside an installer file by the zip name and returns
164 192
     * the stream in this position ready to decompres.
165 193
     * 
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.spi/src/main/java/org/gvsig/installer/lib/spi/InstallerProviderManager.java
82 82
     */
83 83
    public InstallPackageProviderServices createInstallerProviderServices();
84 84

  
85
    /**
86
     * Returns the name to use for the package info file.
87
     * 
88
     * @return the name of the package info file
89
     */
90
    public String getPackageInfoFileName();
85 91
}
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
64 64
    private WizardPanelWithLogo wizardPanelWithLogo = null;
65 65
    private MakePluginPackageService makePluginPackageService = null;
66 66
    private OutputStream outputStream = null;
67
    private OutputStream indexOutputStream;
67 68
    private PackageInfo selectedPackageInfo = null;
68 69

  
69 70
    // Wizards
......
76 77
    private SelectPlugintoInstallWizard selectPlugintoInstallWizard = null;
77 78

  
78 79
    private WizardListenerAdapter wizardListenerAdapter = null;
80
    private URL downloadURL;
79 81

  
80 82
    public DefaultMakePluginPackageWizard(File applicationFolder,
81 83
        File pluginsFolder, File installFolder) throws LocatorException,
......
113 115
        selectFilesWizard.setApplicationDirectory(applicationFolder);
114 116
    }
115 117

  
118
    public MakePluginPackageService getMakePluginPackageService() {
119
        return makePluginPackageService;
120
    }
121

  
116 122
    private void addWizards() {
117 123
        wizardPanelWithLogo.addOptionPanel(selectPlugintoInstallWizard);
118 124
        wizardPanelWithLogo.addOptionPanel(pluginDescriptionWizard);
......
178 184
        this.outputStream = outputStream;
179 185
    }
180 186

  
187
    public OutputStream getIndexOutputStream() {
188
        return indexOutputStream;
189
    }
190

  
191
    public void setIndexOutputStream(OutputStream outputStream) {
192
        this.indexOutputStream = outputStream;
193
    }
194

  
181 195
    public PackageInfo getSelectedPackageInfo() {
182 196
        return selectedPackageInfo;
183 197
    }
......
198 212
        // TODO Auto-generated method stub
199 213

  
200 214
    }
215

  
216
    public void setDownloadURL(URL downloadURL) {
217
        this.downloadURL = downloadURL;
218
    }
219

  
220
    public URL getDownloadURL() {
221
        return downloadURL;
222
    }
201 223
}
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/SelectOutputFilePanel.java
30 30
import java.awt.BorderLayout;
31 31
import java.awt.GridBagConstraints;
32 32
import java.awt.GridBagLayout;
33
import java.awt.event.ActionEvent;
34
import java.awt.event.ActionListener;
33 35
import java.io.File;
36
import java.net.MalformedURLException;
37
import java.net.URL;
34 38

  
39
import javax.swing.JCheckBox;
35 40
import javax.swing.JLabel;
36 41
import javax.swing.JPanel;
42
import javax.swing.JTextField;
37 43

  
44
import org.slf4j.Logger;
45
import org.slf4j.LoggerFactory;
46

  
38 47
import org.gvsig.gui.beans.openfile.FileTextField;
39 48
import org.gvsig.installer.swing.api.SwingInstallerLocator;
40 49
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
......
44 53
 */
45 54
public abstract class SelectOutputFilePanel extends JPanel {
46 55

  
47
    /**
48
     * 
49
     */
56
    private static final Logger LOG = LoggerFactory
57
        .getLogger(SelectOutputFilePanel.class);
50 58
    private static final long serialVersionUID = 1219577194134960697L;
59

  
51 60
    protected DefaultSwingInstallerManager swingInstallerManager = null;
52 61
    private JLabel fileLabel;
53 62
    protected FileTextField fileTextField;
63
    private JLabel createPackageIndexLabel;
64
    private JCheckBox createPackageIndexCheckBox;
65
    private JLabel packageURLLabel;
66
    protected JTextField packageURLTextField;
67
    private JLabel indexFileLabel;
68
    protected FileTextField indexFileTextField;
54 69
    private javax.swing.JPanel northPanel;
55 70

  
56 71
    public SelectOutputFilePanel() {
......
59 74
            (DefaultSwingInstallerManager) SwingInstallerLocator
60 75
                .getSwingInstallerManager();
61 76
        initComponents();
62
        initLabels();
63 77
    }
64 78

  
65
    private void initLabels() {
66
        fileLabel.setText(swingInstallerManager.getText("file") + ":");
67
    }
68

  
69 79
    private void initComponents() {
70
        java.awt.GridBagConstraints gridBagConstraints;
80
        GridBagConstraints gridBagConstraints;
71 81

  
72 82
        northPanel = new JPanel();
73
        fileLabel = new JLabel();
74
        fileTextField = new FileTextField(getClass().getName());
83
        fileLabel =
84
            new JLabel(swingInstallerManager.getText("package_file") + ":");
85
        fileTextField = new FileTextField("package.file");
86
        indexFileLabel =
87
            new JLabel(swingInstallerManager.getText("package_index_file")
88
                + ":");
75 89

  
90
        packageURLLabel =
91
            new JLabel(swingInstallerManager.getText("download_url") + ":");
92
        packageURLTextField = new JTextField();
93
        packageURLTextField.setEnabled(false);
94

  
95
        indexFileTextField = new FileTextField("package.index.file");
96
        indexFileTextField.setEnabled(false);
97
        createPackageIndexLabel =
98
            new JLabel(swingInstallerManager.getText("create_package_index")
99
                + ":");
100
        createPackageIndexCheckBox = new JCheckBox();
101
        createPackageIndexCheckBox.addActionListener(new ActionListener() {
102
            
103
            public void actionPerformed(ActionEvent e) {
104
                if (createPackageIndexCheckBox.isSelected()) {
105
                    packageURLTextField.setEnabled(true);
106
                    indexFileTextField.setEnabled(true);
107
                }
108
                else {
109
                    packageURLTextField.setEnabled(false);
110
                    indexFileTextField.setEnabled(false);
111
                }
112
                
113
            }
114
        });
115

  
76 116
        setLayout(new BorderLayout());
77 117

  
78 118
        northPanel.setLayout(new GridBagLayout());
79 119

  
80
        northPanel.add(fileLabel, new GridBagConstraints());
120
        // Package file
121
        gridBagConstraints = new GridBagConstraints();
122
        gridBagConstraints.gridx = 0;
123
        gridBagConstraints.gridy = 0;
124
        gridBagConstraints.anchor = GridBagConstraints.EAST;
125
        northPanel.add(fileLabel, gridBagConstraints);
81 126

  
82
        gridBagConstraints = new GridBagConstraints();
83 127
        gridBagConstraints.gridx = 1;
84 128
        gridBagConstraints.gridy = 0;
85 129
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
86 130
        gridBagConstraints.weightx = 1.0;
131
        gridBagConstraints.anchor = GridBagConstraints.WEST;
87 132
        northPanel.add(fileTextField, gridBagConstraints);
88 133

  
134
        // Package index check
135
        gridBagConstraints = new GridBagConstraints();
136
        gridBagConstraints.gridx = 0;
137
        gridBagConstraints.gridy = 1;
138
        gridBagConstraints.anchor = GridBagConstraints.EAST;
139
        northPanel.add(createPackageIndexLabel, gridBagConstraints);
140

  
141
        gridBagConstraints.gridx = 1;
142
        gridBagConstraints.gridy = 1;
143
        gridBagConstraints.anchor = GridBagConstraints.WEST;
144
        createPackageIndexCheckBox.setAlignmentX(LEFT_ALIGNMENT);
145
        northPanel.add(createPackageIndexCheckBox, gridBagConstraints);
146

  
147
        // Package download URL
148
        gridBagConstraints = new GridBagConstraints();
149
        gridBagConstraints.gridx = 0;
150
        gridBagConstraints.gridy = 2;
151
        gridBagConstraints.anchor = GridBagConstraints.EAST;
152
        northPanel.add(packageURLLabel, gridBagConstraints);
153

  
154
        gridBagConstraints.gridx = 1;
155
        gridBagConstraints.gridy = 2;
156
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
157
        gridBagConstraints.weightx = 1.0;
158
        gridBagConstraints.anchor = GridBagConstraints.WEST;
159
        northPanel.add(packageURLTextField, gridBagConstraints);
160

  
161
        // Package index file
162
        gridBagConstraints = new GridBagConstraints();
163
        gridBagConstraints.gridx = 0;
164
        gridBagConstraints.gridy = 3;
165
        gridBagConstraints.anchor = GridBagConstraints.EAST;
166
        northPanel.add(indexFileLabel, gridBagConstraints);
167

  
168
        gridBagConstraints.gridx = 1;
169
        gridBagConstraints.gridy = 3;
170
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
171
        gridBagConstraints.weightx = 1.0;
172
        gridBagConstraints.anchor = GridBagConstraints.WEST;
173
        northPanel.add(indexFileTextField, gridBagConstraints);
174

  
89 175
        add(northPanel, BorderLayout.NORTH);
90 176
    }
91 177

  
......
96 182
    protected void setSelectedFile(File selectedFile) {
97 183
        fileTextField.setSelectedFile(selectedFile);
98 184
    }
185

  
186
    public boolean isCreatePackageIndex() {
187
        return createPackageIndexCheckBox.isSelected();
188
    }
189

  
190
    public void setCreatePackageIndex(boolean create) {
191
        createPackageIndexCheckBox.setSelected(create);
192
    }
193

  
194
    public File getSelectedIndexFile() {
195
        if (isCreatePackageIndex()) {
196
            return indexFileTextField.getSelectedFile();
197
        } else {
198
            return null;
199
        }
200
    }
201

  
202
    protected void setSelectedIndexFile(File selectedIndexFile) {
203
        indexFileTextField.setSelectedFile(selectedIndexFile);
204
    }
205

  
206
    public URL getDownloadURL() {
207
        if (isCreatePackageIndex()) {
208
            try {
209
                return new URL(packageURLTextField.getText());
210
            } catch (MalformedURLException e) {
211
                LOG.error(
212
                    "Invalid download URL: " + packageURLTextField.getText(), e);
213
                return null;
214
            }
215
        } else {
216
            return null;
217
        }
218
    }
219

  
220
    public void setDownloadURL(URL downloadURL) {
221
        packageURLTextField.setText(downloadURL.toString());
222
    }
99 223
}
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
79 79
        try {
80 80
            installerCreationWizard.setOutputStream(new FileOutputStream(
81 81
                getSelectedFile()));
82
            if (isCreatePackageIndex()) {
83
                installerCreationWizard.setDownloadURL(getDownloadURL());
84
                installerCreationWizard
85
                    .setIndexOutputStream(new FileOutputStream(
86
                        getSelectedIndexFile()));
87
            }
82 88
        } catch (FileNotFoundException e) {
83 89
            logger.error(
84 90
                swingInstallerManager.getText("create_output_file_exception"),
......
90 96

  
91 97
    public void updatePanel() {
92 98
        setSelectedFile(getDefaultPackageBundleFile());
99
        setSelectedIndexFile(getDefaultPackageIndexBundleFile());
93 100
    }
94 101

  
95 102
    private File getDefaultPackageBundleFile() {
......
101 108
        return new File(installsFolder, fileName);
102 109
    }
103 110

  
111
    private File getDefaultPackageIndexBundleFile() {
112
        File installsFolder = installerCreationWizard.getInstallFolder();
113
        PackageInfo info = installerCreationWizard.getSelectedPackageInfo();
114
        String fileName =
115
            InstallerLocator.getInstallerManager()
116
                .getPackageIndexFileName(info);
117
        return new File(installsFolder, fileName);
118
    }
119

  
104 120
}
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.File;
31

  
30 32
import javax.swing.JPanel;
31 33

  
32 34
import org.slf4j.Logger;
......
89 91
            setCompressingText();
90 92
            installerCreationService.createPackageSet(packageInfo,
91 93
                installerCreationWizard.getOutputStream());
94
            if (installerCreationWizard.getIndexOutputStream() != null) {
95
                setCreatingIndexText();
96
                setProgress(50);
97
                PackageInfo info =
98
                    installerCreationWizard.getSelectedPackageInfo();
99
                File pluginFolder =
100
                    installerCreationWizard.getMakePluginPackageService()
101
                        .getPluginFolder(info);
102

  
103
                PackageInfo infoIndex = (PackageInfo) info.clone();
104
                infoIndex.setDownloadURL(installerCreationWizard
105
                    .getDownloadURL());
106

  
107
                installerCreationService.writePackageInfoForIndex(infoIndex,
108
                    pluginFolder);
109
                installerCreationService.createPackageIndex(info,
110
                    installerCreationWizard.getIndexOutputStream());
111
            }
92 112
            setProgress(100);
93 113

  
94 114
            // Set the finished text
......
98 118
                swingInstallerManager.getText("create_output_file_exception"),
99 119
                e);
100 120
            setExceptionText(e);
121
        } catch (CloneNotSupportedException e) {
122
            logger.error(
123
                swingInstallerManager.getText("create_output_file_exception"),
124
                e);
125
            setExceptionText(e);
101 126
        }
102

  
103 127
        setProgress(100);
104 128
        installerCreationWizard.setFinishButtonEnabled(true);
105 129
        installerCreationWizard.setCancelButtonEnabled(false);
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/panel/ProgressPanel.java
110 110
        progressLabel.setText(swingInstallerManager.getText("compressing"));
111 111
    }
112 112

  
113
    public void setCreatingIndexText() {
114
        progressLabel.setText(swingInstallerManager.getText("creating_index"));
115
    }
116

  
113 117
    public void setFinishedText() {
114 118
        progressLabel.setText(swingInstallerManager.getText("finished"));
115 119
    }
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/resources/locale/text.properties
41 41
architecture=Arquitectura
42 42
java_version=Versi?n m?nima de java
43 43
gvSIG_version=Versi?n m?nima de gvSIG
44
creating_index=Creando ?ndice del paquete de instalaci?n
45
create_package_index=?Crear ?ndice de paquete de instalaci?n?
46
package_index_file=Archivo de ?ndice de paquete
47
package_file=Archivo de paquete de instalaci?n 
44 48

  
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/resources/locale/text_en.properties
41 41
architecture=Architecture
42 42
java_version=Java minimum version
43 43
gvSIG_version=gvSIG minimum version
44
create_package_index=Create installation package index?
45
package_index_file=Index package file
46
package_file=Package file 

Also available in: Unified diff