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 2016/03/14 23:17:20 UTC
svn commit: r1734999 - in /myfaces/tobago/branches/tobago-3.0.x:
tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/
tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/s...
Author: lofwyr
Date: Mon Mar 14 22:17:20 2016
New Revision: 1734999
URL: http://svn.apache.org/viewvc?rev=1734999&view=rev
Log:
TOBAGO-1545: Adapt the tc:progress to Bootstrap
Modified:
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml
myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ProgressRenderer.java
myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml?rev=1734999&r1=1734998&r2=1734999&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml Mon Mar 14 22:17:20 2016
@@ -30,16 +30,20 @@
<p><b>TODO:</b> May be subject of change... use AjaxClientBehavior</p>
<tc:panel>
- <f:facet name="reload">
- <tc:reload frequency="2000" update="#{progress.update}"/>
- </f:facet>
+ <!--
+ <f:facet name="reload">
+ <tc:reload frequency="2000" update="#{progress.update}"/>
+ </f:facet>
+ -->
<tc:flexLayout columns="auto;*">
<tc:label value="Progress:"/>
<tc:progress value="#{progress.progress}">
- <f:facet name="complete">
- <tc:command action="#{progress.reset}"/>
- </f:facet>
+ <!--
+ <f:facet name="complete">
+ <tc:command action="#{progress.reset}"/>
+ </f:facet>
+-->
</tc:progress>
</tc:flexLayout>
</tc:panel>
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/ProgressRenderer.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/ProgressRenderer.java?rev=1734999&r1=1734998&r2=1734999&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/ProgressRenderer.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/ProgressRenderer.java Mon Mar 14 22:17:20 2016
@@ -32,8 +32,6 @@ import org.slf4j.LoggerFactory;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.swing.BoundedRangeModel;
-import javax.swing.DefaultBoundedRangeModel;
import java.io.IOException;
public class ProgressRenderer extends RendererBase {
@@ -41,43 +39,39 @@ public class ProgressRenderer extends Re
private static final Logger LOG = LoggerFactory.getLogger(ProgressRenderer.class);
@Override
- public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {
+ public void encodeBegin(final FacesContext facesContext, final UIComponent component) throws IOException {
final UIProgress progress = (UIProgress) component;
- BoundedRangeModel model = (BoundedRangeModel) progress.getValue();
-
- if (model == null) {
- LOG.warn("'null' value found! Using dummy Model instead!");
- model = new DefaultBoundedRangeModel(0, 1, 0, 100);
- }
+ final double value = progress.getRangeValue();
+ final double max = progress.getRangeMax();
- final int diff = model.getMaximum() - model.getMinimum();
- Object title = progress.getTip();
- final double percent = 100.0 * model.getValue() / diff;
- if (title == null && diff > 0) {
- title = Integer.toString((int) percent) + " %";
+ String title = progress.getTip();
+ if (title == null && max > 0) {
+ title = Integer.toString((int) (value / max)) + " %";
}
final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
- writer.startElement(HtmlElements.DIV);
+ writer.startElement(HtmlElements.PROGRESS);
+ writer.writeIdAttribute(progress.getClientId(facesContext));
writer.writeClassAttribute(Classes.create(progress), progress.getCustomClass());
HtmlRendererUtils.writeDataAttributes(facesContext, writer, progress);
writer.writeStyleAttribute(progress.getStyle());
- if (title != null) {
- writer.writeAttribute(HtmlAttributes.TITLE, String.valueOf(title), true);
- }
+ writer.writeAttribute(HtmlAttributes.TITLE, title, true);
+ writer.writeAttribute(HtmlAttributes.MAX, Double.toString(max), false);
+ writer.writeAttribute(HtmlAttributes.VALUE, Double.toString(value), false);
+
final UIComponent facet = progress.getFacet("complete");
- if (model.getValue() == model.getMaximum() && facet instanceof UICommand) {
+ if (value == max && facet instanceof UICommand) {
HtmlRendererUtils.renderCommandFacet(progress, facesContext, writer);
}
- writer.startElement(HtmlElements.DIV);
- writer.writeClassAttribute(Classes.create(progress, "value"));
- writer.writeStyleAttribute("width: " + percent + "%");
- writer.endElement(HtmlElements.DIV);
+ }
- writer.endElement(HtmlElements.DIV);
+ @Override
+ public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {
+ final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+ writer.endElement(HtmlElements.PROGRESS);
}
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg?rev=1734999&r1=1734998&r2=1734999&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component.stg Mon Mar 14 22:17:20 2016
@@ -374,6 +374,10 @@ LabelLayoutProperty(property) ::= <<
<NormalProperty(property)>
>>
+DoubleProperty(property) ::= <<
+<NormalProperty(property)>
+>>
+
MethodExpressionProperty(property) ::= <<
/**