Author: snjeza
Date: 2012-02-09 10:16:21 -0500 (Thu, 09 Feb 2012)
New Revision: 38558
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java
Log:
JBIDE-10801 Problem rendering blog entry in JBoss central
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2012-02-09
15:01:37 UTC (rev 38557)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/GettingStartedPage.java 2012-02-09
15:16:21 UTC (rev 38558)
@@ -99,8 +99,8 @@
import org.jboss.tools.central.jobs.RefreshNewsJob;
import org.jboss.tools.central.jobs.RefreshTutorialsJob;
import org.jboss.tools.central.model.FeedsEntry;
-import org.jboss.tools.project.examples.model.ProjectExampleCategory;
import org.jboss.tools.project.examples.model.ProjectExample;
+import org.jboss.tools.project.examples.model.ProjectExampleCategory;
import org.osgi.framework.Bundle;
/**
@@ -1018,42 +1018,33 @@
if (i++ > JBossCentralActivator.MAX_FEEDS) {
return;
}
- String text = entry.getFormString();
+ String text = entry.getFormString(false);
FormText formText = toolkit.createFormText(composite, true);
TableWrapData td = new TableWrapData();
td.indent = 2;
- //Point size = scrollable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- //td.maxWidth = size.x - 2;
formText.setLayoutData(td);
- try {
- // to avoid illegal argumentexception on formtext fields.
- // we replace the HTML entity with the standard xml version
- // TODO: should probably be done earlier on but couldn't find where.
- text = text.replaceAll(" ", " ");
- //Temporary fix for JBIDE-10801
- //FIXME find a generic way to replace entities with proper code
- text = text.replaceAll(" & ", " & ");
+ try {
formText.setText(text, true, true);
} catch(IllegalArgumentException se) {
- formText.dispose();
- formText = toolkit.createFormText(composite, false);
- formText.setLayoutData(td);
try {
- formText.setText("Problem rendering entry - " +
StringEscapeUtils.unescapeHtml(se.getMessage()), false, false);
- } catch (Exception e1) {
- JBossCentralActivator.log(se);
+ text = entry.getFormString(true);
+ formText.setText(text, true, true);
+ } catch (IllegalArgumentException se2) {
+ formText.dispose();
+ formText = toolkit.createFormText(composite, false);
+ formText.setLayoutData(td);
+ try {
+ formText.setText("Problem rendering entry - " +
StringEscapeUtils.unescapeHtml(se.getMessage()), false, false);
+ } catch (Exception e1) {
+ JBossCentralActivator.log(se);
+ }
}
continue;
}
- //Display display = Display.getCurrent();
- //formText.setFont(getLinkFont(display));
formText.setFont("default", JFaceResources.getDefaultFont());
formText.setFont("date", JFaceResources.getDefaultFont());
formText.setColor("date", JFaceColors.getHyperlinkText(getDisplay()));
- //formText.setForeground(JFaceColors.getHyperlinkText(getDisplay()));
formText.setFont("description", JFaceResources.getDefaultFont());
- //Font boldFont = getAuthorFont(display);
- //formText.setFont("author", boldFont);
formText.setColor("author", JFaceColors.getHyperlinkText(getDisplay()));
formText.setImage("image", getFeedsImage());
if (JBossCentralActivator.isInternalWebBrowserAvailable() &&
entry.getDescription() != null && !entry.getDescription().isEmpty()) {
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java 2012-02-09
15:01:37 UTC (rev 38557)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/model/FeedsEntry.java 2012-02-09
15:16:21 UTC (rev 38558)
@@ -81,7 +81,7 @@
this.date = date;
}
- public String getFormString() {
+ public String getFormString(boolean escapeXml) {
StringBuffer buffer = new StringBuffer();
buffer.append(JBossCentralActivator.FORM_START_TAG);
buffer.append("<img href=\"image\"/> ");
@@ -89,10 +89,10 @@
buffer.append("<a href=\"");
buffer.append(link);
buffer.append("\">");
- buffer.append(StringEscapeUtils.unescapeHtml(title));
+ buffer.append(escapeXml(title, escapeXml));
buffer.append("</a>");
} else {
- buffer.append(StringEscapeUtils.unescapeHtml(title));
+ buffer.append(escapeXml(title, escapeXml));
}
//buffer.append("<br/>");
boolean cr = false;
@@ -113,7 +113,7 @@
buffer.append("</span>");
buffer.append(" ");
buffer.append("<span color=\"author\"
font=\"author\">");
- buffer.append(StringEscapeUtils.unescapeHtml(author));
+ buffer.append(escapeXml(author, escapeXml));
buffer.append("</span>");
cr = true;
}
@@ -125,7 +125,7 @@
cr = false;
if (shortDescription != null && !shortDescription.isEmpty()) {
buffer.append("<span font=\"description\">");
- buffer.append(StringEscapeUtils.unescapeHtml(shortDescription));
+ buffer.append(escapeXml(shortDescription, escapeXml));
buffer.append("</span>");
cr = true;
}
@@ -135,6 +135,16 @@
buffer.append(JBossCentralActivator.FORM_END_TAG);
return buffer.toString();
}
+
+ protected String escapeXml(String text, boolean escape) {
+ text = StringEscapeUtils.unescapeHtml(text);
+ if (escape) {
+ text = StringEscapeUtils.escapeXml(text);
+ }
+ text = text.replaceAll(" ", " ");
+ text = text.replaceAll("& ", "& ");
+ return text;
+ }
public String getShortDescription() {
if (description == null) {
Show replies by date