You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2018/09/20 21:24:31 UTC
[juneau] branch master updated: Use unicode dingbat for tooltip
icon.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 034cd93 Use unicode dingbat for tooltip icon.
034cd93 is described below
commit 034cd93965c3e9a9335d515d88a4099a6a1fe9a6
Author: JamesBognar <ja...@apache.org>
AuthorDate: Thu Sep 20 17:24:19 2018 -0400
Use unicode dingbat for tooltip icon.
---
.../java/org/apache/juneau/dto/html5/HtmlText.java | 70 +++++++++-------------
.../apache/juneau/xml/XmlSerializerSession.java | 13 +++-
.../examples/rest/petstore/AddOrderMenuItem.java | 4 +-
.../examples/rest/petstore/AddPetMenuItem.java | 8 +--
.../examples/rest/petstore/PetStoreResource.java | 12 ++--
.../org/apache/juneau/rest/widget/Tooltip.java | 9 +--
.../apache/juneau/rest/widget/QueryMenuItem.html | 6 +-
7 files changed, 59 insertions(+), 63 deletions(-)
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddOrderMenuItem.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlText.java
similarity index 54%
copy from juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddOrderMenuItem.java
copy to juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlText.java
index b1df268..56b583d 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddOrderMenuItem.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/html5/HtmlText.java
@@ -10,55 +10,41 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.examples.rest.petstore;
+package org.apache.juneau.dto.html5;
-import static org.apache.juneau.dto.html5.HtmlBuilder.*;
-import static org.apache.juneau.http.HttpMethodName.*;
+import static org.apache.juneau.xml.annotation.XmlFormat.*;
-import org.apache.juneau.rest.*;
-import org.apache.juneau.rest.widget.*;
+import org.apache.juneau.xml.annotation.*;
/**
- * Menu item for adding a Pet.
+ * An object that gets serialized as raw XML by the XML and HTML serializers.
+ *
+ * <p>
+ * Can be used to serialize text containing markup without escaping the markup.
+ * For example:
+ *
+ * <h5 class='figure'>Example:</h5>
+ * <p class='bcode w800'>
+ * HtmlText t = <jk>new</jk> HtmlText(<js>"<span>&#2753;</span>"</js>);
+ * </p>
+ *
+ *
*/
-public class AddOrderMenuItem extends MenuItemWidget {
+@Xml(format=XMLTEXT)
+public class HtmlText {
+ private final String text;
- @Override /* MenuItemWidget */
- public String getLabel(RestRequest req) throws Exception {
- return "add";
+ /**
+ * Constructor.
+ *
+ * @param text Raw text.
+ */
+ public HtmlText(String text) {
+ this.text = text;
}
- @Override /* MenuItemWidget */
- public String getBeforeShowScript(RestRequest req) throws Exception {
- return loadScript("AddOrderMenuItem_beforeShow.js");
- }
-
- @Override /* Widget */
- public Object getContent(RestRequest req) throws Exception {
-
- return div(
- form().id("form").action("servlet:/store/order").method(POST).children(
- table(
- tr(
- th("Pet:"),
- td(
- select().id("addPet_names").name("petId")
- ),
- td(new Tooltip("(?)", "The pet to purchase."))
- ),
- tr(
- th("Ship date:"),
- td(input().name("shipDate").type("date")),
- td(new Tooltip("(?)", "The requested ship date."))
- ),
- tr(
- td().colspan(2).style("text-align:right").children(
- button("reset", "Reset"),
- button("submit", "Submit")
- )
- )
- ).style("white-space:nowrap")
- )
- );
+ @Override
+ public String toString() {
+ return text;
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
index 08a6e17..f4f2b7b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java
@@ -426,7 +426,7 @@ public class XmlSerializerSession extends WriterSerializerSession {
if (sType.isUri() || (pMeta != null && pMeta.isUri())) {
out.textUri(o);
} else if (sType.isCharSequence() || sType.isChar()) {
- if (format == XMLTEXT)
+ if (isXmlText(format, sType))
out.append(o);
else
out.text(o, preserveWhitespace);
@@ -454,7 +454,7 @@ public class XmlSerializerSession extends WriterSerializerSession {
} else if (sType.isReader() || sType.isInputStream()) {
IOUtils.pipe(o, out);
} else {
- if (format == XMLTEXT)
+ if (isXmlText(format, sType))
out.append(toString(o));
else
out.text(toString(o));
@@ -484,6 +484,15 @@ public class XmlSerializerSession extends WriterSerializerSession {
return rc;
}
+ private boolean isXmlText(XmlFormat format, ClassMeta<?> sType) {
+ if (format == XMLTEXT)
+ return true;
+ XmlClassMeta xcm = sType.getExtendedMeta(XmlClassMeta.class);
+ if (xcm == null)
+ return false;
+ return xcm.getFormat() == XMLTEXT;
+ }
+
private ContentResult serializeMap(XmlWriter out, Map m, ClassMeta<?> sType,
ClassMeta<?> eKeyType, ClassMeta<?> eValueType, boolean isMixed) throws Exception {
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddOrderMenuItem.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddOrderMenuItem.java
index b1df268..298a6ff 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddOrderMenuItem.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddOrderMenuItem.java
@@ -44,12 +44,12 @@ public class AddOrderMenuItem extends MenuItemWidget {
td(
select().id("addPet_names").name("petId")
),
- td(new Tooltip("(?)", "The pet to purchase."))
+ td(new Tooltip("❓", "The pet to purchase."))
),
tr(
th("Ship date:"),
td(input().name("shipDate").type("date")),
- td(new Tooltip("(?)", "The requested ship date."))
+ td(new Tooltip("❓", "The requested ship date."))
),
tr(
td().colspan(2).style("text-align:right").children(
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddPetMenuItem.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddPetMenuItem.java
index de094ce..10aba70 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddPetMenuItem.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/AddPetMenuItem.java
@@ -36,7 +36,7 @@ public class AddPetMenuItem extends MenuItemWidget {
tr(
th("Name:"),
td(input().name("name").type("text")),
- td(new Tooltip("(?)", "The name of the pet.", br(), "e.g. 'Fluffy'"))
+ td(new Tooltip("❓", "The name of the pet.", br(), "e.g. 'Fluffy'"))
),
tr(
th("Species:"),
@@ -45,17 +45,17 @@ public class AddPetMenuItem extends MenuItemWidget {
option("cat"), option("dog"), option("bird"), option("fish"), option("mouse"), option("rabbit"), option("snake")
)
),
- td(new Tooltip("(?)", "The kind of animal."))
+ td(new Tooltip("❓", "The kind of animal."))
),
tr(
th("Price:"),
td(input().name("price").type("number").placeholder("1.0").step("0.01").min(1).max(100).value(9.99)),
- td(new Tooltip("(?)", "The price to charge for this pet."))
+ td(new Tooltip("❓", "The price to charge for this pet."))
),
tr(
th("Tags:"),
td(input().name("tags").type("text")),
- td(new Tooltip("(?)", "Arbitrary textual tags (comma-delimited).", br(), "e.g. 'fluffy,friendly'"))
+ td(new Tooltip("❓", "Arbitrary textual tags (comma-delimited).", br(), "e.g. 'fluffy,friendly'"))
),
tr(
td().colspan(2).style("text-align:right").children(
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java
index 6461a90..6fce0cc 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/petstore/PetStoreResource.java
@@ -264,12 +264,12 @@ public class PetStoreResource extends BasicRestServletJena {
tr(
th("Id:"),
td(input().name("id").type("text").value(petId).readonly(true)),
- td(new Tooltip("(?)", "The name of the pet.", br(), "e.g. 'Fluffy'"))
+ td(new Tooltip("❓", "The name of the pet.", br(), "e.g. 'Fluffy'"))
),
tr(
th("Name:"),
td(input().name("name").type("text").value(pet.getName())),
- td(new Tooltip("(?)", "The name of the pet.", br(), "e.g. 'Fluffy'"))
+ td(new Tooltip("❓", "The name of the pet.", br(), "e.g. 'Fluffy'"))
),
tr(
th("Species:"),
@@ -278,17 +278,17 @@ public class PetStoreResource extends BasicRestServletJena {
option("cat"), option("dog"), option("bird"), option("fish"), option("mouse"), option("rabbit"), option("snake")
).choose(pet.getSpecies())
),
- td(new Tooltip("(?)", "The kind of animal."))
+ td(new Tooltip("❓", "The kind of animal."))
),
tr(
th("Price:"),
td(input().name("price").type("number").placeholder("1.0").step("0.01").min(1).max(100).value(pet.getPrice())),
- td(new Tooltip("(?)", "The price to charge for this pet."))
+ td(new Tooltip("❓", "The price to charge for this pet."))
),
tr(
th("Tags:"),
td(input().name("tags").type("text").value(PetTag.asString(pet.getTags()))),
- td(new Tooltip("(?)", "Arbitrary textual tags (comma-delimited).", br(), "e.g. 'fluffy,friendly'"))
+ td(new Tooltip("❓", "Arbitrary textual tags (comma-delimited).", br(), "e.g. 'fluffy,friendly'"))
),
tr(
th("Status:"),
@@ -297,7 +297,7 @@ public class PetStoreResource extends BasicRestServletJena {
option("AVAILABLE"), option("PENDING"), option("SOLD")
).choose(pet.getStatus())
),
- td(new Tooltip("(?)", "The current status of the animal."))
+ td(new Tooltip("❓", "The current status of the animal."))
),
tr(
td().colspan(2).style("text-align:right").children(
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/Tooltip.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/Tooltip.java
index ebe7fbd..e42dc31 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/Tooltip.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/widget/Tooltip.java
@@ -33,7 +33,7 @@ import org.apache.juneau.dto.html5.*;
*/
public class Tooltip {
- private final String display;
+ private final HtmlText display;
private final List<Object> content;
/**
@@ -41,13 +41,14 @@ public class Tooltip {
*
* @param display
* The normal display text.
- * This is what gets rendered normally.
+ * <br>This is what gets rendered normally.
+ * <br>The format is raw HTML and can contain markup.
* @param content
* The hover contents.
- * Typically a list of strings, but can also include any HTML5 beans as well.
+ * <br>Typically a list of strings, but can also include any HTML5 beans as well.
*/
public Tooltip(String display, Object...content) {
- this.display = display;
+ this.display = new HtmlText(display);
this.content = new ArrayList<>(Arrays.asList(content));
}
diff --git a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html
index 9e8c6a6..dbbd954 100644
--- a/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html
+++ b/juneau-rest/juneau-rest-server/src/main/resources/org/apache/juneau/rest/widget/QueryMenuItem.html
@@ -22,7 +22,7 @@
</td>
<td>
<div class="tooltip">
- <small>(?)</small>
+ <small>❓</small>
<span class="tooltiptext">
Comma-delimited list of key/value pair search terms.
<br>
@@ -69,7 +69,7 @@
</td>
<td>
<div class="tooltip">
- <small>(?)</small>
+ <small>❓</small>
<span class="tooltiptext">
Comma-delimited list of columns to display.
<br>
@@ -85,7 +85,7 @@
</td>
<td>
<div class="tooltip">
- <small>(?)</small>
+ <small>❓</small>
<span class="tooltiptext">
Comma-delimited list of columns to sort by.
<br>Columns can be suffixed with '-' to indicate descending order.