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 22:58:57 UTC
svn commit: r1734998 - in /myfaces/tobago/branches/tobago-3.0.x:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/
tobago-core/src/main/java/org/apache...
Author: lofwyr
Date: Mon Mar 14 21:58:56 2016
New Revision: 1734998
URL: http://svn.apache.org/viewvc?rev=1734998&view=rev
Log:
TOBAGO-1545: Adapt the tc:progress to Bootstrap
Modified:
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIProgress.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ProgressTagDeclaration.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java
myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlElements.java
myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/020-output/50-progress/progress.xhtml
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIProgress.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIProgress.java?rev=1734998&r1=1734997&r2=1734998&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIProgress.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIProgress.java Mon Mar 14 21:58:56 2016
@@ -20,8 +20,64 @@
package org.apache.myfaces.tobago.internal.component;
import org.apache.myfaces.tobago.component.Visual;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.faces.component.UIOutput;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ComponentSystemEventListener;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.PreRenderComponentEvent;
+import javax.swing.BoundedRangeModel;
-public abstract class AbstractUIProgress extends UIOutput implements Visual {
+@ListenerFor(systemEventClass = PreRenderComponentEvent.class)
+public abstract class AbstractUIProgress extends UIOutput implements Visual, ComponentSystemEventListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractUIProgress.class);
+
+ private double rangeValue;
+ private double rangeMax;
+
+ public double getRangeValue() {
+ return rangeValue;
+ }
+
+ public double getRangeMax() {
+ return rangeMax;
+ }
+
+ @Override
+ public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
+
+ if (event instanceof PreRenderComponentEvent) {
+ Object model = getValue();
+ if (model instanceof BoundedRangeModel) {
+ BoundedRangeModel m = (BoundedRangeModel) model;
+ rangeValue = (double) m.getValue();
+ rangeMax = (double) m.getMaximum();
+ final int min = m.getMinimum();
+ if (min != 0) {
+ rangeValue -= min;
+ rangeMax -= min;
+ }
+ } else {
+ if (model instanceof Number) {
+ rangeValue = ((Number) model).doubleValue();
+ } else {
+ rangeValue = Double.parseDouble("" + model);
+ }
+ if (getMax() != null) {
+ rangeMax = getMax();
+ } else {
+ rangeMax = 1.0;
+ }
+ if (rangeValue > rangeMax) {
+ rangeValue = rangeMax;
+ }
+ }
+ }
+ }
+
+ public abstract Double getMax();
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ProgressTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ProgressTagDeclaration.java?rev=1734998&r1=1734997&r2=1734998&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ProgressTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ProgressTagDeclaration.java Mon Mar 14 21:58:56 2016
@@ -53,11 +53,19 @@ import javax.faces.component.UIOutput;
public interface ProgressTagDeclaration extends HasIdBindingAndRendered, HasTip, IsVisual {
/**
- * The current value of this component.
+ * The current value of this component. May be a java.lang.Number or a javax.swing.BoundedRangeModel
*/
@TagAttribute
@UIComponentTagAttribute(
- type = { "javax.swing.BoundedRangeModel" },
+ type = { "javax.swing.BoundedRangeModel", "java.lang.Double" },
expression = DynamicExpression.VALUE_EXPRESSION_REQUIRED)
void setValue(String value);
+
+ /**
+ * The maximum of the value of the progress.
+ */
+ @TagAttribute
+ @UIComponentTagAttribute(
+ type = { "java.lang.Double" })
+ void setMax(String max);
}
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java?rev=1734998&r1=1734997&r2=1734998&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlAttributes.java Mon Mar 14 21:58:56 2016
@@ -46,6 +46,7 @@ public enum HtmlAttributes implements Ma
HTTP_EQUIV("http-equiv"),
ID("id"),
LABEL("label"),
+ MAX("max"),
MAXLENGTH("maxlength"),
MEDIA("media"),
METHOD("method"),
Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlElements.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlElements.java?rev=1734998&r1=1734997&r2=1734998&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlElements.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlElements.java Mon Mar 14 21:58:56 2016
@@ -98,7 +98,7 @@ public enum HtmlElements {
P("p"),
PARAM("param", Qualifier.VOID),
PRE("pre"),
- PRODRESS("prodress"),
+ PROGRESS("progress"),
Q("q"),
RP("rp"),
RT("rt"),
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=1734998&r1=1734997&r2=1734998&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 21:58:56 2016
@@ -21,23 +21,33 @@
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
-
- <ui:param name="title" value="Simple progress example with reload facet"/>
+ <ui:param name="title" value="#{overviewBundle.progress}"/>
<tc:panel>
- <f:facet name="reload">
- <tc:reload frequency="2000" update="#{progress.update}"/>
- </f:facet>
- <f:facet name="layout">
- <tc:gridLayout rows="auto;1*" columns="100px;1* "/>
- </f:facet>
- <tc:label value="Progress:"/>
- <tc:progress value="#{progress.progress}">
- <f:facet name="complete">
- <tc:command action="#{progress.reset}"/>
+
+ <p>Simple progress example with reload facet</p>
+
+ <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>
- </tc:progress>
- <tc:panel/>
- </tc:panel>
+ <tc:flexLayout columns="auto;*">
+
+ <tc:label value="Progress:"/>
+ <tc:progress value="#{progress.progress}">
+ <f:facet name="complete">
+ <tc:command action="#{progress.reset}"/>
+ </f:facet>
+ </tc:progress>
+ </tc:flexLayout>
+ </tc:panel>
+ <tc:flexLayout columns="auto;*">
+ <tc:label value="Progress:"/>
+ <tc:progress value="0.3" max="1"/>
+ </tc:flexLayout>
+
+ </tc:panel>
</ui:composition>