Support Button captionAsHtml attribute #880

This commit is contained in:
Yuriy Artamonov 2018-05-24 17:17:14 +04:00
parent 9f8df35838
commit f2dc87859d
6 changed files with 51 additions and 0 deletions

View File

@ -49,6 +49,8 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
protected boolean disableOnClick = false;
protected boolean useResponsePending = false;
protected boolean captionAsHtml = false; // just stub
public DesktopButton() {
impl = createImplementation();
impl.addActionListener(new ValidationAwareActionListener() {
@ -243,4 +245,14 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
public void setUseResponsePending(boolean useResponsePending) {
this.useResponsePending = useResponsePending;
}
@Override
public void setCaptionAsHtml(boolean captionAsHtml) {
this.captionAsHtml = captionAsHtml;
}
@Override
public boolean isCaptionAsHtml() {
return captionAsHtml;
}
}

View File

@ -560,5 +560,14 @@ public class DesktopPopupButton extends DesktopAbstractActionsHolderComponent<JB
@Override
public void setUseResponsePending(boolean useResponsePending) {
}
@Override
public void setCaptionAsHtml(boolean captionAsHtml) {
}
@Override
public boolean isCaptionAsHtml() {
return false;
}
}
}

View File

@ -43,4 +43,15 @@ public interface Button extends Component, Component.HasCaption, Component.Belon
* @param useResponsePending whether to use response pending
*/
void setUseResponsePending(boolean useResponsePending);
/**
* Enable or disable HTML mode for caption.
*
* @param captionAsHtml pass true to enable HTML mode for caption.
*/
void setCaptionAsHtml(boolean captionAsHtml);
/**
* @return true if caption is inserted to DOM as HTML
*/
boolean isCaptionAsHtml();
}

View File

@ -1863,6 +1863,7 @@
<xs:attribute name="stylename" type="buttonStylename"/>
<xs:attribute name="action" type="xs:string"/>
<xs:attribute name="invoke" type="xs:string"/>
<xs:attribute name="captionAsHtml" type="xs:boolean"/>
<xs:attribute name="focusable" type="xs:boolean"/>
<xs:attribute name="disableOnClick" type="xs:boolean"/>

View File

@ -64,6 +64,7 @@ public class ButtonLoader extends AbstractComponentLoader<Button> {
loadStyleName(resultComponent, element);
loadCaption(resultComponent, element);
loadCaptionAsHtml(resultComponent, element);
loadDescription(resultComponent, element);
loadAction(resultComponent, element);
loadIcon(resultComponent, element);
@ -81,6 +82,13 @@ public class ButtonLoader extends AbstractComponentLoader<Button> {
loadResponsive(resultComponent, element);
}
protected void loadCaptionAsHtml(Button resultComponent, Element element) {
String captionAsHtml = element.attributeValue("captionAsHtml");
if (StringUtils.isNotEmpty(captionAsHtml)) {
resultComponent.setCaptionAsHtml(Boolean.parseBoolean(captionAsHtml));
}
}
protected void loadDisableOnClick(Button component, Element element) {
String disableOnClick = element.attributeValue("disableOnClick");
if (StringUtils.isNotEmpty(disableOnClick)) {

View File

@ -174,4 +174,14 @@ public class WebButton extends WebAbstractComponent<CubaButton> implements Butto
public void setUseResponsePending(boolean useResponsePending) {
component.setUseResponsePending(useResponsePending);
}
@Override
public void setCaptionAsHtml(boolean captionAsHtml) {
component.setCaptionAsHtml(captionAsHtml);
}
@Override
public boolean isCaptionAsHtml() {
return component.isCaptionAsHtml();
}
}