Skip to content

Commit

Permalink
Merge pull request #805 from chongma/iconAwesomePanel
Browse files Browse the repository at this point in the history
iconAwesome on panel
  • Loading branch information
TheCoder4eu authored Jun 11, 2017
2 parents 5d80071 + 232f09f commit dd5d9fb
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 2 deletions.
119 changes: 119 additions & 0 deletions src/main/java/net/bootsfaces/component/panel/Panel.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ protected enum PropertyKeys {
disabled,
display,
hidden,
icon,
iconAlign,
iconAwesome,
iconFlip,
iconRotate,
iconSize,
iconSpin,
immediate,
largeScreen,
look,
Expand Down Expand Up @@ -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. <P>
* @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. <P>
* 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. <P>
* @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. <P>
* 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. <P>
* @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. <P>
* 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). <P>
* @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). <P>
* 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. <P>
* @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. <P>
* 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. <P>
* @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. <P>
* 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. <P>
* @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. <P>
* 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. <P>
Expand Down
36 changes: 34 additions & 2 deletions src/main/java/net/bootsfaces/component/panel/PanelRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit dd5d9fb

Please sign in to comment.