Empty caption of actions and buttons is being ignored #PL-5694

This commit is contained in:
Yuriy Artamonov 2015-07-20 14:33:56 +00:00
parent f2df0501f7
commit 5b3574aa91
4 changed files with 28 additions and 19 deletions

View File

@ -24,6 +24,7 @@ import java.beans.PropertyChangeListener;
public class DesktopButton extends DesktopAbstractComponent<JButton> implements Button {
protected Action action;
protected String caption;
protected String icon;
protected long responseEndTs = 0;
@ -77,22 +78,22 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
if (action != null) {
String caption = action.getCaption();
if (!StringUtils.isEmpty(caption) && StringUtils.isEmpty(impl.getText())) {
impl.setText(caption);
if (caption != null && getCaption() == null) {
setCaption(caption);
}
String description = action.getDescription();
if (StringUtils.isEmpty(description) && action.getShortcut() != null) {
if (description == null && action.getShortcut() != null) {
description = action.getShortcut().format();
}
if (!StringUtils.isEmpty(description) && StringUtils.isEmpty(getDescription())) {
if (description != null && getDescription() == null) {
setDescription(description);
}
setEnabled(action.isEnabled());
setVisible(action.isVisible());
if (action.getIcon() != null) {
if (action.getIcon() != null && getIcon() == null) {
setIcon(action.getIcon());
}
@ -123,12 +124,13 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
@Override
public String getCaption() {
return impl.getText();
return caption;
}
@Override
public void setCaption(String caption) {
impl.setText(caption);
this.caption = caption;
impl.setText(caption == null ? "" : caption);
}
@Override

View File

@ -48,7 +48,7 @@
<action id="excel"/>
</actions>
<buttonsPanel>
<button id="userTableCreateBtn" action="usersTable.create"/>
<button id="userTableCreateBtn" action="usersTable.create" caption=""/>
<button id="userTableEditBtn" action="usersTable.edit"/>
<button id="userTableCopyButton" action="usersTable.copy"/>
<button id="userTableRemoveBtn" action="usersTable.remove"/>

View File

@ -126,18 +126,18 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
}
protected void loadCaption(Component.HasCaption component, Element element) {
String caption = element.attributeValue("caption");
if (element.attribute("caption") != null) {
String caption = element.attributeValue("caption");
if (!StringUtils.isEmpty(caption)) {
caption = loadResourceString(caption);
component.setCaption(caption);
}
}
protected void loadDescription(Component.HasCaption component, Element element) {
String description = element.attributeValue("description");
if (element.attribute("description") != null) {
String description = element.attributeValue("description");
if (!StringUtils.isEmpty(description)) {
description = loadResourceString(description);
component.setDescription(description);
}
@ -179,6 +179,7 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
protected boolean loadEnable(Component component, Element element) {
String enable = element.attributeValue("enable");
if (enable == null) {
// todo artamonov remove in 6.0
final Element e = element.element("enable");
if (e != null) {
enable = e.getText();
@ -196,6 +197,10 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
}
protected String loadResourceString(String caption) {
if (StringUtils.isEmpty(caption)) {
return caption;
}
return messageTools.loadString(messagesPack, caption);
}
@ -316,9 +321,11 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
}
protected void loadIcon(Component.HasIcon component, Element element) {
final String icon = element.attributeValue("icon");
if (!StringUtils.isEmpty(icon)) {
component.setIcon(loadResourceString(icon));
if (element.attribute("icon") != null) {
String icon = element.attributeValue("icon");
icon = loadResourceString(icon);
component.setIcon(icon);
}
}

View File

@ -87,22 +87,22 @@ public class WebButton extends WebAbstractComponent<CubaButton> implements Butto
if (action != null) {
String caption = action.getCaption();
if (!StringUtils.isEmpty(caption) && StringUtils.isEmpty(component.getCaption())) {
if (caption != null && component.getCaption() == null) {
component.setCaption(caption);
}
String description = action.getDescription();
if (StringUtils.isEmpty(description) && action.getShortcut() != null) {
if (description == null && action.getShortcut() != null) {
description = action.getShortcut().format();
}
if (!StringUtils.isEmpty(description) && StringUtils.isEmpty(component.getDescription())) {
if (description != null && component.getDescription() == null) {
component.setDescription(description);
}
component.setEnabled(action.isEnabled());
component.setVisible(action.isVisible());
if (action.getIcon() != null) {
if (action.getIcon() != null && getIcon() == null) {
setIcon(action.getIcon());
}