Revision 43088 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/PackagesTablePanel.java
PackagesTablePanel.java | ||
---|---|---|
34 | 34 |
import java.awt.Insets; |
35 | 35 |
import java.awt.event.MouseEvent; |
36 | 36 |
import java.awt.event.MouseListener; |
37 |
import java.io.IOException; |
|
38 |
import java.io.InputStream; |
|
37 | 39 |
import java.net.URL; |
38 | 40 |
import java.util.List; |
41 |
import java.util.Locale; |
|
42 |
import java.util.logging.Level; |
|
43 |
import java.util.logging.Logger; |
|
39 | 44 |
|
40 | 45 |
import javax.swing.JEditorPane; |
41 | 46 |
import javax.swing.JPanel; |
... | ... | |
44 | 49 |
import javax.swing.event.ListSelectionEvent; |
45 | 50 |
import javax.swing.event.ListSelectionListener; |
46 | 51 |
import javax.swing.table.TableColumnModel; |
52 |
import org.apache.commons.io.FileUtils; |
|
53 |
import org.apache.commons.io.IOUtils; |
|
54 |
import org.apache.commons.lang3.StringUtils; |
|
47 | 55 |
|
48 | 56 |
import org.gvsig.installer.lib.api.PackageInfo; |
49 | 57 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
... | ... | |
271 | 279 |
return; |
272 | 280 |
} |
273 | 281 |
|
274 |
PackageInfo pkginfo = ((PackagesTableModel) pluginsTable.getModel()) |
|
275 |
.getPackageInfoAt(row);
|
|
282 |
PackageInfo pkginfo = ((PackagesTableModel) pluginsTable.getModel()).getPackageInfoAt(row);
|
|
283 |
descriptionTextEditor.setText(getFullDescriptionAsHTML(pkginfo));
|
|
276 | 284 |
|
277 |
HTMLCoder html = new HTMLCoder(); |
|
278 |
html.addTitle(pkginfo.getName()); |
|
279 |
html.addParagraph(pkginfo.getDescription()); |
|
280 |
html.addBeginList(); |
|
281 |
html.addListItem("code", pkginfo.getCode()); |
|
282 |
html.addListItem("Organization", pkginfo.getOwner()); |
|
283 |
html.addListItem("Organization URL", pkginfo.getOwnerURL()); |
|
284 |
html.addListItem("Sources", pkginfo.getSourcesURL()); |
|
285 |
html.addListItem("Dependencies", pkginfo.getDependencies()); |
|
286 |
html.addListItem("Categories", pkginfo.getCategoriesAsString()); |
|
287 |
html.addListItem("Official", pkginfo.isOfficial()); |
|
288 |
html.addListItem("Signed", pkginfo.isSigned()); |
|
289 |
html.addEndList(); |
|
290 |
|
|
291 |
descriptionTextEditor.setText(html.toString()); |
|
292 |
|
|
293 | 285 |
// get the view area to the top-left corner |
294 | 286 |
descriptionTextEditor.setCaretPosition(0); |
295 | 287 |
|
296 | 288 |
} |
289 |
|
|
290 |
public String getFullDescriptionAsHTML(PackageInfo pkginfo) { |
|
291 |
String html = null; |
|
292 |
String lang = Locale.getDefault().getLanguage(); |
|
293 |
InputStream res = this.getClass().getClassLoader().getResourceAsStream("org/gvsig/installer/swing/impl/pkg_description_"+lang+".html"); |
|
294 |
if( res == null ) { |
|
295 |
res = this.getClass().getClassLoader().getResourceAsStream("org/gvsig/installer/swing/impl/pkg_description_en.html"); |
|
296 |
} |
|
297 |
if( res != null ) { |
|
298 |
try { |
|
299 |
List<String> lines = IOUtils.readLines(res); |
|
300 |
html = StringUtils.join(lines,null); |
|
301 |
res.close(); |
|
302 |
} catch (Exception ex) { |
|
303 |
// Do nothing |
|
304 |
} |
|
305 |
} |
|
306 |
if( html == null ) { |
|
307 |
HTMLCoder coder = new HTMLCoder(); |
|
308 |
coder.addTitle(pkginfo.getName()); |
|
309 |
coder.addParagraph(pkginfo.getDescription()); |
|
310 |
coder.addBeginList(); |
|
311 |
coder.addListItem("code", pkginfo.getCode()); |
|
312 |
coder.addListItem("Organization", pkginfo.getOwner()); |
|
313 |
coder.addListItem("Organization URL", pkginfo.getOwnerURL()); |
|
314 |
coder.addListItem("Sources", pkginfo.getSourcesURL()); |
|
315 |
coder.addListItem("Dependencies", pkginfo.getDependencies()); |
|
316 |
coder.addListItem("Categories", pkginfo.getCategoriesAsString()); |
|
317 |
coder.addListItem("Official", pkginfo.isOfficial()); |
|
318 |
coder.addEndList(); |
|
319 |
return coder.toString(); |
|
320 |
} |
|
321 |
|
|
322 |
html = html.replace("${gvsig.package.info.name}",pkginfo.getName()); |
|
323 |
html = html.replace("${gvsig.package.info.description}",pkginfo.getDescription()); |
|
324 |
html = html.replace("${gvsig.package.info.official}",pkginfo.isOfficial()?"true":"false"); |
|
325 |
html = html.replace("${gvsig.package.info.official.label}",pkginfo.isOfficial()?"official":"community"); |
|
326 |
html = html.replace("${gvsig.package.info.owner}",pkginfo.getOwner()); |
|
327 |
html = html.replace("${gvsig.package.info.webURL}",pkginfo.getWebURL()==null? "":pkginfo.getWebURL().toString()); |
|
328 |
html = html.replace("${gvsig.package.info.categories}",pkginfo.getCategoriesAsString()); |
|
329 |
html = html.replace("${gvsig.package.info.sourcesURL}",pkginfo.getSourcesURL()==null?"":pkginfo.getSourcesURL().toString()); |
|
330 |
html = html.replace("${gvsig.package.info.code}",pkginfo.getCode()); |
|
331 |
html = html.replace("${gvsig.package.info.dependencies}",pkginfo.getDependencies()==null?"":pkginfo.getDependencies().toString()); |
|
332 |
html = html.replace("${gvsig.package.info.version}",pkginfo.getVersion()==null?"":pkginfo.getVersion().toString()); |
|
333 |
html = html.replace("${gvsig.package.info.state}",pkginfo.getState()); |
|
334 |
html = html.replace("${gvsig.package.info.operatingSystem}",pkginfo.getOperatingSystem()); |
|
335 |
html = html.replace("${gvsig.package.info.architecture}",pkginfo.getArchitecture()); |
|
336 |
html = html.replace("${gvsig.package.info.javaVM}",pkginfo.getJavaVM()); |
|
337 |
return html; |
|
338 |
} |
|
297 | 339 |
|
298 | 340 |
public void setFilter(PackageFilter filter) { |
299 | 341 |
PackagesTableModel pluginsTableModel = (PackagesTableModel) pluginsTable |
Also available in: Unified diff