Revision 34003
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 | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.installer.app.extension.execution; |
29 | 29 |
|
30 |
import java.net.MalformedURLException; |
|
31 |
import java.net.URL; |
|
32 |
|
|
30 | 33 |
import org.slf4j.Logger; |
31 | 34 |
import org.slf4j.LoggerFactory; |
32 | 35 |
|
33 | 36 |
import org.gvsig.andami.PluginServices; |
34 | 37 |
import org.gvsig.andami.plugins.Extension; |
35 | 38 |
import org.gvsig.installer.app.extension.GvSIGFolders; |
39 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
36 | 40 |
|
37 | 41 |
/** |
38 | 42 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
... | ... | |
44 | 48 |
|
45 | 49 |
public void execute(String actionCommand) { |
46 | 50 |
GvSIGFolders folders = new GvSIGFolders(); |
47 |
|
|
48 | 51 |
try { |
49 | 52 |
PluginServices.getMDIManager().addCentredWindow( |
50 | 53 |
new InstallPackageWindow(folders.getApplicationFolder(), |
51 | 54 |
folders.getPluginsFolder(), folders.getInstallFolder())); |
52 | 55 |
} catch (Exception e) { |
53 |
LOG.error("Error creating teh wizard to install a package ", e);
|
|
56 |
LOG.error("Error creating the wizard to install a package ", e);
|
|
54 | 57 |
} |
55 | 58 |
} |
56 | 59 |
|
57 | 60 |
public void initialize() { |
58 | 61 |
|
62 |
// TODO: move to user preferences or an external configuration file |
|
63 |
String packageDownloadURL = |
|
64 |
"http://gvsig-desktop.forge.osor.eu/gvSIG-desktop/dists/2.0.0/packages.zip"; |
|
65 |
|
|
66 |
try { |
|
67 |
SwingInstallerLocator.getSwingInstallerManager() |
|
68 |
.setDefaultDownloadURL(new URL(packageDownloadURL)); |
|
69 |
} catch (MalformedURLException e) { |
|
70 |
LOG.error( |
|
71 |
"Error creating the default packages download URL pointing to" |
|
72 |
+ packageDownloadURL, e); |
|
73 |
} |
|
59 | 74 |
} |
60 | 75 |
|
61 | 76 |
public boolean isEnabled() { |
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 | ||
---|---|---|
160 | 160 |
* |
161 | 161 |
* @param fileURL |
162 | 162 |
* to download the file from |
163 |
* @param defaultFileName |
|
164 |
* default name for the file. If the URL ends with / the file |
|
165 |
* name will be appended to the URL. If null it will be ignored |
|
163 | 166 |
* @return the temporal downloaded file |
164 | 167 |
* @throws IOException |
165 | 168 |
* if there is an error downloading the file |
166 | 169 |
*/ |
167 |
public File downloadFile(URL fileURL) throws IOException; |
|
170 |
public File downloadFile(URL fileURL, String defaultFileName) |
|
171 |
throws IOException; |
|
168 | 172 |
} |
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 | ||
---|---|---|
127 | 127 |
decompress.readInstallInfo(is, installerInfos, zipEntriesMap); |
128 | 128 |
} |
129 | 129 |
|
130 |
public File downloadFile(URL bundleURL) throws IOException { |
|
131 |
URLConnection connection = bundleURL.openConnection(); |
|
130 |
public File downloadFile(URL bundleURL, String defaultFileName) |
|
131 |
throws IOException { |
|
132 |
|
|
133 |
URL downloadURL = bundleURL; |
|
134 |
|
|
135 |
// check if the URL ends with '/' and append the file name |
|
136 |
if (defaultFileName != null) { |
|
137 |
String urlStr = bundleURL.toString(); |
|
138 |
if (urlStr.endsWith("/")) { |
|
139 |
urlStr = urlStr.concat(defaultFileName); |
|
140 |
downloadURL = new URL(urlStr); |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
URLConnection connection = downloadURL.openConnection(); |
|
132 | 145 |
String fileName = getFileName(connection); |
133 | 146 |
|
134 | 147 |
if (LOG.isDebugEnabled()) { |
135 | 148 |
Date date = new Date(connection.getLastModified()); |
136 | 149 |
LOG.debug( |
137 | 150 |
"Downloading file {} from URL {}, with last modified date: {}", |
138 |
new Object[] { fileName, bundleURL, date });
|
|
151 |
new Object[] { fileName, downloadURL, date });
|
|
139 | 152 |
} |
140 | 153 |
|
141 | 154 |
String fileNamePrefix = fileName; |
... | ... | |
147 | 160 |
} |
148 | 161 |
|
149 | 162 |
BufferedInputStream bis = |
150 |
new BufferedInputStream(bundleURL.openStream());
|
|
163 |
new BufferedInputStream(downloadURL.openStream());
|
|
151 | 164 |
|
152 | 165 |
File localFile = File.createTempFile(fileNamePrefix, fileNameSuffix); |
153 | 166 |
BufferedOutputStream bos = |
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 | ||
---|---|---|
106 | 106 |
installerExecutionProvider.install(applicationDirectory, |
107 | 107 |
packageStream); |
108 | 108 |
} else { |
109 |
File downloadedBundle = downloadFile(packageInfo.getDownloadURL()); |
|
109 |
File downloadedBundle = |
|
110 |
downloadFile(packageInfo.getDownloadURL(), null); |
|
110 | 111 |
try { |
111 | 112 |
FileInputStream fis = new FileInputStream(downloadedBundle); |
112 | 113 |
BufferedInputStream bis = new BufferedInputStream(fis); |
... | ... | |
184 | 185 |
} |
185 | 186 |
|
186 | 187 |
public void addBundle(URL bundleURL) throws InstallPackageServiceException { |
187 |
File bundle = downloadFile(bundleURL); |
|
188 |
File bundle = downloadFile(bundleURL, "packages.zip");
|
|
188 | 189 |
addBundle(bundle); |
189 | 190 |
} |
190 | 191 |
|
191 |
private File downloadFile(URL bundleURL) |
|
192 |
private File downloadFile(URL bundleURL, String defaultFileName)
|
|
192 | 193 |
throws InstallPackageServiceException { |
193 | 194 |
try { |
194 | 195 |
return InstallerProviderLocator.getProviderManager() |
195 |
.createInstallerProviderServices().downloadFile(bundleURL); |
|
196 |
.createInstallerProviderServices() |
|
197 |
.downloadFile(bundleURL, defaultFileName); |
|
196 | 198 |
} catch (IOException e) { |
197 | 199 |
throw new InstallPackageServiceException( |
198 | 200 |
"Bundle file download error from URL: " + bundleURL, e); |
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 | ||
---|---|---|
66 | 66 |
private JRadioButton standardRadioButton; |
67 | 67 |
private JTextField urlText; |
68 | 68 |
private JRadioButton urlRadioButton; |
69 |
private final URL defaultDownloadURL; |
|
69 | 70 |
|
70 |
public SelectBundlesPanel() { |
|
71 |
public SelectBundlesPanel(URL defaultDownloadURL) {
|
|
71 | 72 |
super(); |
73 |
this.defaultDownloadURL = defaultDownloadURL; |
|
72 | 74 |
swingInstallerManager = |
73 | 75 |
(DefaultSwingInstallerManager) SwingInstallerLocator |
74 | 76 |
.getSwingInstallerManager(); |
... | ... | |
97 | 99 |
urlRadioButton = new JRadioButton(); |
98 | 100 |
selectFileText = new FileTextField(); |
99 | 101 |
urlText = new JTextField(); |
102 |
if (defaultDownloadURL != null) { |
|
103 |
urlText.setText(defaultDownloadURL.toString()); |
|
104 |
} |
|
100 | 105 |
buttonGroup = new ButtonGroup(); |
101 | 106 |
|
102 | 107 |
buttonGroup.add(standardRadioButton); |
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 | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 | 31 |
import java.net.MalformedURLException; |
32 |
import java.net.URL; |
|
32 | 33 |
|
33 | 34 |
import javax.swing.JOptionPane; |
34 | 35 |
import javax.swing.JPanel; |
... | ... | |
57 | 58 |
.getLogger(SelectBundlesWizard.class); |
58 | 59 |
|
59 | 60 |
public SelectBundlesWizard( |
60 |
DefaultInstallPackageWizard installerExecutionWizard) { |
|
61 |
super(); |
|
61 |
DefaultInstallPackageWizard installerExecutionWizard, |
|
62 |
URL defaultDownloadURL) { |
|
63 |
super(defaultDownloadURL); |
|
62 | 64 |
this.installerExecutionWizard = installerExecutionWizard; |
63 | 65 |
} |
64 | 66 |
|
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 | ||
---|---|---|
44 | 44 |
import org.gvsig.installer.lib.api.PackageInfo; |
45 | 45 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
46 | 46 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
47 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
47 | 48 |
import org.gvsig.installer.swing.api.execution.InstallPackageWizard; |
48 | 49 |
import org.gvsig.installer.swing.impl.execution.wizard.ProgressWizard; |
49 | 50 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectBundlesWizard; |
... | ... | |
82 | 83 |
ImageIcon icon = new ImageIcon(iconURL); |
83 | 84 |
wizardPanelWithLogo = new WizardPanelWithLogo(icon); |
84 | 85 |
|
85 |
selectInstallersWizard = new SelectBundlesWizard(this); |
|
86 |
URL downloadURL = |
|
87 |
SwingInstallerLocator.getSwingInstallerManager() |
|
88 |
.getDefaultDownloadURL(); |
|
89 |
selectInstallersWizard = new SelectBundlesWizard(this, downloadURL); |
|
86 | 90 |
selectPluginsWizard = new SelectPackagesWizard(this); |
87 | 91 |
progressWizard = new ProgressWizard(this); |
88 | 92 |
|
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/DefaultSwingInstallerManager.java | ||
---|---|---|
28 | 28 |
package org.gvsig.installer.swing.impl; |
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 |
import java.net.URL; |
|
31 | 32 |
|
32 | 33 |
import org.gvsig.i18n.Messages; |
33 | 34 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
... | ... | |
54 | 55 |
.getExtensionPointManager(); |
55 | 56 |
|
56 | 57 |
private String applicationVersion = "1.0.0"; |
58 |
private URL defaultDownloadURL = null; |
|
57 | 59 |
|
58 | 60 |
public String getText(String key) { |
59 | 61 |
return Messages.getText(key); |
... | ... | |
117 | 119 |
this.applicationVersion = gvSIGVersion; |
118 | 120 |
} |
119 | 121 |
|
122 |
public URL getDefaultDownloadURL() { |
|
123 |
return defaultDownloadURL; |
|
124 |
} |
|
125 |
|
|
126 |
public void setDefaultDownloadURL(URL defaultDownloadURL) { |
|
127 |
this.defaultDownloadURL = defaultDownloadURL; |
|
128 |
} |
|
129 |
|
|
120 | 130 |
} |
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 | ||
---|---|---|
28 | 28 |
package org.gvsig.installer.swing.api; |
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 |
import java.net.URL; |
|
31 | 32 |
|
32 | 33 |
import javax.swing.JPanel; |
33 | 34 |
|
... | ... | |
112 | 113 |
public void setApplicationVersion(String gvSIGVersion); |
113 | 114 |
|
114 | 115 |
/** |
116 |
* Returns the default URL to download packages from. |
|
117 |
* |
|
118 |
* @return the default URL to download packages from |
|
119 |
*/ |
|
120 |
public URL getDefaultDownloadURL(); |
|
121 |
|
|
122 |
/** |
|
123 |
* Sets the default URL to download packages from |
|
124 |
* |
|
125 |
* @param defaultDownloadURL |
|
126 |
* the default URL to download packages from |
|
127 |
*/ |
|
128 |
public void setDefaultDownloadURL(URL defaultDownloadURL); |
|
129 |
|
|
130 |
/** |
|
115 | 131 |
* Translate a key in a text using the current application language |
116 | 132 |
* |
117 | 133 |
* @param key |
Also available in: Unified diff