public <T extends Component & Container & VariableOwner> void setViewer(
T viewer) {
- if (viewer == this.viewer) {
+ // This somewhat complicated check exists to make sure that proxies are
+ // handled correctly
+ if (this.viewer == viewer
+ || (this.viewer != null && this.viewer.equals(viewer))) {
return;
}
if (this.viewer != null) {
@Override
public void addActionHandler(Handler actionHandler) {
- if (actionHandler == this) {
+ if (equals(actionHandler)) {
// don't add the actionHandler to itself
return;
}
import com.vaadin.ui.HasComponents;
import com.vaadin.ui.LegacyComponent;
import com.vaadin.ui.UI;
+
import elemental.json.JsonObject;
/**
*/
protected void addExtension(Extension extension) {
ClientConnector previousParent = extension.getParent();
- if (previousParent == this) {
+ if (equals(previousParent)) {
// Nothing to do, already attached
return;
} else if (previousParent != null) {
public void setErrorHandler(ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
}
+
+ private AbstractClientConnector getInstance() {
+ // returns the underlying instance regardless of proxies
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof AbstractClientConnector) {
+ return super.equals(((AbstractClientConnector) obj).getInstance());
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
}
@Override
public void setParent(HasComponents parent) {
// If the parent is not changed, don't do anything
- if (parent == this.parent) {
+ if (parent == null ? this.parent == null : parent.equals(this.parent)) {
return;
}
if (content instanceof HasComponents) {
for (Component parent = this; parent != null; parent = parent
.getParent()) {
- if (parent == content) {
+ if (parent.equals(content)) {
return true;
}
}
*/
@Override
public void removeComponent(Component c) {
- if (c.getParent() == this) {
+ if (equals(c.getParent())) {
c.setParent(null);
fireComponentDetachEvent(c);
}
public void addComponentAsFirst(Component c) {
// If c is already in this, we must remove it before proceeding
// see ticket #7668
- if (c.getParent() == this) {
+ if (equals(c.getParent())) {
removeComponent(c);
}
components.addFirst(c);
public void addComponent(Component c, int index) {
// If c is already in this, we must remove it before proceeding
// see ticket #7668
- if (c.getParent() == this) {
+ if (equals(c.getParent())) {
// When c is removed, all components after it are shifted down
if (index > getComponentIndex(c)) {
index--;
// do not set the same content twice
return;
}
- if (oldContent != null && oldContent.getParent() == this) {
+ if (oldContent != null && equals(oldContent.getParent())) {
oldContent.setParent(null);
fireComponentDetachEvent(oldContent);
}
for (ClientConnector child : children) {
stack.add(child);
- if (child.getParent() != connector) {
+ if (!connector.equals(child.getParent())) {
noErrors = false;
getLogger()
.log(Level.WARNING,
public void addComponentAsFirst(Component c) {
// If c is already in this, we must remove it before proceeding
// see ticket #7668
- if (c.getParent() == this) {
+ if (equals(c.getParent())) {
removeComponent(c);
}
components.addFirst(c);
public void addComponent(Component c, int index) {
// If c is already in this, we must remove it before proceeding
// see ticket #7668
- if (c.getParent() == this) {
+ if (equals(c.getParent())) {
// When c is removed, all components after it are shifted down
if (index > getComponentIndex(c)) {
index--;
*/
protected void setCompositionRoot(Component compositionRoot) {
if (compositionRoot != root) {
- if (root != null && root.getParent() == this) {
+ if (root != null && equals(root.getParent())) {
// remove old component
root.setParent(null);
}
Collection<?> visibleItemProperties = f.getItemPropertyIds();
for (Object fieldId : visibleItemProperties) {
Field<?> field = f.getField(fieldId);
- if (field == this) {
+ if (equals(field)) {
/*
* this datefield is logically in a form. Do the same
* thing as form does in its value change listener that
}
visibleComponent.setParent(this);
} else {
- if (visibleComponent.getParent() == this) {
+ if (equals(visibleComponent.getParent())) {
visibleComponent.setParent(null);
}
visibleComponent = null;
@Override
public Component getComponent() {
for (Map.Entry<Component, Tab> entry : tabs.entrySet()) {
- if (entry.getValue() == this) {
+ if (equals(entry.getValue())) {
return entry.getKey();
}
}
"Registered {0}: {1}",
new Object[] { component.getClass().getSimpleName(),
component.getCaption() });
- if (component.getParent() != this) {
+ if (!equals(component.getParent())) {
component.setParent(this);
}
visibleComponents.add(component);
@Override
public void valueChange(Property.ValueChangeEvent event) {
- if (event.getProperty() == this
+ if (equals(event.getProperty())
|| event.getProperty() == getPropertyDataSource()) {
super.valueChange(event);
} else {
if (pendingFocus != null) {
// ensure focused component is still attached to this main window
- if (pendingFocus.getUI() == this
- || (pendingFocus.getUI() != null && pendingFocus.getUI()
- .getParent() == this)) {
+ if (equals(pendingFocus.getUI())
+ || (pendingFocus.getUI() != null && equals(pendingFocus
+ .getUI().getParent()))) {
target.addAttribute("focused", pendingFocus);
}
pendingFocus = null;