Author: abelevich
Date: 2011-01-18 07:20:02 -0500 (Tue, 18 Jan 2011)
New Revision: 21053
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPopupPanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractProgressBar.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarStateEncoder.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java
trunk/ui/output/ui/src/main/templates/popupPanel.template.xml
trunk/ui/output/ui/src/main/templates/progressBar.template.xml
Log:
RF-10097 Inline default values: output components I
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPopupPanel.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPopupPanel.java 2011-01-18
09:13:11 UTC (rev 21052)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPopupPanel.java 2011-01-18
12:20:02 UTC (rev 21053)
@@ -44,34 +44,34 @@
@Attribute
public abstract String getVisualOptions();
- @Attribute(defaultValue = "100")
+ @Attribute
public abstract int getZindex();
- @Attribute(defaultValue = "-1")
+ @Attribute
public abstract int getHeight();
- @Attribute(defaultValue = "-1")
+ @Attribute
public abstract int getWidth();
- @Attribute(defaultValue = "-1")
+ @Attribute
public abstract int getMinHeight();
- @Attribute(defaultValue = "-1")
+ @Attribute
public abstract int getMinWidth();
- @Attribute(defaultValue = "" + Integer.MAX_VALUE)
+ @Attribute
public abstract int getMaxHeight();
- @Attribute(defaultValue = "" + Integer.MAX_VALUE)
+ @Attribute
public abstract int getMaxWidth();
- @Attribute(defaultValue = "auto")
+ @Attribute
public abstract String getTop();
- @Attribute(defaultValue = "auto")
+ @Attribute
public abstract String getLeft();
- @Attribute(defaultValue = "false")
+ @Attribute
public abstract boolean isShow();
public abstract void setShow(boolean show);
@@ -79,22 +79,22 @@
@Attribute(defaultValue = "true")
public abstract boolean isMoveable();
- @Attribute(defaultValue = "false")
+ @Attribute
public abstract boolean isAutosized();
@Attribute(defaultValue = "true")
public abstract boolean isModal();
- @Attribute(defaultValue = "false")
+ @Attribute
public abstract boolean isKeepVisualState();
- @Attribute(defaultValue = "false")
+ @Attribute
public abstract boolean isOverlapEmbedObjects();
- @Attribute(defaultValue = "false")
+ @Attribute
public abstract boolean isResizeable();
- @Attribute(defaultValue = "false")
+ @Attribute
public abstract boolean isTrimOverlayedElements();
@Attribute
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractProgressBar.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractProgressBar.java 2011-01-18
09:13:11 UTC (rev 21052)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractProgressBar.java 2011-01-18
12:20:02 UTC (rev 21053)
@@ -96,10 +96,10 @@
public abstract void setData(Object data);
- @Attribute(defaultValue = "1000")
+ @Attribute
public abstract int getInterval();
- @Attribute(defaultValue = "false")
+ @Attribute
public abstract boolean isEnabled();
@Attribute(events = @EventName("beforedomupdate"))
@@ -123,13 +123,13 @@
@Attribute
public abstract String getFinishClass();
- @Attribute(defaultValue = "SwitchType.DEFAULT")
+ @Attribute
public abstract SwitchType getMode();
- @Attribute(defaultValue = "100")
+ @Attribute
public abstract int getMaxValue();
- @Attribute(defaultValue = "0")
+ @Attribute
public abstract int getMinValue();
@Attribute
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java 2011-01-18
09:13:11 UTC (rev 21052)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolbar.java 2011-01-18
12:20:02 UTC (rev 21053)
@@ -44,7 +44,7 @@
@Attribute
public abstract String getHeight();
- @Attribute(defaultValue = "100%")
+ @Attribute
public abstract String getWidth();
@Attribute
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2011-01-18
09:13:11 UTC (rev 21052)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2011-01-18
12:20:02 UTC (rev 21053)
@@ -37,6 +37,9 @@
private static final int SIZE = 10;
private static final String STATE_OPTION_SUFFIX = "StateOption_";
+ private static final String DEFAULT_PROPERTY_LEFT = "auto";
+ private static final String DEFAULT_PROPERTY_TOP = "auto";
+
//TODO nick - use enums
private static final Set<String> ALLOWED_ATTACHMENT_OPTIONS = new
HashSet<String>();
static {
@@ -207,4 +210,36 @@
+ "] must be instance of Map or String, but its type is " +
value.getClass().getSimpleName());
}
}
+
+ protected String getLeftOrDefault(UIComponent component) {
+ String leftProperty = ((AbstractPopupPanel) component).getLeft();
+ if (leftProperty == null || leftProperty.length() == 0) {
+ leftProperty = DEFAULT_PROPERTY_LEFT;
+ }
+ return leftProperty;
+ }
+
+ protected String getTopOrDefault(UIComponent component) {
+ String topProperty = ((AbstractPopupPanel) component).getTop();
+ if (topProperty == null || topProperty.length() == 0) {
+ topProperty = DEFAULT_PROPERTY_TOP;
+ }
+ return topProperty;
+ }
+
+ protected int getMaxWidthOrDefault(UIComponent component) {
+ int maxWidth = ((AbstractPopupPanel) component).getMaxWidth();
+ if (maxWidth == 0) {
+ maxWidth = Integer.MAX_VALUE;
+ }
+ return maxWidth;
+ }
+
+ protected int getMaxHeightOrDefault(UIComponent component) {
+ int maxHeight = ((AbstractPopupPanel) component).getMaxHeight();
+ if (maxHeight == 0) {
+ maxHeight = Integer.MAX_VALUE;
+ }
+ return maxHeight;
+ }
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java 2011-01-18
09:13:11 UTC (rev 21052)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java 2011-01-18
12:20:02 UTC (rev 21053)
@@ -74,6 +74,10 @@
private static final ProgressBarStateEncoder FULL_ENCODER = new
ProgressBarStateEncoder(false);
private static final ProgressBarStateEncoder PARTIAL_ENCODER = new
ProgressBarStateEncoder(true);
+
+ private static final int DEFAULT_MIN_VALUE = 0;
+
+ private static final int DEFAULT_MAX_VALUE = 100;
@Override
protected void doDecode(FacesContext context, UIComponent component) {
@@ -98,7 +102,7 @@
return false;
}
- SwitchType mode = (SwitchType) component.getAttributes().get("mode");
+ SwitchType mode = getModeOrDefault(component);
if (mode == SwitchType.server) {
throw new IllegalArgumentException("Progress bar doesn't support
'server' mode");
@@ -190,4 +194,28 @@
protected ProgressBarStateEncoder getEncoder(FacesContext facesContext, UIComponent
component) {
return isAjaxMode(component) ? PARTIAL_ENCODER : FULL_ENCODER;
}
+
+ protected int getMaxValueOrDefault(UIComponent component) {
+ int maxValue = ((AbstractProgressBar) component).getMaxValue();
+ if (maxValue == 0) {
+ maxValue = DEFAULT_MAX_VALUE;
+ }
+ return maxValue;
+ }
+
+ protected int getMinValueOrDefault(UIComponent component) {
+ int maxValue = ((AbstractProgressBar) component).getMinValue();
+ if (maxValue == 0) {
+ maxValue = DEFAULT_MIN_VALUE;
+ }
+ return maxValue;
+ }
+
+ protected SwitchType getModeOrDefault(UIComponent component) {
+ SwitchType mode = ((AbstractProgressBar) component).getMode();
+ if (mode == null) {
+ mode = SwitchType.DEFAULT;
+ }
+ return mode;
+ }
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarStateEncoder.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarStateEncoder.java 2011-01-18
09:13:11 UTC (rev 21052)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarStateEncoder.java 2011-01-18
12:20:02 UTC (rev 21053)
@@ -79,8 +79,8 @@
protected String getWidth(UIComponent component) {
Number value =
NumberUtils.getNumber(component.getAttributes().get("value"));
- Number minValue =
NumberUtils.getNumber(component.getAttributes().get("minValue"));
- Number maxValue =
NumberUtils.getNumber(component.getAttributes().get("maxValue"));
+ Number minValue =
NumberUtils.getNumber(component.getAttributes().get("minValue") == null ? 0 :
component.getAttributes().get("minValue"));
+ Number maxValue =
NumberUtils.getNumber(component.getAttributes().get("maxValue") == null ? 100 :
component.getAttributes().get("maxValue"));
Number percent = calculatePercent(value, minValue, maxValue);
return String.valueOf(percent.intValue());
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java 2011-01-18
09:13:11 UTC (rev 21052)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarRendererBase.java 2011-01-18
12:20:02 UTC (rev 21053)
@@ -355,7 +355,11 @@
protected String getWidthToolbar(UIComponent component) {
if (component instanceof AbstractToolbar) {
- return HtmlDimensions.formatSize(((AbstractToolbar)component).getWidth());
+ String width = ((AbstractToolbar)component).getWidth();
+ if (width == null || width.length() == 0) {
+ return "100%";
+ }
+ return HtmlDimensions.formatSize(width);
} else {
return "";
}
Modified: trunk/ui/output/ui/src/main/templates/popupPanel.template.xml
===================================================================
--- trunk/ui/output/ui/src/main/templates/popupPanel.template.xml 2011-01-18 09:13:11 UTC
(rev 21052)
+++ trunk/ui/output/ui/src/main/templates/popupPanel.template.xml 2011-01-18 12:20:02 UTC
(rev 21053)
@@ -73,9 +73,13 @@
</div>
<cdk:scriptObject name="options">
- <cdk:scriptOption attributes="width height minWidth minHeight
maxWidth maxHeight moveable followByScroll left top zindex shadowDepth shadowOpacity
domElementAttachment show keepVisualState autosized resizeable modal overlapEmbedObjects
visualOptions " />
- <cdk:scriptOption attributes="onshow onhide onresize onmove
onbeforeshow onbeforehide" wrapper="eventHandler"/>
- </cdk:scriptObject>
+ <cdk:scriptOption name="left"
value="#{getLeftOrDefault(component)}"/>
+ <cdk:scriptOption name="top"
value="#{getTopOrDefault(component)}"/>
+ <cdk:scriptOption name="maxWidth"
value="#{getMaxWidthOrDefault(component)}"/>
+ <cdk:scriptOption name="maxHeight"
value="#{getMaxHeightOrDefault(component)}"/>
+ <cdk:scriptOption attributes="width height minWidth minHeight moveable
followByScroll zindex shadowDepth shadowOpacity domElementAttachment show keepVisualState
autosized resizeable modal overlapEmbedObjects visualOptions " />
+ <cdk:scriptOption attributes="onshow onhide onresize onmove onbeforeshow
onbeforehide" wrapper="eventHandler"/>
+ </cdk:scriptObject>
<script type="text/javascript">
new RichFaces.ui.PopupPanel(#{toScriptArgs(clientId, options)});
Modified: trunk/ui/output/ui/src/main/templates/progressBar.template.xml
===================================================================
--- trunk/ui/output/ui/src/main/templates/progressBar.template.xml 2011-01-18 09:13:11 UTC
(rev 21052)
+++ trunk/ui/output/ui/src/main/templates/progressBar.template.xml 2011-01-18 12:20:02 UTC
(rev 21053)
@@ -37,8 +37,8 @@
<script type="text/javascript">
<cdk:scriptObject name="options">
<cdk:scriptOption name="submitFunction"
value="#{getSubmitFunction(facesContext, component)}" />
- <cdk:scriptOption name="minValue"
value="#{component.attributes['minValue']}" defaultValue="0"
/>
- <cdk:scriptOption name="maxValue"
value="#{component.attributes['maxValue']}" defaultValue="100"
/>
+ <cdk:scriptOption name="minValue"
value="#{getMinValueOrDefault(component)}" />
+ <cdk:scriptOption name="maxValue"
value="#{getMaxValueOrDefault(component)}" />
<cdk:scriptOption attributes="interval enabled value onfinish
resource" />
</cdk:scriptObject>
Show replies by date