You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2015/06/03 14:56:08 UTC
svn commit: r1683316 - in /myfaces/tobago/branches/tobago-3.0.x:
tobago-example/tobago-example-demo/src/main/webapp/
tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/
tobago-theme/tobago-theme-standard/src/main/java/...
Author: lofwyr
Date: Wed Jun 3 12:56:08 2015
New Revision: 1683316
URL: http://svn.apache.org/r1683316
Log:
TOBAGO-1368: Create a new theme which uses Bootstrap
- glyphicons: for buttons and links
Modified:
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ButtonRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LinkRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml?rev=1683316&r1=1683315&r2=1683316&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml Wed Jun 3 12:56:08 2015
@@ -31,18 +31,19 @@
</tc:separator>
<tc:button immediate="true" id="previous"
- image="image/prev.png"
+ image="glyphicon-chevron-left"
action="#{navigationState.gotoPrevious}"
disabled="#{navigationState.first}"
label="#{overviewBundle.footer_previous}"/>
<tc:button immediate="true" id="next" defaultCommand="true"
- image="image/next.png"
+ image="glyphicon-chevron-right"
action="#{navigationState.gotoNext}"
disabled="#{navigationState.last}"
label="#{overviewBundle.footer_next}"/>
<tc:button action="#{navigationTree.viewSource}"
+ image="glyphicon-eye-open"
immediate="true" label="#{overviewBundle.footer_viewSource}"
target="Source Viewer" transition="false"/>
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java?rev=1683316&r1=1683315&r2=1683316&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/CommandRendererBase.java Wed Jun 3 12:56:08 2015
@@ -19,7 +19,6 @@
package org.apache.myfaces.tobago.renderkit;
-import org.apache.myfaces.tobago.context.ResourceManagerUtils;
import org.apache.myfaces.tobago.internal.util.FacesContextUtils;
import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
@@ -57,13 +56,4 @@ public abstract class CommandRendererBas
component.queueEvent(new ActionEvent(component));
}
- public String getImageWithPath(final FacesContext facesContext, final String image, final boolean disabled) {
- final int indexOfExtension = ResourceManagerUtils.indexOfExtension(image);
- if (indexOfExtension == -1) {
- return ResourceManagerUtils.getImageOrDisabledImage(facesContext, image, disabled);
- } else {
- return ResourceManagerUtils.getImageOrDisabledImageWithPath(facesContext, image, disabled);
- }
- }
-
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ButtonRenderer.java?rev=1683316&r1=1683315&r2=1683316&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ButtonRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ButtonRenderer.java Wed Jun 3 12:56:08 2015
@@ -22,7 +22,6 @@ package org.apache.myfaces.tobago.render
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.SupportsCss;
import org.apache.myfaces.tobago.component.UIButton;
-import org.apache.myfaces.tobago.context.ResourceManagerUtils;
import org.apache.myfaces.tobago.internal.component.AbstractUICommand;
import org.apache.myfaces.tobago.internal.component.AbstractUIForm;
import org.apache.myfaces.tobago.internal.component.AbstractUIToolBar;
@@ -123,24 +122,7 @@ public class ButtonRenderer extends Comm
writer.flush(); // force closing the start tag
String image = (String) button.getAttributes().get(Attributes.IMAGE);
- if (image != null) {
- if (ResourceManagerUtils.isAbsoluteResource(image)) {
- // absolute Path to image : nothing to do
- } else {
- image = getImageWithPath(facesContext, image, disabled);
- }
- writer.startElement(HtmlElements.IMG, null);
- writer.writeAttribute(HtmlAttributes.SRC, image, true);
- final String tip = button.getTip();
- writer.writeAttribute(HtmlAttributes.ALT, tip != null ? tip : "", true);
- writer.endElement(HtmlElements.IMG);
- }
-
- if (label.getLabel() != null) {
- writer.startElement(HtmlElements.SPAN, null);
- HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
- writer.endElement(HtmlElements.SPAN);
- }
+ HtmlRendererUtils.encodeIconWithLabel(writer, facesContext, image, label, disabled);
writer.endElement(HtmlElements.BUTTON);
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java?rev=1683316&r1=1683315&r2=1683316&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandRenderer.java Wed Jun 3 12:56:08 2015
@@ -110,7 +110,7 @@ public class CommandRenderer extends Com
if (ResourceManagerUtils.isAbsoluteResource(image)) {
// absolute Path to image : nothing to do
} else {
- image = getImageWithPath(facesContext, image, disabled);
+ image = HtmlRendererUtils.getImageWithPath(facesContext, image, disabled);
}
writer.startElement(HtmlElements.IMG, link);
writer.writeClassAttribute(Classes.create(link, "image"));
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LinkRenderer.java?rev=1683316&r1=1683315&r2=1683316&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LinkRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/LinkRenderer.java Wed Jun 3 12:56:08 2015
@@ -20,7 +20,6 @@
package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
import org.apache.myfaces.tobago.config.Configurable;
-import org.apache.myfaces.tobago.context.ResourceManagerUtils;
import org.apache.myfaces.tobago.internal.component.AbstractUILink;
import org.apache.myfaces.tobago.internal.util.AccessKeyLogger;
import org.apache.myfaces.tobago.layout.Measure;
@@ -93,31 +92,7 @@ public class LinkRenderer extends Comman
// image
String image = link.getImage();
- if (image != null) {
- if (ResourceManagerUtils.isAbsoluteResource(image)) {
- // absolute Path to image : nothing to do
- } else {
- image = getImageWithPath(facesContext, image, disabled);
- }
- writer.startElement(HtmlElements.IMG, link);
- writer.writeClassAttribute(Classes.create(link, "image"));
- writer.writeAttribute(HtmlAttributes.SRC, image, true);
- writer.writeAttribute(HtmlAttributes.BORDER, 0); // TODO: is border=0 setting via style possible?
- final String tip = link.getTip();
- writer.writeAttribute(HtmlAttributes.ALT, tip != null ? tip : "", true);
- if (tip != null) {
- writer.writeAttribute(HtmlAttributes.TITLE, tip, true);
- }
- writer.endElement(HtmlElements.IMG);
- }
-
-// label
- if (label.getLabel() != null) {
- if (image != null) {
- writer.write(" "); // separator: e.g.
- }
- HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
- }
+ HtmlRendererUtils.encodeIconWithLabel(writer, facesContext, image, label, disabled);
}
public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java?rev=1683316&r1=1683315&r2=1683316&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/SectionRenderer.java Wed Jun 3 12:56:08 2015
@@ -73,7 +73,7 @@ public class SectionRenderer extends Lay
writer.writeClassAttribute(clazz);
}
final String image = section.getImage();
- HtmlRendererUtils.encodeIconWithLabel(writer, label, image);
+ HtmlRendererUtils.encodeIconWithLabel(writer, image, label);
writer.endElement(tag);
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java?rev=1683316&r1=1683315&r2=1683316&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/HtmlRendererUtils.java Wed Jun 3 12:56:08 2015
@@ -105,12 +105,11 @@ public final class HtmlRendererUtils {
}
}
- public static void encodeIconWithLabel(TobagoResponseWriter writer, String label, String image) throws IOException {
+ public static void encodeIconWithLabel(TobagoResponseWriter writer, String image, String label) throws IOException {
if (image != null && image.startsWith("glyphicon-")) { // XXX hack: should be integrated in the resource manager
writer.startElement(HtmlElements.SPAN, null);
writer.writeClassAttribute(BootstrapClass.GLYPHICON, BootstrapClass.glyphicon(image));
writer.endElement(HtmlElements.SPAN);
-
}
if (image != null && label != null) {
writer.writeText(" ");
@@ -123,6 +122,43 @@ public final class HtmlRendererUtils {
}
}
+ public static void encodeIconWithLabel(
+ TobagoResponseWriter writer, FacesContext facesContext, String image, LabelWithAccessKey label, boolean disabled)
+ throws IOException {
+ if (image != null) {
+ if (image.startsWith("glyphicon-")) {
+ writer.startElement(HtmlElements.SPAN, null);
+ writer.writeClassAttribute(BootstrapClass.GLYPHICON, BootstrapClass.glyphicon(image));
+ writer.endElement(HtmlElements.SPAN);
+ } else {
+ if (ResourceManagerUtils.isAbsoluteResource(image)) {
+ // absolute Path to image : nothing to do
+ } else {
+ image = getImageWithPath(facesContext, image, disabled);
+ }
+ writer.startElement(HtmlElements.IMG, null);
+ writer.writeAttribute(HtmlAttributes.SRC, image, true);
+ writer.writeAttribute(HtmlAttributes.ALT, "", false);
+ writer.endElement(HtmlElements.IMG);
+ }
+ }
+
+ if (label.getLabel() != null) {
+ writer.startElement(HtmlElements.SPAN, null);
+ HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
+ writer.endElement(HtmlElements.SPAN);
+ }
+ }
+
+ public static String getImageWithPath(final FacesContext facesContext, final String image, final boolean disabled) {
+ final int indexOfExtension = ResourceManagerUtils.indexOfExtension(image);
+ if (indexOfExtension == -1) {
+ return ResourceManagerUtils.getImageOrDisabledImage(facesContext, image, disabled);
+ } else {
+ return ResourceManagerUtils.getImageOrDisabledImageWithPath(facesContext, image, disabled);
+ }
+ }
+
public static TobagoResponseWriter getTobagoResponseWriter(final FacesContext facesContext) {
final ResponseWriter writer = facesContext.getResponseWriter();