PL-10534 Button.setAction doesn't refresh UI element

This commit is contained in:
Gleb Gorelov 2018-04-03 10:39:06 +04:00
parent 14d8497d16
commit 9e8e355c0e
2 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import javax.swing.*;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Objects;
public class DesktopButton extends DesktopAbstractComponent<JButton> implements Button {
@ -95,6 +96,15 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
if (this.action != null) {
this.action.removeOwner(this);
this.action.removePropertyChangeListener(actionPropertyChangeListener);
if (Objects.equals(this.action.getCaption(), getCaption())) {
setCaption(null);
}
if (Objects.equals(this.action.getDescription(), getDescription())) {
setDescription(null);
}
if (Objects.equals(this.action.getIcon(), getIcon())) {
setIcon(null);
}
}
this.action = action;

View File

@ -22,6 +22,7 @@ import com.haulmont.cuba.web.toolkit.ui.CubaButton;
import org.apache.commons.lang.StringUtils;
import java.beans.PropertyChangeListener;
import java.util.Objects;
public class WebButton extends WebAbstractComponent<CubaButton> implements Button {
@ -63,6 +64,15 @@ public class WebButton extends WebAbstractComponent<CubaButton> implements Butto
if (this.action != null) {
this.action.removeOwner(this);
this.action.removePropertyChangeListener(actionPropertyChangeListener);
if (Objects.equals(this.action.getCaption(), getCaption())) {
setCaption(null);
}
if (Objects.equals(this.action.getDescription(), getDescription())) {
setDescription(null);
}
if (Objects.equals(this.action.getIcon(), getIcon())) {
setIcon(null);
}
}
this.action = action;