diff --git a/src/main/java/net/bootsfaces/component/panel/Panel.java b/src/main/java/net/bootsfaces/component/panel/Panel.java index 63addbd60..599535b77 100644 --- a/src/main/java/net/bootsfaces/component/panel/Panel.java +++ b/src/main/java/net/bootsfaces/component/panel/Panel.java @@ -155,6 +155,13 @@ protected enum PropertyKeys { disabled, display, hidden, + icon, + iconAlign, + iconAwesome, + iconFlip, + iconRotate, + iconSize, + iconSpin, immediate, largeScreen, look, @@ -447,6 +454,118 @@ public String getHidden() { public void setHidden(String _hidden) { getStateHelper().put(PropertyKeys.hidden, _hidden); } + + /** + * Panel header Icon, can be one of the Bootstrap icon names. Alignment can be specified with icon-align attribute.

+ * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. + */ + public String getIcon() { + return (String) getStateHelper().eval(PropertyKeys.icon); + } + + /** + * Panel header Icon, can be one of the Bootstrap icon names. Alignment can be specified with icon-align attribute.

+ * Usually this method is called internally by the JSF engine. + */ + public void setIcon(String _icon) { + getStateHelper().put(PropertyKeys.icon, _icon); + } + + /** + * Alignment can be right or left.

+ * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. + */ + public String getIconAlign() { + return (String) getStateHelper().eval(PropertyKeys.iconAlign); + } + + /** + * Alignment can be right or left.

+ * Usually this method is called internally by the JSF engine. + */ + public void setIconAlign(String _iconAlign) { + getStateHelper().put(PropertyKeys.iconAlign, _iconAlign); + } + + /** + * Font Awesome Icon to show in this Panel header, can be one of the Font Awesome icon names. Alignment can be specified with the icon-align attribute.

+ * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. + */ + public String getIconAwesome() { + return (String) getStateHelper().eval(PropertyKeys.iconAwesome); + } + + /** + * Font Awesome Icon to show in this Panel header, can be one of the Font Awesome icon names. Alignment can be specified with the icon-align attribute.

+ * Usually this method is called internally by the JSF engine. + */ + public void setIconAwesome(String _iconAwesome) { + getStateHelper().put(PropertyKeys.iconAwesome, _iconAwesome); + } + + /** + * Flip the icon: can be H (horizontal) or V (vertical).

+ * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. + */ + public String getIconFlip() { + return (String) getStateHelper().eval(PropertyKeys.iconFlip); + } + + /** + * Flip the icon: can be H (horizontal) or V (vertical).

+ * Usually this method is called internally by the JSF engine. + */ + public void setIconFlip(String _iconFlip) { + getStateHelper().put(PropertyKeys.iconFlip, _iconFlip); + } + + /** + * Rotate 90 degrees the icon: Can be L,R.

+ * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. + */ + public String getIconRotate() { + return (String) getStateHelper().eval(PropertyKeys.iconRotate); + } + + /** + * Rotate 90 degrees the icon: Can be L,R.

+ * Usually this method is called internally by the JSF engine. + */ + public void setIconRotate(String _iconRotate) { + getStateHelper().put(PropertyKeys.iconRotate, _iconRotate); + } + + /** + * Icon Size: legal values are lg, 2x, 3x, 4x, 5x.

+ * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. + */ + public String getIconSize() { + return (String) getStateHelper().eval(PropertyKeys.iconSize); + } + + /** + * Icon Size: legal values are lg, 2x, 3x, 4x, 5x.

+ * Usually this method is called internally by the JSF engine. + */ + public void setIconSize(String _iconSize) { + getStateHelper().put(PropertyKeys.iconSize, _iconSize); + } + + /** + * Boolean value: if true the icon will spin.

+ * @return Returns the value of the attribute, or , false, if it hasn't been set by the JSF file. + */ + public boolean isIconSpin() { + return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.iconSpin, false); + } + + /** + * Boolean value: if true the icon will spin.

+ * Usually this method is called internally by the JSF engine. + */ + public void setIconSpin(boolean _iconSpin) { + getStateHelper().put(PropertyKeys.iconSpin, _iconSpin); + } /** * Flag indicating that, if this component is activated by the user, notifications should be delivered to interested listeners and actions immediately (that is, during Apply Request Values phase) rather than waiting until Invoke Application phase. Default is false.

diff --git a/src/main/java/net/bootsfaces/component/panel/PanelRenderer.java b/src/main/java/net/bootsfaces/component/panel/PanelRenderer.java index ca02c3b5c..c3a0495b0 100644 --- a/src/main/java/net/bootsfaces/component/panel/PanelRenderer.java +++ b/src/main/java/net/bootsfaces/component/panel/PanelRenderer.java @@ -28,6 +28,7 @@ import javax.faces.render.FacesRenderer; import net.bootsfaces.component.ajax.AJAXRenderer; +import net.bootsfaces.component.icon.IconRenderer; import net.bootsfaces.render.CoreRenderer; import net.bootsfaces.render.Responsive; import net.bootsfaces.render.Tooltip; @@ -112,7 +113,16 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx } else { _styleClass += " "; } - + + String icon = panel.getIcon(); + String faicon = panel.getIconAwesome(); + boolean fa = false; // flag to indicate whether the selected icon set is + // Font Awesome or not. + if (faicon != null) { + icon = faicon; + fa = true; + } + rw.startElement("div", panel); if (!(isCollapsible && null == accordionParent)) { rw.writeAttribute("id", clientId, "id"); @@ -154,7 +164,29 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx writeTitleLink(panel, rw, jQueryClientID, accordionParent); } - rw.writeText(_title, null); + if (icon != null) { + + Object ialign = panel.getIconAlign(); // Default Left + + if (ialign != null && ialign.equals("right")) { + _title = _title != null ? _title + " " : null; + writeText(rw, _title, null); + IconRenderer.encodeIcon(rw, component, icon, fa, panel.getIconSize(), panel.getIconRotate(), panel.getIconFlip(), panel.isIconSpin(), null, null, false, false, false, false); + } else { + IconRenderer.encodeIcon(rw, component, icon, fa, panel.getIconSize(), panel.getIconRotate(), panel.getIconFlip(), panel.isIconSpin(), null, null, false, false, false, false); + _title = _title != null ? " " + _title : null; + writeText(rw, _title, null); + } + + } else { + if (component.getChildCount() > 0) { + _title = _title != null ? " " + _title : null; + writeText(rw, _title, null); + } else { + writeText(rw, _title, null); + } + } +// rw.writeText(_title, null); if (isCollapsible) { rw.endElement("a"); }