Revision 34005

View differences:

branches/v2_0_0_prep/extensions/org.gvsig.installer.app/org.gvsig.installer.app.extension/src/main/java/org/gvsig/installer/app/extension/execution/InstallPackageExtension.java
61 61

  
62 62
        // TODO: move to user preferences or an external configuration file
63 63
        String packageDownloadURL =
64
            "http://gvsig-desktop.forge.osor.eu/gvSIG-desktop/dists/2.0.0/packages.zip";
64
            "http://gvsig-desktop.forge.osor.eu/gvSIG-desktop/dists/2.0.0/packages.gvspki";
65 65

  
66 66
        try {
67 67
            SwingInstallerLocator.getSwingInstallerManager()
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.main/src/main/java/org/gvsig/installer/main/utils/CreateBoundleFrame.java
183 183
                    fileNamesArray.add(files[i].getName());
184 184
                }
185 185
            }
186
            compress.compressPlugins(filesArray, fileNamesArray,
186
            compress.compressPluginsAsPackageSet(filesArray, fileNamesArray,
187 187
                new FileOutputStream(outputFile));
188 188
        } catch (Exception e) {
189 189
            JOptionPane.showMessageDialog(this, e.toString());
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/execution/InstallPackageService.java
167 167
     *         returns <code>null</code> if the package doesn't exist.
168 168
     */
169 169
    public PackageInfo getPackageInfo(String packageCode);
170

  
170 171
}
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
95 95
    public File getPluginsDirectory();
96 96

  
97 97
    /**
98
     * It creates a bundle with a plugin package inside.
98
     * It creates a package set with a single plugin package inside.
99 99
     * 
100 100
     * @param packageInfo
101
     *            the package that has to be included in the bundle.
102
     * @param bundleStream
103
     *            the stream where the the bundle is created.
101
     *            the information of the plugin that has to be included in the
102
     *            package set
103
     * @param packageStream
104
     *            the stream where the the package set will be created
104 105
     * @throws MakePluginPackageServiceException
105
     *             it is thrown when there is an exception creating the bundle.
106
     *             it is thrown when there is an exception creating the package
107
     *             set
106 108
     */
107
    public void createPluginPackage(PackageInfo packageInfo,
108
        OutputStream bundleStream) throws MakePluginPackageServiceException;
109
    public void createPackageSet(PackageInfo packageInfo,
110
        OutputStream packageStream) throws MakePluginPackageServiceException;
109 111

  
110 112
    /**
113
     * It creates a package of a plugin.
114
     * 
115
     * @param packageInfo
116
     *            the information of the plugin that has to be included in the
117
     *            package
118
     * @param packageStream
119
     *            the stream where the the package will be created
120
     * @throws MakePluginPackageServiceException
121
     *             it is thrown when there is an exception creating the
122
     *             package
123
     */
124
    public void createPackage(PackageInfo packageInfo,
125
        OutputStream packageStream) throws MakePluginPackageServiceException;
126

  
127
    /**
111 128
     * Writes a package info file with the information provided.
112 129
     * 
113 130
     * @param packageInfo
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
211 211
    public void setDownloadURL(URL defaultURL);
212 212

  
213 213
    /**
214
     * Returns the package info model version.
215
     * 
216
     * @return the package info model version
217
     */
218
    public String getModelVersion();
219

  
220
    /**
221
     * Sets the package info model version.
222
     * 
223
     * @param modelVersion
224
     *            the package info model version
225
     */
226
    public void setModelVersion(String modelVersion);
227

  
228
    /**
214 229
     * Add an external file that have to be copied in the
215 230
     * installation process.
216 231
     * 
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
138 138
    /**
139 139
     * Fields into the bundle file name message format.
140 140
     * 
141
     * @see InstallerManager#getPackageBundleNameFormat()
142
     * @see InstallerManager#setPackageBundleNameFormat(String)
141
     * @see InstallerManager#getPackageSetNameFormat()
142
     * @see InstallerManager#setPackageSetNameFormat(String)
143 143
     */
144
    public static interface BUNDLE_FILE_NAME_FIELDS {
144
    public static interface PACKAGE_FILE_NAME_FIELDS {
145 145

  
146 146
        static final int GVSIG_VERSION = 0;
147 147
        static final int NAME = 1;
......
202 202
     * 
203 203
     * @return the package bundle file name format.
204 204
     */
205
    public String getPackageBundleNameFormat();
205
    public String getPackageSetNameFormat();
206 206

  
207 207
    /**
208 208
     * Sets the package bundle file name format.
209 209
     * 
210
     * @see InstallerManager#getPackageBundleNameFormat()
210
     * @see InstallerManager#getPackageSetNameFormat()
211 211
     * @param packageBundleNameFormat
212 212
     *            the package bundle file name format.
213 213
     */
214
    public void setPackageBundleNameFormat(String packageBundleNameFormat);
214
    public void setPackageSetNameFormat(String packageBundleNameFormat);
215 215

  
216 216
    /**
217
     * Returns the name of the package bundle file for a given package info.
217
     * Returns the name of the package set file for a given package info.
218 218
     * 
219 219
     * @param info
220 220
     *            of the plugin
221
     * @return the name of the package bundle file
221
     * @return the name of the package set file
222 222
     */
223
    public String getPackageBundleFileName(PackageInfo info);
223
    public String getPackageSetFileName(PackageInfo info);
224 224

  
225 225
    /**
226
     * Returns the name of the package file for a given package info.
227
     * 
228
     * @param info
229
     *            of the plugin
230
     * @return the name of the package file
231
     */
232
    public String getPackageFileName(PackageInfo info);
233

  
234
    /**
226 235
     * It registers a class that implements the service for the installation
227 236
     * of a package that is inside a bundle. This class has to implement
228 237
     * the {@link InstallPackageService} interface.
......
246 255
     */
247 256
    public InstallPackageService getInstallPackageService()
248 257
        throws InstallPackageServiceException;
258

  
259
    /**
260
     * Returns the default extensions of the package files.
261
     * 
262
     * @return the default extensions of the package files
263
     */
264
    public String getDefaultPackageFileExtension();
265

  
266
    /**
267
     * Returns the default extensions of the package set files.
268
     * 
269
     * @return the default extensions of the package set files
270
     */
271
    public String getDefaultPackageSetFileExtension();
249 272
}
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
65 65
        throws InstallPackageServiceException;
66 66

  
67 67
    /**
68
     * Compress a directory like an zipped outputstream with a concrete name.
68
     * Compress a folder as a zipped package set in the given outputstream with
69
     * a concrete name.
69 70
     * 
70
     * @param directory
71
     *            the directory to compress.
71
     * @param folder
72
     *            the folder to compress.
72 73
     * @param fileName
73 74
     *            name of the zip entry that has the output file.
74 75
     *            The name that have to have
......
77 78
     * @throws MakePluginPackageServiceException
78 79
     *             if there is any problem compressing.
79 80
     */
80
    public void compress(File directory, String fileName, OutputStream os)
81
    public void compressPackageSet(File folder, String fileName, OutputStream os)
81 82
        throws MakePluginPackageServiceException;
82 83

  
83 84
    /**
85
     * Compress a plugin folder using the plugin's name as a package.
86
     * 
87
     * @param folder
88
     *            the directory to compress.
89
     * @param os
90
     *            output stream to write the output.
91
     * @throws MakePluginPackageServiceException
92
     *             if there is any problem compressing.
93
     */
94
    public void compressPackage(File folder, OutputStream os)
95
        throws MakePluginPackageServiceException;
96

  
97
    /**
84 98
     * Reads the package.info file from a directory a fills the the properties
85 99
     * of the {@link PackageInfo} object.
86 100
     * 
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/info/InstallerInfoFileWriter.java
32 32
import java.io.FileOutputStream;
33 33
import java.io.IOException;
34 34
import java.io.OutputStream;
35
import java.net.URL;
35 36
import java.util.Properties;
36 37

  
37 38
import org.gvsig.installer.lib.api.PackageInfo;
......
97 98
                installInfo.getDescription());
98 99
            properties.setProperty(InstallerInfoTags.VERSION,
99 100
                installInfo.getVersion());
100
            properties.setProperty(InstallerInfoTags.BUILD, new Integer(
101
                installInfo.getBuild()).toString());
101
            properties.setProperty(InstallerInfoTags.BUILD,
102
                Integer.toString(installInfo.getBuild()));
102 103
            properties.setProperty(InstallerInfoTags.STATE,
103 104
                installInfo.getState());
104
            properties.setProperty(InstallerInfoTags.OFFICIAL, new Boolean(
105
                installInfo.isOfficial()).toString());
105
            properties.setProperty(InstallerInfoTags.OFFICIAL,
106
                Boolean.toString(installInfo.isOfficial()));
106 107
            properties.setProperty(InstallerInfoTags.TYPE,
107 108
                installInfo.getType());
108 109
            properties.setProperty(InstallerInfoTags.OS,
......
113 114
                installInfo.getJavaVM());
114 115
            properties.setProperty(InstallerInfoTags.GVSIG_VERSION,
115 116
                installInfo.getGvSIGVersion());
116
            properties.setProperty(InstallerInfoTags.DOWNLOAD_URL, installInfo
117
                .getDownloadURL().toString());
117
            URL downloadURL = installInfo.getDownloadURL();
118
            if (downloadURL != null) {
119
                properties.setProperty(InstallerInfoTags.DOWNLOAD_URL,
120
                    downloadURL.toString());
121
            }
122
            properties.setProperty(InstallerInfoTags.MODEL_VERSION,
123
                installInfo.getModelVersion());
118 124
            properties.store(os, "");
119 125
            os.close();
120 126
        } catch (IOException e) {
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/info/InstallerInfoTags.java
45 45
    public static final String JVM = "java-version";
46 46
    public static final String GVSIG_VERSION = "gvSIG-version";
47 47
    public static final String DOWNLOAD_URL = "download-url";
48
    public static final String MODEL_VERSION = "model-version";
48 49
}
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/info/InstallerInfoFileReader.java
169 169
            }
170 170
            installerInfoResource.setDownloadURL(downloadURL);
171 171
        }
172

  
173
        String modelVersion =
174
            properties.getProperty(InstallerInfoTags.MODEL_VERSION);
175
        if (modelVersion != null) {
176
            installerInfoResource.setModelVersion(modelVersion);
177
        }
172 178
    }
173 179

  
174 180
}
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
62 62

  
63 63
    private URL defaultDownloadURL = null;
64 64

  
65
    private String modelVersion = "1.0.0";
66

  
65 67
    public DefaultPackageInfo() {
66 68
        super();
67 69
        selectedFiles = new ArrayList<File>();
......
195 197
        this.defaultDownloadURL = defaultDownloadURL;
196 198
    }
197 199

  
200
    public String getModelVersion() {
201
        return modelVersion;
202
    }
203

  
204
    public void setModelVersion(String modelVersion) {
205
        this.modelVersion = modelVersion;
206
    }
207

  
198 208
}
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
59 59
    private ExtensionPointManager extensionPoints = ToolsLocator
60 60
        .getExtensionPointManager();
61 61

  
62
    private String packageBundleNameFormat =
63
        "gvSIG-desktop-{0}-{1}-{2}-{3,number,#}-{4}-{5}-{6}-{7}.zip";
62
    private String packageSetNameFormat =
63
        "gvSIG-desktop-{0}-{1}-{2}-{3,number,#}-{4}-{5}-{6}-{7}.gvspks";
64 64

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

  
65 68
    public DefaultInstallerManager() {
66 69
        super(new DefaultInstallerProviderManager());
67 70
    }
68 71

  
69
    public String getPackageBundleNameFormat() {
70
        return packageBundleNameFormat;
72
    public String getPackageSetNameFormat() {
73
        return packageSetNameFormat;
71 74
    }
72 75

  
73
    public void setPackageBundleNameFormat(String packageBundleNameFormat) {
74
        this.packageBundleNameFormat = packageBundleNameFormat;
76
    public void setPackageSetNameFormat(String packageSetNameFormat) {
77
        this.packageSetNameFormat = packageSetNameFormat;
75 78
    }
76 79

  
80
    public String getPackageNameFormat() {
81
        return packageNameFormat;
82
    }
83

  
84
    public void setPackageNameFormat(String packageNameFormat) {
85
        this.packageNameFormat = packageNameFormat;
86
    }
87

  
77 88
    public MakePluginPackageService getMakePluginPackageService(
78 89
        File pluginsDirectory) throws MakePluginPackageServiceException {
79 90
        ExtensionPoint ep =
......
125 136
        return null;
126 137
    }
127 138

  
128
    public String getPackageBundleFileName(PackageInfo info) {
139
    public String getPackageSetFileName(PackageInfo info) {
140
        Object[] parameters = getPackageNameFormatParameters(info);
141
        return MessageFormat.format(getPackageSetNameFormat(), parameters);
142
    }
143

  
144
    public String getPackageFileName(PackageInfo info) {
145
        Object[] parameters = getPackageNameFormatParameters(info);
146
        return MessageFormat.format(getPackageNameFormat(), parameters);
147
    }
148

  
149
    private Object[] getPackageNameFormatParameters(PackageInfo info) {
129 150
        Object[] parameters = new Object[8];
130
        parameters[BUNDLE_FILE_NAME_FIELDS.GVSIG_VERSION] =
151
        parameters[PACKAGE_FILE_NAME_FIELDS.GVSIG_VERSION] =
131 152
            info.getGvSIGVersion();
132
        parameters[BUNDLE_FILE_NAME_FIELDS.NAME] = info.getCode();
133
        parameters[BUNDLE_FILE_NAME_FIELDS.VERSION] = info.getVersion();
134
        parameters[BUNDLE_FILE_NAME_FIELDS.BUILD] = info.getBuild();
135
        parameters[BUNDLE_FILE_NAME_FIELDS.STATE] = info.getState();
136
        parameters[BUNDLE_FILE_NAME_FIELDS.OS] = info.getOperatingSystem();
137
        parameters[BUNDLE_FILE_NAME_FIELDS.ARCH] = info.getArchitecture();
138
        parameters[BUNDLE_FILE_NAME_FIELDS.JVM] = info.getJavaVM();
139
        return MessageFormat.format(getPackageBundleNameFormat(), parameters);
153
        parameters[PACKAGE_FILE_NAME_FIELDS.NAME] = info.getCode();
154
        parameters[PACKAGE_FILE_NAME_FIELDS.VERSION] = info.getVersion();
155
        parameters[PACKAGE_FILE_NAME_FIELDS.BUILD] = info.getBuild();
156
        parameters[PACKAGE_FILE_NAME_FIELDS.STATE] = info.getState();
157
        parameters[PACKAGE_FILE_NAME_FIELDS.OS] = info.getOperatingSystem();
158
        parameters[PACKAGE_FILE_NAME_FIELDS.ARCH] = info.getArchitecture();
159
        parameters[PACKAGE_FILE_NAME_FIELDS.JVM] = info.getJavaVM();
160
        return parameters;
140 161
    }
141 162

  
142 163
    public PackageInfo[] getInstalledPackages(File pluginsDirectory)
......
145 166
            getMakePluginPackageService(pluginsDirectory);
146 167
        return service.getInstalledPackages();
147 168
    }
169

  
170
    public String getDefaultPackageFileExtension() {
171
        return "gvspkg";
172
    }
173

  
174
    public String getDefaultPackageSetFileExtension() {
175
        return "gvspks";
176
    }
148 177
}
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
56 56
        super();
57 57
    }
58 58

  
59
    public void compressPlugin(File file, String fileName, OutputStream os)
60
        throws MakePluginPackageServiceException {
59
    public void compressPluginAsPackageSet(File file, String fileName,
60
        OutputStream os) throws MakePluginPackageServiceException {
61 61
        ArrayList<File> files = new ArrayList<File>();
62 62
        ArrayList<String> fileNames = new ArrayList<String>();
63 63
        files.add(file);
64 64
        fileNames.add(fileName);
65
        compressPlugins(files, fileNames, os);
65
        compressPluginsAsPackageSet(files, fileNames, os);
66 66
    }
67 67

  
68
    public void compressPlugins(File directory, OutputStream os)
68
    public void compressPluginsAsPackageSet(File directory, OutputStream os)
69 69
        throws MakePluginPackageServiceException {
70 70
        File[] files = directory.listFiles();
71 71
        List<File> filesArray = new ArrayList<File>();
......
74 74
            filesArray.add(files[i]);
75 75
            fileNamesArray.add(files[i].getName());
76 76
        }
77
        compressPlugins(filesArray, fileNamesArray, os);
77
        compressPluginsAsPackageSet(filesArray, fileNamesArray, os);
78 78
    }
79 79

  
80
    public void compressPlugins(List<File> files, List<String> fileNames,
81
        OutputStream os) throws MakePluginPackageServiceException {
80
    public void compressPluginsAsPackageSet(List<File> files,
81
        List<String> fileNames, OutputStream os)
82
        throws MakePluginPackageServiceException {
82 83
        try {
83 84
            ZipOutputStream zos =
84 85
                new ZipOutputStream(new BufferedOutputStream(os));
85 86

  
86 87
            for (int i = 0; i < files.size(); i++) {
87
                File file = files.get(i);
88

  
89
                int parentFileLenght = file.getParentFile().toString().length();
90

  
91 88
                ZipEntry zipEntry = new ZipEntry(fileNames.get(i));
92 89
                zos.putNextEntry(zipEntry);
93

  
94
                ZipOutputStream zosPlugin = new ZipOutputStream(zos);
95
                compressPluginFile(file, parentFileLenght, zosPlugin);
96
                zosPlugin.finish();
97

  
90
                compressPluginFiles(files.get(i), zos);
98 91
                zos.closeEntry();
99 92
            }
100 93
            zos.close();
......
105 98
        }
106 99
    }
107 100

  
101
    public void compressPluginAsPackage(File folder, OutputStream os)
102
        throws MakePluginPackageServiceException {
103
        ZipOutputStream zos = new ZipOutputStream(os);
104
        try {
105
            ZipEntry zipEntry = new ZipEntry(folder.getName());
106
            zos.putNextEntry(zipEntry);
107
            compressPluginFiles(folder, zos);
108
            zos.closeEntry();
109
            zos.flush();
110
            zos.close();
111
        } catch (IOException e) {
112
            throw new MakePluginPackageServiceException(
113
                "Error compressing the plugin folder: " + folder, e);
114
        }
115
    }
116

  
117
    private void compressPluginFiles(File fileOrFolder, ZipOutputStream zos)
118
        throws IOException {
119
        int parentFileLenght = fileOrFolder.getParentFile().toString().length();
120
        ZipOutputStream zosPlugin = new ZipOutputStream(zos);
121
        compressPluginFile(fileOrFolder, parentFileLenght, zosPlugin);
122
        zosPlugin.finish();
123
    }
124

  
108 125
    private void compressPluginFile(File file, int parenFileLength,
109 126
        ZipOutputStream zosPlugin) throws IOException {
110 127
        String fileName =
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
83 83
        }
84 84
    }
85 85

  
86
    public void compress(File directory, String fileName, OutputStream os)
86
    public void compressPackageSet(File folder, String fileName,
87
        OutputStream os)
87 88
        throws MakePluginPackageServiceException {
88 89
        Compress compress = new Compress();
89
        compress.compressPlugin(directory, fileName, os);
90
        compress.compressPluginAsPackageSet(folder, fileName, os);
91
    }
90 92

  
93
    public void compressPackage(File folder, OutputStream os)
94
        throws MakePluginPackageServiceException {
95
        Compress compress = new Compress();
96
        compress.compressPluginAsPackage(folder, os);
91 97
    }
92 98

  
93 99
    public void readPackageInfo(File directory, PackageInfo installerInfo)
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/DefaultInstallPackageService.java
29 29

  
30 30
import java.io.BufferedInputStream;
31 31
import java.io.File;
32
import java.io.FileFilter;
32 33
import java.io.FileInputStream;
33 34
import java.io.FileNotFoundException;
34 35
import java.io.IOException;
......
42 43
import org.slf4j.Logger;
43 44
import org.slf4j.LoggerFactory;
44 45

  
46
import org.gvsig.installer.lib.api.InstallerManager;
45 47
import org.gvsig.installer.lib.api.PackageInfo;
46 48
import org.gvsig.installer.lib.api.execution.InstallPackageService;
47 49
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
......
61 63
    private Map<PackageInfo, File> packageInfoFileMap = null;
62 64
    private Map<PackageInfo, String> zipEntriesMap = null;
63 65
    private List<PackageInfo> packageInfos = null;
64
    private Manager manager;
66
    private InstallerManager manager;
65 67
    private static final Logger logger = LoggerFactory
66 68
        .getLogger(DefaultInstallPackageService.class);
67 69
    private InstallPackageProviderServices installerProviderServices = null;
......
185 187
    }
186 188

  
187 189
    public void addBundle(URL bundleURL) throws InstallPackageServiceException {
188
        File bundle = downloadFile(bundleURL, "packages.zip");
190
        File bundle = downloadFile(bundleURL, "packages.gvspki");
189 191
        addBundle(bundle);
190 192
    }
191 193

  
......
207 209
            throw new InstallPackageServiceException(
208 210
                "The application directory has to be a directory");
209 211
        }
210
        File[] files = directory.listFiles();
212
        File[] files = directory.listFiles(new FileFilter() {
213
            
214
            private String packageExt = manager.getDefaultPackageFileExtension();
215
            private String packageSetExt = manager
216
                .getDefaultPackageSetFileExtension();
217
            
218
            public boolean accept(File file) {
219
                String name = file.getName().toLowerCase();
220
                return name.endsWith(packageExt)
221
                    || name.endsWith(packageSetExt);
222
            }
223
        });
211 224
        for (int i = 0; i < files.length; i++) {
212 225
            if (files[i].isFile()) {
213 226
                addBundle(files[i]);
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
156 156
        }
157 157
    }
158 158

  
159
    public void createPluginPackage(PackageInfo packageInfo,
160
        OutputStream installerStream) throws MakePluginPackageServiceException {
159
    public void createPackageSet(PackageInfo packageInfo,
160
        OutputStream packageStream) throws MakePluginPackageServiceException {
161 161

  
162
        writeAdditionalFiles(packageInfo);
163
        String pluginFileName = manager.getPackageFileName(packageInfo);
164
        installerProviderServices.compressPackageSet(
165
            getAbsolutePluginPackageDirectory(packageInfo), pluginFileName,
166
            packageStream);
167
    }
168

  
169
    private void writeAdditionalFiles(PackageInfo packageInfo)
170
        throws MakePluginPackageServiceException {
162 171
        // Write the package.info file
163 172
        writePackageInfo(packageInfo);
164 173

  
......
169 178
            // Copy the selected files
170 179
            writeSelectedFiles(packageInfo);
171 180
        }
181
    }
172 182

  
173
        String pluginFileName = manager.getPackageBundleFileName(packageInfo);
174
        installerProviderServices.compress(
175
            getAbsolutePluginPackageDirectory(packageInfo), pluginFileName,
176
            installerStream);
183
    public void createPackage(PackageInfo packageInfo,
184
        OutputStream packageStream) throws MakePluginPackageServiceException {
185

  
186
        writeAdditionalFiles(packageInfo);
187
        installerProviderServices.compressPackage(
188
            getAbsolutePluginPackageDirectory(packageInfo), packageStream);
177 189
    }
178 190

  
179 191
    private void writePackageInfo(PackageInfo packageInfo)
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/test/java/org/gvsig/installer/lib/impl/creation/MakePluginPackageServiceTest.java
104 104

  
105 105
        // Compress the plugin and create the installer compressed file
106 106
        FileOutputStream os = new FileOutputStream(installerFile);
107
        makePluginPackageService.createPluginPackage(packageInfo, os);
107
        makePluginPackageService.createPackageSet(packageInfo, os);
108 108

  
109 109
        // decompress the plugin and read the plugin information
110 110
        InstallPackageService installPackageService =
......
133 133

  
134 134
        // Compress the plugin and create the installer compressed file
135 135
        FileOutputStream os = new FileOutputStream(installerFile);
136
        makePluginPackageService.createPluginPackage(packageInfo, os);
136
        makePluginPackageService.createPackageSet(packageInfo, os);
137 137

  
138 138
        // decompress the plugin and read the plugin information
139 139
        InstallPackageService installPackageService =
......
164 164

  
165 165
        // Compress the plugin and create the installer compressed file
166 166
        FileOutputStream os = new FileOutputStream(installerFile);
167
        makePluginPackageService.createPluginPackage(packageInfo, os);
167
        makePluginPackageService.createPackageSet(packageInfo, os);
168 168

  
169 169
        // decompress the plugin and read the plugin information
170 170
        InstallPackageService installPackageService =
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.maven/src/main/java/org/gvsig/installer/maven/GenerateInstallerMojo.java
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
package org.gvsig.installer.maven;
23

  
24
import java.io.BufferedOutputStream;
25
import java.io.File;
26
import java.io.FileNotFoundException;
27
import java.io.FileOutputStream;
28
import java.io.IOException;
29

  
30
import org.apache.maven.plugin.AbstractMojo;
31
import org.apache.maven.plugin.MojoExecutionException;
32
import org.apache.maven.plugin.MojoFailureException;
33
import org.apache.maven.plugin.logging.Log;
34

  
35
import org.gvsig.installer.lib.api.InstallerLocator;
36
import org.gvsig.installer.lib.api.InstallerManager;
37
import org.gvsig.installer.lib.api.PackageInfo;
38
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
39
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
40
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
41
import org.gvsig.tools.locator.LocatorException;
42

  
43
/**
44
 * Maven mojo to launch the gvSIG installer to generate a installation
45
 * bundle of a gvSIG plugin.
46
 * <p>
47
 * Look at the <a href=
48
 * "http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/anexos/proyectos-oficiales-en-gvsig/nombrado-de-binarios-para-un-plugin-de-gvsig"
49
 * >gvSIG plugin naming standard</a> for information about installers naming and
50
 * versioning.
51
 * </p>
52
 * 
53
 * @see InstallerManager
54
 * 
55
 * @author gvSIG Team
56
 * @version $Id$
57
 * 
58
 * @goal create-installer
59
 */
60
public class GenerateInstallerMojo extends AbstractMojo {
61

  
62
    /**
63
     * Location of the gvSIG plugins folder.
64
     * 
65
     * @parameter
66
     * @required
67
     */
68
    private File pluginsFolder;
69

  
70
    /**
71
     * Location of the folder where to create the package bundle file.
72
     * 
73
     * @parameter
74
     * @required
75
     */
76
    private File bundleFolder;
77

  
78
    /**
79
     * Name of the package bundle file. If not provided, the
80
     * official gvSIG name will be used, as provided by
81
     * the org.gvsig.installer.lib.api.InstallerManager.
82
     * 
83
     * @parameter
84
     */
85
    private String bundleFileName;
86

  
87
    /**
88
     * Plugin project artifactId or code, used as gvSIG plugin name.
89
     * 
90
     * @parameter expression="${project.artifactId}"
91
     * @required
92
     */
93
    private String artifactId;
94

  
95
    /**
96
     * Plugin project packaging, to check it is of jar type.
97
     * 
98
     * @parameter expression="${project.packaging}"
99
     * @required
100
     */
101
    private String packaging;
102

  
103
    /**
104
     * If the mojo execution is disabled. Useful for projects that inherit
105
     * the maven plugin configuration but don't generate installer.
106
     * 
107
     * @parameter
108
     */
109
    private boolean disabled = false;
110

  
111
    public void execute() throws MojoExecutionException, MojoFailureException {
112
        Log log = getLog();
113

  
114
        if (disabled) {
115
            log.info("Installer generation disabled.");
116
            return;
117
        }
118

  
119
        if (!"jar".equals(packaging)) {
120
            log.info("Running on a project with packaging of type " + packaging
121
                + ". Do nothing, as we only create installers for projects "
122
                + "with jar packaging");
123
            return;
124
        }
125

  
126
        log.info("Generating a installable for the plugin: " + artifactId
127
            + " with the following information:");
128
        log.info("\tgvSIG Plugin's folder: " + pluginsFolder);
129
        log.info("\tBundle installation file to create: " + bundleFolder);
130

  
131
        File packageBundleFile = null;
132

  
133
        try {
134
            new DefaultLibrariesInitializer().fullInitialize();
135

  
136
            InstallerManager manager = InstallerLocator.getInstallerManager();
137

  
138
            MakePluginPackageService makePluginService =
139
                manager.getMakePluginPackageService(pluginsFolder);
140

  
141
            // Get and fill the package info data
142
            PackageInfo info =
143
                makePluginService.getPluginPackageInfo(artifactId);
144

  
145
            // Create the package bundle file
146
            String packageBundleFileName =
147
                bundleFileName == null ? manager.getPackageBundleFileName(info)
148
                    : bundleFileName;
149

  
150
            if (!bundleFolder.exists()) {
151
                bundleFolder.mkdirs();
152
            }
153
            packageBundleFile = new File(bundleFolder, packageBundleFileName);
154

  
155
            FileOutputStream fos = new FileOutputStream(packageBundleFile);
156
            BufferedOutputStream bos = new BufferedOutputStream(fos);
157

  
158
            makePluginService.createPluginPackage(info, bos);
159

  
160
            bos.flush();
161
            bos.close();
162
            fos.close();
163
        } catch (LocatorException e) {
164
            throw new MojoExecutionException(
165
                "Error getting a reference to the InstallerManager", e);
166
        } catch (MakePluginPackageServiceException e) {
167
            throw new MojoExecutionException(
168
                "Error getting a MakePluginPackageService for the "
169
                    + "plugin folder: " + pluginsFolder, e);
170
        } catch (FileNotFoundException e) {
171
            throw new MojoExecutionException(
172
                "Error creating the bundle installation file: "
173
                    + packageBundleFile, e);
174
        } catch (IOException e) {
175
            throw new MojoExecutionException(
176
                "I/O error writing the bundle installation file: "
177
                    + packageBundleFile, e);
178
        }
179

  
180
        log.info("Bundle installation file created successfully");
181
    }
182
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.maven/src/main/java/org/gvsig/installer/maven/GeneratePluginPackageSetMojo.java
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
package org.gvsig.installer.maven;
23

  
24
import java.io.OutputStream;
25

  
26
import org.gvsig.installer.lib.api.InstallerLocator;
27
import org.gvsig.installer.lib.api.InstallerManager;
28
import org.gvsig.installer.lib.api.PackageInfo;
29
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
30
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
31

  
32
/**
33
 * Maven mojo to launch the gvSIG installer to generate a installation
34
 * bundle of a gvSIG plugin.
35
 * <p>
36
 * Look at the <a href=
37
 * "http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/anexos/proyectos-oficiales-en-gvsig/nombrado-de-binarios-para-un-plugin-de-gvsig"
38
 * >gvSIG plugin naming standard</a> for information about installers naming and
39
 * versioning.
40
 * </p>
41
 * 
42
 * @see InstallerManager
43
 * 
44
 * @author gvSIG Team
45
 * @version $Id$
46
 * 
47
 * @goal create-package-set
48
 */
49
public class GeneratePluginPackageSetMojo extends AbstractGeneratePackageMojo {
50

  
51
    @Override
52
    protected void createPackage(MakePluginPackageService makePluginService,
53
        PackageInfo info, OutputStream os)
54
        throws MakePluginPackageServiceException {
55
        makePluginService.createPackageSet(info, os);
56
    }
57

  
58
    @Override
59
    protected String getPackageTypeName() {
60
        return "Package Set";
61
    }
62

  
63
    @Override
64
    protected String getPackageFileName(PackageInfo info) {
65
        return InstallerLocator.getInstallerManager().getPackageSetFileName(
66
            info);
67
    }
68
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.maven/src/main/java/org/gvsig/installer/maven/GeneratePluginPackageMojo.java
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
package org.gvsig.installer.maven;
23

  
24
import java.io.OutputStream;
25

  
26
import org.gvsig.installer.lib.api.InstallerLocator;
27
import org.gvsig.installer.lib.api.InstallerManager;
28
import org.gvsig.installer.lib.api.PackageInfo;
29
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
30
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
31

  
32
/**
33
 * Maven mojo to launch the gvSIG installer to generate a package of a gvSIG
34
 * plugin.
35
 * <p>
36
 * Look at the <a href=
37
 * "http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/anexos/proyectos-oficiales-en-gvsig/nombrado-de-binarios-para-un-plugin-de-gvsig"
38
 * >gvSIG plugin naming standard</a> for information about installers naming and
39
 * versioning.
40
 * </p>
41
 * 
42
 * @see InstallerManager
43
 * 
44
 * @author gvSIG Team
45
 * @version $Id$
46
 * 
47
 * @goal create-package
48
 */
49
public class GeneratePluginPackageMojo extends AbstractGeneratePackageMojo {
50

  
51
    @Override
52
    protected void createPackage(MakePluginPackageService makePluginService,
53
        PackageInfo info, OutputStream os)
54
        throws MakePluginPackageServiceException {
55
        makePluginService.createPackage(info, os);
56
    }
57

  
58
    @Override
59
    protected String getPackageTypeName() {
60
        return "Package";
61
    }
62

  
63
    @Override
64
    protected String getPackageFileName(PackageInfo info) {
65
        return InstallerLocator.getInstallerManager().getPackageFileName(info);
66
    }
67
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.maven/src/main/java/org/gvsig/installer/maven/AbstractGeneratePackageMojo.java
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
package org.gvsig.installer.maven;
23

  
24
import java.io.BufferedOutputStream;
25
import java.io.File;
26
import java.io.FileNotFoundException;
27
import java.io.FileOutputStream;
28
import java.io.IOException;
29
import java.io.OutputStream;
30

  
31
import org.apache.maven.plugin.AbstractMojo;
32
import org.apache.maven.plugin.MojoExecutionException;
33
import org.apache.maven.plugin.MojoFailureException;
34
import org.apache.maven.plugin.logging.Log;
35

  
36
import org.gvsig.installer.lib.api.InstallerLocator;
37
import org.gvsig.installer.lib.api.InstallerManager;
38
import org.gvsig.installer.lib.api.PackageInfo;
39
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
40
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
41
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
42
import org.gvsig.tools.locator.LocatorException;
43

  
44
/**
45
 * Abstract Maven mojo to launch the gvSIG installer to generate a package of a
46
 * gvSIG plugin.
47
 * <p>
48
 * Look at the <a href=
49
 * "http://www.gvsig.org/web/projects/gvsig-desktop/docs/devel/gvsig-devel-guide/2.0.0/anexos/proyectos-oficiales-en-gvsig/nombrado-de-binarios-para-un-plugin-de-gvsig"
50
 * >gvSIG plugin naming standard</a> for information about installers naming and
51
 * versioning.
52
 * </p>
53
 * 
54
 * @see InstallerManager
55
 * 
56
 * @author gvSIG Team
57
 * @version $Id$
58
 */
59
public abstract class AbstractGeneratePackageMojo extends AbstractMojo {
60

  
61
    /**
62
     * Location of the gvSIG plugins folder.
63
     * 
64
     * @parameter
65
     * @required
66
     */
67
    private File pluginsFolder;
68

  
69
    /**
70
     * Location of the folder where to create the package file.
71
     * 
72
     * @parameter
73
     * @required
74
     */
75
    private File packageFolder;
76

  
77
    /**
78
     * Name of the package file. If not provided, the
79
     * official gvSIG name will be used, as provided by
80
     * the org.gvsig.installer.lib.api.InstallerManager.
81
     * 
82
     * @parameter
83
     */
84
    private String packageFileName;
85

  
86
    /**
87
     * Plugin project artifactId or code, used as gvSIG plugin name.
88
     * 
89
     * @parameter expression="${project.artifactId}"
90
     * @required
91
     */
92
    private String artifactId;
93

  
94
    /**
95
     * Plugin project packaging, to check it is of jar type.
96
     * 
97
     * @parameter expression="${project.packaging}"
98
     * @required
99
     */
100
    private String packaging;
101

  
102
    /**
103
     * If the mojo execution is disabled. Useful for projects that inherit
104
     * the maven plugin configuration but don't generate installer.
105
     * 
106
     * @parameter
107
     */
108
    private boolean disabled = false;
109

  
110
    public void execute() throws MojoExecutionException, MojoFailureException {
111
        String packageName;
112
        MakePluginPackageService makePluginService;
113
        File packageBundleFile = null;
114

  
115
        Log log = getLog();
116

  
117
        if (disabled) {
118
            log.info(getPackageTypeName() + " generation disabled.");
119
            return;
120
        }
121

  
122
        if (!"jar".equals(packaging)) {
123
            log.info("Running on a project with packaging of type " + packaging
124
                + ". Do nothing, as we only create installers for projects "
125
                + "with jar packaging");
126
            return;
127
        }
128

  
129
        log.info("Generating a " + getPackageTypeName() + " for the plugin: "
130
            + artifactId + " with the following information:");
131
        log.info("\tgvSIG Plugin's folder: " + pluginsFolder);
132
        log.info("\tPackage file destination folder: " + packageFolder);
133

  
134
        try {
135
            new DefaultLibrariesInitializer().fullInitialize();
136

  
137
            InstallerManager manager = InstallerLocator.getInstallerManager();
138

  
139
            makePluginService =
140
                manager.getMakePluginPackageService(pluginsFolder);
141
        } catch (LocatorException e) {
142
            throw new MojoExecutionException(
143
                "Error getting a reference to the InstallerManager", e);
144
        } catch (MakePluginPackageServiceException e) {
145
            throw new MojoExecutionException(
146
                "Error getting a MakePluginPackageService for the "
147
                    + "plugin folder: " + pluginsFolder, e);
148
        }
149

  
150
        // Get and fill the package info data
151
        PackageInfo info = makePluginService.getPluginPackageInfo(artifactId);
152

  
153
        // Create the package bundle file
154
        packageName =
155
            packageFileName == null ? getPackageFileName(info)
156
                : packageFileName;
157
        if (!packageFolder.exists()) {
158
            packageFolder.mkdirs();
159
        }
160
        packageBundleFile = new File(packageFolder, packageName);
161

  
162
        try {
163
            FileOutputStream fos = new FileOutputStream(packageBundleFile);
164
            BufferedOutputStream bos = new BufferedOutputStream(fos);
165

  
166
            createPackage(makePluginService, info, bos);
167

  
168
            bos.flush();
169
            bos.close();
170
            fos.close();
171
        } catch (FileNotFoundException e) {
172
            throw new MojoExecutionException("Error creating the "
173
                + getPackageTypeName() + " file: " + packageBundleFile, e);
174
        } catch (MakePluginPackageServiceException e) {
175
            throw new MojoExecutionException(
176
                "Error creating the package file: " + packageName
177
                    + ", for the plugin: " + artifactId, e);
178
        } catch (IOException e) {
179
            throw new MojoExecutionException("I/O error writing the "
180
                + getPackageTypeName() + " file: " + packageBundleFile, e);
181
        }
182

  
183
        log.info(getPackageTypeName() + " file created successfully as: "
184
            + packageName);
185
    }
186

  
187
    /**
188
     * Returns the name of the package file to create.
189
     * 
190
     * @param info
191
     *            package information
192
     * @return the name of the file to create
193
     */
194
    protected abstract String getPackageFileName(PackageInfo info);
195

  
196
    /**
197
     * Returns the name of the package type to create.
198
     * 
199
     * @return the name of the package type to create
200
     */
201
    protected abstract String getPackageTypeName();
202

  
203
    /**
204
     * Creates the package file into the given {@link OutputStream}.
205
     * 
206
     * @param makePluginService
207
     *            to use to create the package
208
     * @param info
209
     *            the information of the package to create
210
     * @param os
211
     *            where to create the package file
212
     * @throws MakePluginPackageServiceException
213
     *             if there is an error creating the package file
214
     */
215
    protected abstract void createPackage(
216
        MakePluginPackageService makePluginService, PackageInfo info,
217
        OutputStream os) throws MakePluginPackageServiceException;
218
}
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.api/src/main/java/org/gvsig/installer/swing/api/SwingInstallerManager.java
32 32

  
33 33
import javax.swing.JPanel;
34 34

  
35
import org.gvsig.installer.lib.api.InstallerManager;
35 36
import org.gvsig.installer.swing.api.creation.MakePluginPackageWizard;
36 37
import org.gvsig.installer.swing.api.creation.MakePluginPackageWizardException;
37 38
import org.gvsig.installer.swing.api.execution.InstallPackageWizard;
......
137 138
     */
138 139
    public String getText(String key);
139 140

  
141
    /**
142
     * Returns a reference to the {@link InstallerManager}.
143
     * 
144
     * @return a reference to the {@link InstallerManager}
145
     */
146
    public InstallerManager getInstallerManager();
147

  
140 148
}
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/execution/DefaultInstallPackageWizard.java
139 139
        getWizardComponents().getCancelButton().setEnabled(isEnabled);
140 140
    }
141 141

  
142
    public void setBackButtonEnabled(boolean isEnabled) {
143
        getWizardComponents().getBackButton().setEnabled(isEnabled);
144
    }
145

  
142 146
    @Override
143 147
    public void installFromDefaultDirectory()
144 148
        throws InstallPackageServiceException {
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/execution/panel/SelectBundlesPanel.java
44 44
import javax.swing.event.DocumentEvent;
45 45
import javax.swing.event.DocumentListener;
46 46

  
47
import org.gvsig.gui.beans.openfile.FileFilter;
47 48
import org.gvsig.gui.beans.openfile.FileTextField;
48 49
import org.gvsig.installer.swing.api.SwingInstallerLocator;
49 50
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
......
98 99
        fileRadioButton = new JRadioButton();
99 100
        urlRadioButton = new JRadioButton();
100 101
        selectFileText = new FileTextField();
102
        selectFileText.setFileFilter(new FileFilter() {
103

  
104
            private String packageExt = swingInstallerManager
105
                .getInstallerManager().getDefaultPackageFileExtension();
106
            private String packageSetExt = swingInstallerManager
107
                .getInstallerManager().getDefaultPackageSetFileExtension();
108

  
109
            @Override
110
            public String getDescription() {
111
                return "gvSIG package and package sets (*." + packageExt
112
                    + ", *." + packageSetExt + ")";
113
            }
114

  
115
            @Override
116
            public boolean accept(File file) {
117
                if (file.isFile()) {
118
                    String name = file.getName().toLowerCase();
119
                    return name.endsWith(packageExt)
120
                        || name.endsWith(packageSetExt);
121
                }
122
                return true;
123
            }
124

  
125
            @Override
126
            public String getDefaultExtension() {
127
                return packageSetExt;
128
            }
129
        });
130

  
101 131
        urlText = new JTextField();
102 132
        if (defaultDownloadURL != null) {
103 133
            urlText.setText(defaultDownloadURL.toString());
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/execution/wizard/SelectBundlesWizard.java
31 31
import java.net.MalformedURLException;
32 32
import java.net.URL;
33 33

  
34
import javax.swing.JOptionPane;
35 34
import javax.swing.JPanel;
36 35

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

  
39
import org.gvsig.gui.beans.wizard.panel.NotContinueWizardException;
40 40
import org.gvsig.gui.beans.wizard.panel.OptionPanel;
41 41
import org.gvsig.installer.lib.api.execution.InstallPackageService;
42 42
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
......
62 62
        URL defaultDownloadURL) {
63 63
        super(defaultDownloadURL);
64 64
        this.installerExecutionWizard = installerExecutionWizard;
65
        updatePanel();
65 66
    }
66 67

  
67 68
    public JPanel getJPanel() {
......
77 78

  
78 79
    }
79 80

  
80
    public void nextPanel() {
81
    public void nextPanel() throws NotContinueWizardException {
81 82
        InstallPackageService installerExecutionService =
82 83
            installerExecutionWizard.getInstallerExecutionService();
83 84
        try {
......
98 99
                }
99 100
            }
100 101
        } catch (InstallPackageServiceException e) {
101
            LOG.error("Error adding installer info", e);
102
            JOptionPane.showMessageDialog(installerExecutionWizard,
103
                swingInstallerManager.getText("execute_adding_error"));
102
            throw new NotContinueWizardException(
103
                swingInstallerManager.getText("execute_adding_error"), e, this);
104 104
        } catch (MalformedURLException e) {
105
            LOG.error("Error adding installer info", e);
106
            JOptionPane.showMessageDialog(installerExecutionWizard,
107
                swingInstallerManager.getText("execute_adding_error"));
105
            throw new NotContinueWizardException(
106
                swingInstallerManager.getText("execute_adding_error"), e, this);
108 107
        }
109 108
    }
110 109

  
111 110
    public void updatePanel() {
112

  
111
        if (installerExecutionWizard != null) {
112
            installerExecutionWizard.setBackButtonEnabled(false);
113
        }
113 114
    }
114 115

  
115 116
    @Override
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/PluginDescriptionPanel.java
155 155
        gridBagConstraints.anchor = GridBagConstraints.EAST;
156 156
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
157 157
        add(nameLabel, gridBagConstraints);
158

  
158 159
        gridBagConstraints = new GridBagConstraints();
159 160
        gridBagConstraints.gridx = 1;
160 161
        gridBagConstraints.gridy = 1;
......
163 164
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
164 165
        add(nameText, gridBagConstraints);
165 166

  
167
        descriptionLabel.setText(swingInstallerManager.getText("description"));
168
        gridBagConstraints = new GridBagConstraints();
169
        gridBagConstraints.gridx = 0;
170
        gridBagConstraints.gridy = 2;
171
        gridBagConstraints.anchor = GridBagConstraints.EAST;
172
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
173
        add(descriptionLabel, gridBagConstraints);
174

  
166 175
        descriptionArea.setColumns(20);
167 176
        descriptionArea.setRows(5);
168 177
        descriptionScrollPane.setViewportView(descriptionArea);
169

  
170 178
        gridBagConstraints = new GridBagConstraints();
171 179
        gridBagConstraints.gridx = 1;
172 180
        gridBagConstraints.gridy = 2;
......
176 184
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
177 185
        add(descriptionScrollPane, gridBagConstraints);
178 186

  
179
        descriptionLabel.setText(swingInstallerManager.getText("description"));
180
        gridBagConstraints = new GridBagConstraints();
181
        gridBagConstraints.gridx = 0;
182
        gridBagConstraints.gridy = 2;
183
        gridBagConstraints.anchor = GridBagConstraints.EAST;
184
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
185
        add(descriptionLabel, gridBagConstraints);
186

  
187 187
        versionLabel.setText(swingInstallerManager.getText("version"));
188 188
        gridBagConstraints = new GridBagConstraints();
189 189
        gridBagConstraints.gridx = 0;
......
196 196
        gridBagConstraints = new java.awt.GridBagConstraints();
197 197
        gridBagConstraints.gridx = 1;
198 198
        gridBagConstraints.gridy = 3;
199
        gridBagConstraints.anchor = GridBagConstraints.WEST;
199
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
200
        gridBagConstraints.weightx = 1.0;
200 201
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
201 202
        add(versionText, gridBagConstraints);
202 203

  
......
212 213
        gridBagConstraints = new GridBagConstraints();
213 214
        gridBagConstraints.gridx = 1;
214 215
        gridBagConstraints.gridy = 4;
215
        gridBagConstraints.anchor = GridBagConstraints.WEST;
216
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
217
        gridBagConstraints.weightx = 1.0;
216 218
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
217 219
        add(buildText, gridBagConstraints);
218 220

  
......
224 226
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
225 227
        add(officialLabel, gridBagConstraints);
226 228

  
229
        gridBagConstraints = new GridBagConstraints();
230
        gridBagConstraints.gridx = 1;
231
        gridBagConstraints.gridy = 6;
232
        gridBagConstraints.anchor = GridBagConstraints.WEST;
233
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
234
        add(officialCheckBox, gridBagConstraints);
235

  
227 236
        statusLabel.setText(swingInstallerManager.getText("status"));
228 237
        gridBagConstraints = new GridBagConstraints();
229 238
        gridBagConstraints.gridx = 0;
......
240 249
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
241 250
        add(statusCombo, gridBagConstraints);
242 251

  
243
        gridBagConstraints = new GridBagConstraints();
244
        gridBagConstraints.gridx = 1;
245
        gridBagConstraints.gridy = 6;
246
        gridBagConstraints.anchor = GridBagConstraints.WEST;
247
        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
248
        add(officialCheckBox, gridBagConstraints);
249

  
250 252
        codeLabel.setText(swingInstallerManager.getText("code"));
251 253
        gridBagConstraints = new GridBagConstraints();
252 254
        gridBagConstraints.anchor = GridBagConstraints.EAST;
253 255
        gridBagConstraints.insets = new Insets(2, 2, 2, 2);
254 256
        add(codeLabel, gridBagConstraints);
257

  
255 258
        gridBagConstraints = new GridBagConstraints();
256 259
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
257 260
        gridBagConstraints.weightx = 1.0;
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
87 87
        try {
88 88
            // Compress the plugin
89 89
            setCompressingText();
90
            installerCreationService.createPluginPackage(packageInfo,
90
            installerCreationService.createPackageSet(packageInfo,
91 91
                installerCreationWizard.getOutputStream());
92 92
            setProgress(100);
93 93

  
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
96 96
        File installsFolder = installerCreationWizard.getInstallFolder();
97 97
        PackageInfo info = installerCreationWizard.getSelectedPackageInfo();
98 98
        String fileName =
99
            InstallerLocator.getInstallerManager().getPackageBundleFileName(
99
            InstallerLocator.getInstallerManager().getPackageSetFileName(
100 100
                info);
101 101
        return new File(installsFolder, fileName);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff