You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/03/18 12:40:47 UTC

[11/25] incubator-nifi git commit: NIFI-280 - putting description as an info bubble

NIFI-280 - putting description as an info bubble


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/60070706
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/60070706
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/60070706

Branch: refs/heads/NIFI-250
Commit: 60070706281e8d8cd8ee2a15312f62a1af9e7e0c
Parents: f269861
Author: danbress <db...@onyxconsults.com>
Authored: Tue Feb 3 22:37:44 2015 -0500
Committer: danbress <db...@onyxconsults.com>
Committed: Sat Feb 7 10:47:09 2015 -0500

----------------------------------------------------------------------
 .../html/HtmlDocumentationWriter.java           | 71 ++++++++++++++------
 .../html/HtmlProcessorDocumentationWriter.java  |  4 +-
 .../example/FullyDocumentedProcessor.java       |  3 +-
 3 files changed, 53 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/60070706/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
index 40618fe..cd2cee6 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlDocumentationWriter.java
@@ -52,8 +52,8 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 			final boolean includesAdditionalDocumentation) throws IOException {
 
 		try {
-			XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(streamToWriteTo,
-					"UTF-8");
+			XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(
+					streamToWriteTo, "UTF-8");
 			xmlStreamWriter.writeDTD("<!DOCTYPE html>");
 			xmlStreamWriter.writeStartElement("html");
 			xmlStreamWriter.writeAttribute("lang", "en");
@@ -76,8 +76,8 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 	 * @throws XMLStreamException
 	 *             thrown if there was a problem writing to the stream
 	 */
-	protected void writeHead(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter)
-			throws XMLStreamException {
+	protected void writeHead(final ConfigurableComponent configurableComponent,
+			final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
 		xmlStreamWriter.writeStartElement("head");
 		xmlStreamWriter.writeStartElement("meta");
 		xmlStreamWriter.writeAttribute("charset", "utf-8");
@@ -118,7 +118,8 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 	 *             thrown if there was a problem writing to the XML stream
 	 */
 	private final void writeBody(final ConfigurableComponent configurableComponent,
-			final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails) throws XMLStreamException {
+			final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails)
+			throws XMLStreamException {
 		xmlStreamWriter.writeStartElement("body");
 		writeDescription(configurableComponent, xmlStreamWriter, hasAdditionalDetails);
 		writeTags(configurableComponent, xmlStreamWriter);
@@ -149,16 +150,18 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 	 * @param xmlStreamWriter
 	 * @throws XMLStreamException
 	 */
-	private void writeTags(final ConfigurableComponent configurableComponent, final XMLStreamWriter xmlStreamWriter)
-			throws XMLStreamException {
+	private void writeTags(final ConfigurableComponent configurableComponent,
+			final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
 		final Tags tags = configurableComponent.getClass().getAnnotation(Tags.class);
+		xmlStreamWriter.writeStartElement("h3");
+		xmlStreamWriter.writeCharacters("Tags: ");
+		xmlStreamWriter.writeEndElement();
 		xmlStreamWriter.writeStartElement("p");
 		if (tags != null) {
 			final String tagString = StringUtils.join(tags.value(), ", ");
-			xmlStreamWriter.writeCharacters("Tags: ");
 			xmlStreamWriter.writeCharacters(tagString);
 		} else {
-			xmlStreamWriter.writeCharacters("No Tags provided.");
+			xmlStreamWriter.writeCharacters("None.");
 		}
 		xmlStreamWriter.writeEndElement();
 
@@ -178,7 +181,8 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 	 *             thrown if there was a problem writing to the XML stream
 	 */
 	protected void writeDescription(final ConfigurableComponent configurableComponent,
-			final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails) throws XMLStreamException {
+			final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails)
+			throws XMLStreamException {
 		writeSimpleElement(xmlStreamWriter, "h2", "Description: ");
 		writeSimpleElement(xmlStreamWriter, "p", getDescription(configurableComponent));
 		if (hasAdditionalDetails) {
@@ -224,9 +228,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 	 */
 	protected void writeProperties(final ConfigurableComponent configurableComponent,
 			final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
-		xmlStreamWriter.writeStartElement("p");
-		writeSimpleElement(xmlStreamWriter, "strong", "Properties: ");
-		xmlStreamWriter.writeEndElement();
+		writeSimpleElement(xmlStreamWriter, "h3", "Properties: ");
 		xmlStreamWriter.writeStartElement("p");
 		xmlStreamWriter.writeCharacters("In the list below, the names of required properties appear in ");
 		writeSimpleElement(xmlStreamWriter, "strong", "bold");
@@ -253,11 +255,10 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 			// write the header row
 			xmlStreamWriter.writeStartElement("tr");
 			writeSimpleElement(xmlStreamWriter, "th", "Name");
-			writeSimpleElement(xmlStreamWriter, "th", "Description");
-			writeSimpleElement(xmlStreamWriter, "th", "Default");
-			writeSimpleElement(xmlStreamWriter, "th", "Values");
+			writeSimpleElement(xmlStreamWriter, "th", "Default Value");
+			writeSimpleElement(xmlStreamWriter, "th", "Valid Values");
 			xmlStreamWriter.writeStartElement("th");
-			writeLink(xmlStreamWriter, "EL", "../../html/expression-language-guide.html");
+			writeLink(xmlStreamWriter, "Expression Language", "../../html/expression-language-guide.html");
 			xmlStreamWriter.writeEndElement();
 			xmlStreamWriter.writeEndElement();
 
@@ -274,17 +275,18 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 				if (property.isSensitive()) {
 					writeSensitiveImg(xmlStreamWriter);
 				}
+				writePropertyDescription(xmlStreamWriter, property.getDescription());
 				xmlStreamWriter.writeEndElement();
-				writeSimpleElement(xmlStreamWriter, "td", property.getDescription());
 				writeSimpleElement(xmlStreamWriter, "td", property.getDefaultValue());
 				writeValidValues(xmlStreamWriter, property);
-				writeSimpleElement(xmlStreamWriter, "td", property.isExpressionLanguageSupported() ? "Yes" : "No");
+				writeSimpleElement(xmlStreamWriter, "td", property.isExpressionLanguageSupported() ? "Yes"
+						: "No");
 				xmlStreamWriter.writeEndElement();
 			}
 
 			// TODO support dynamic properties...
 			xmlStreamWriter.writeEndElement();
-			
+
 			if (containsSensitiveElement) {
 				writeSensitiveImg(xmlStreamWriter);
 				xmlStreamWriter.writeCharacters(" indicates that a property is a sensitive property");
@@ -295,6 +297,26 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 		}
 	}
 
+	private void writePropertyDescription(XMLStreamWriter xmlStreamWriter, String description)
+			throws XMLStreamException {
+		xmlStreamWriter.writeCharacters(" ");
+		xmlStreamWriter.writeStartElement("img");
+		xmlStreamWriter.writeAttribute("src", "../../html/images/iconInfo.png");
+		xmlStreamWriter.writeAttribute("alt", description);
+		xmlStreamWriter.writeEndElement();
+
+	}
+
+	private void writeValidValueDescription(XMLStreamWriter xmlStreamWriter, String description)
+			throws XMLStreamException {
+		xmlStreamWriter.writeCharacters(" ");
+		xmlStreamWriter.writeStartElement("img");
+		xmlStreamWriter.writeAttribute("src", "../../html/images/iconInfo.png");
+		xmlStreamWriter.writeAttribute("alt", description);
+		xmlStreamWriter.writeEndElement();
+
+	}
+
 	private void writeSensitiveImg(final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
 		xmlStreamWriter.writeCharacters(" ");
 		xmlStreamWriter.writeStartElement("img");
@@ -320,7 +342,14 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
 		if (property.getAllowableValues() != null && property.getAllowableValues().size() > 0) {
 			xmlStreamWriter.writeStartElement("ul");
 			for (AllowableValue value : property.getAllowableValues()) {
-				writeSimpleElement(xmlStreamWriter, "li", value.getDisplayName());
+				xmlStreamWriter.writeStartElement("li");
+				xmlStreamWriter.writeCharacters(value.getDisplayName());
+
+				if (value.getDescription() != null) {
+					writeValidValueDescription(xmlStreamWriter, value.getDescription());
+				}
+				xmlStreamWriter.writeEndElement();
+
 			}
 			xmlStreamWriter.writeEndElement();
 		}

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/60070706/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
index 2637235..4cf6ba8 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/main/java/org/apache/nifi/documentation/html/HtmlProcessorDocumentationWriter.java
@@ -35,9 +35,7 @@ public class HtmlProcessorDocumentationWriter extends HtmlDocumentationWriter {
 	protected void writeAdditionalBodyInfo(final ConfigurableComponent configurableComponent,
 			final XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
 		final Processor processor = (Processor) configurableComponent;
-		xmlStreamWriter.writeStartElement("p");
-		writeSimpleElement(xmlStreamWriter, "strong", "Relationships: ");
-		xmlStreamWriter.writeEndElement();
+		writeSimpleElement(xmlStreamWriter, "h3", "Relationships: ");
 
 		if (processor.getRelationships().size() > 0) {
 			xmlStreamWriter.writeStartElement("table");

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/60070706/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java
index 2a00177..a30133e 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/src/test/java/org/apache/nifi/documentation/example/FullyDocumentedProcessor.java
@@ -22,6 +22,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.nifi.components.AllowableValue;
 import org.apache.nifi.components.PropertyDescriptor;
 import org.apache.nifi.processor.AbstractProcessor;
 import org.apache.nifi.processor.ProcessContext;
@@ -44,7 +45,7 @@ public class FullyDocumentedProcessor extends AbstractProcessor {
 
 	public static final PropertyDescriptor RECURSE = new PropertyDescriptor.Builder().name("Recurse Subdirectories")
 			.description("Indicates whether or not to pull files from subdirectories").required(true)
-			.allowableValues("true", "false").defaultValue("true").build();
+			.allowableValues(new AllowableValue("true", "true", "Should pull from sub directories"), new AllowableValue("false", "false", "Should not pull from sub directories")).defaultValue("true").build();
 
 	public static final PropertyDescriptor POLLING_INTERVAL = new PropertyDescriptor.Builder().name("Polling Interval")
 			.description("Indicates how long to wait before performing a directory listing").required(true)