Update credits (acknowledgements). #PL-5181

This commit is contained in:
Konstantin Krivopustov 2015-04-06 10:40:01 +00:00
parent 6187cdd745
commit 65b5b98236
5 changed files with 55 additions and 6 deletions

View File

@ -76,6 +76,11 @@ Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
</item>
<item name="FreeMarker" web="http://freemarker.sourceforge.net/">
<acknowledgment>
<![CDATA[
This product includes software developed by the Visigoth Software Society (http://www.visigoths.org/).
]]>
</acknowledgment>
<license><![CDATA[
FreeMarker 1.x was released under the LGPL license. Later, by community
consensus, we have switched over to a BSD-style license. As of FreeMarker
@ -402,6 +407,11 @@ Initial authors:
<item name="Xml Pull Parser 3rd Edition" web="http://www.extreme.indiana.edu/xgws/xsoap/xpp/mxp1">
<jar>xpp3_min-.*</jar>
<acknowledgment>
<![CDATA[
This product includes software developed by the Indiana University Extreme! Lab. For further information please visit http://www.extreme.indiana.edu/
]]>
</acknowledgment>
<license>
<![CDATA[
Indiana University Extreme! Lab Software License, Version 1.2

View File

@ -39,6 +39,8 @@ public class CreditsFrame extends AbstractFrame {
public void init(final Map<String, Object> params) {
getDialogParams().setResizable(true);
StringBuilder acknowledgements = new StringBuilder();
GridLayout grid = componentsFactory.createComponent(GridLayout.NAME);
grid.setSpacing(true);
grid.setMargin(false, true, false, true);
@ -52,6 +54,9 @@ public class CreditsFrame extends AbstractFrame {
for (int i = 0, itemsSize = items.size(); i < itemsSize; i++) {
final CreditsItem item = items.get(i);
if (item.getAcknowledgement() != null)
acknowledgements.append("<p>").append(item.getAcknowledgement());
Label nameLab = componentsFactory.createComponent(Label.NAME);
nameLab.setValue(item.getName());
nameLab.setFrame(frame);
@ -93,18 +98,40 @@ public class CreditsFrame extends AbstractFrame {
grid.add(license, 4, i);
}
if (acknowledgements.length() > 0) {
Label ackLab = componentsFactory.createComponent(Label.NAME);
ackLab.setWidth("420px");
ackLab.setHtmlEnabled(true);
ackLab.setValue(acknowledgements.toString());
scrollBox.add(ackLab);
}
scrollBox.add(grid);
}
}
public void exportLicenses() {
List<CreditsItem> items = new CreditsLoader().load().getItems();
Map<String, String> licenses = new TreeMap<>();
StringBuilder sb = new StringBuilder();
sb.append("<html><body>\n");
sb.append("<h1>Credits</h1>\n");
sb.append("<p><a href='#licenses'>Common Licenses</a></p>\n");
StringBuilder acknowledgements = new StringBuilder();
for (CreditsItem item : items) {
if (item.getAcknowledgement() != null)
acknowledgements.append("<p>").append(item.getAcknowledgement());
}
if (acknowledgements.length() > 0) {
sb.append("<h2>Acknowledgements</h1>\n");
sb.append(acknowledgements);
}
// sb.append("<p><a href='#licenses'>Common Licenses</a></p>\n");
sb.append("<h2>Third-party products</h1>\n");
sb.append("<ol>\n");
List<CreditsItem> items = new CreditsLoader().load().getItems();
for (CreditsItem item : items) {
sb.append("<li><b>").append(item.getName()).append("</b>\n");
sb.append("<p>Web site: <a href='").append(item.getWebPage()).append("' target='_blank'>").append(item.getWebPage()).append("</a></p>\n");
@ -119,7 +146,8 @@ public class CreditsFrame extends AbstractFrame {
sb.append("</li>\n");
}
sb.append("</ol>\n");
sb.append("<a name='licenses'></a><h1>Common Licenses</h1>\n");
sb.append("<a name='licenses'></a><h2>Common Licenses</h1>\n");
sb.append("<ol>\n");
for (Map.Entry<String, String> entry : licenses.entrySet()) {
sb.append("<li><a name='").append(entry.getKey()).append("'></a><b>").append(entry.getKey()).append("</b>\n");

View File

@ -16,14 +16,16 @@ public class CreditsItem implements Comparable<CreditsItem> {
private String webPage;
private String licenseId;
private String license;
private String acknowledgement;
public CreditsItem(String name, String webPage, String licenseId, String license) {
public CreditsItem(String name, String webPage, String licenseId, String license, String acknowledgement) {
if (name == null || webPage == null || license == null)
throw new NullPointerException("Argument is null");
this.name = name;
this.webPage = webPage;
this.licenseId = licenseId;
this.license = license;
this.acknowledgement = acknowledgement;
}
public String getName() {
@ -42,6 +44,10 @@ public class CreditsItem implements Comparable<CreditsItem> {
return license;
}
public String getAcknowledgement() {
return acknowledgement;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;

View File

@ -77,7 +77,7 @@ public class CreditsLoader {
for (Element element : Dom4j.elements(itemsEl)) {
CreditsItem item = new CreditsItem(element.attributeValue("name"), element.attributeValue("web"),
element.attributeValue("license"), loadLicense(element));
element.attributeValue("license"), loadLicense(element), loadAcknowledgement(element));
if (items.contains(item)) {
items.set(items.indexOf(item), item);
} else {
@ -100,4 +100,9 @@ public class CreditsLoader {
return licenseEl.getText();
}
}
private String loadAcknowledgement(Element element) {
Element acknowledgmentEl = element.element("acknowledgment");
return acknowledgmentEl == null ? null : acknowledgmentEl.getText();
}
}

View File

@ -10,7 +10,7 @@
<action id="printLicenses" shortcut="Ctrl-Alt-E" invoke="exportLicenses"/>
</actions>
<layout>
<scrollBox id="scroll" width="100%" height="100%" scrollBars="both">
<scrollBox id="scroll" width="100%" height="100%" scrollBars="both" spacing="true">
</scrollBox>
</layout>