
org.ioc.commons.impl.gwt.client.ui.HasEnabledWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ioc-commons-gwt-impl Show documentation
Show all versions of ioc-commons-gwt-impl Show documentation
GWT implementation for ioc-commons artifacts.
package org.ioc.commons.impl.gwt.client.ui;
import org.ioc.commons.ui.HasEnabled;
import org.ioc.commons.ui.HasStorage;
public class HasEnabledWrapper implements HasEnabled {
private com.google.gwt.user.client.ui.HasEnabled wrapped;
private HasEnabledWrapper(com.google.gwt.user.client.ui.HasEnabled wrapped) {
this.wrapped = wrapped;
}
@Override
public void setEnabled(boolean enabled) {
this.wrapped.setEnabled(enabled);
}
@Override
public boolean isEnabled() {
return this.wrapped.isEnabled();
}
/**
* Gets a wrapper for a GWT HasEnabled implementation
*
* @param gwtHasEnabled
*
* @return HasEnabled wrapper
*/
public static HasEnabled from(com.google.gwt.user.client.ui.HasEnabled gwtHasEnabled) {
return new HasEnabledWrapper(gwtHasEnabled);
}
public static HasEnabled from(com.google.gwt.user.client.ui.HasEnabled gwtHasEnabled, HasStorage cache) {
Object cached = cache.retrieve(gwtHasEnabled);
HasEnabled hasEnabled = (cached instanceof HasEnabled) ? (HasEnabled) cached : null;
if (hasEnabled == null) {
hasEnabled = new HasEnabledWrapper(gwtHasEnabled);
cache.store(gwtHasEnabled, hasEnabled);
}
return hasEnabled;
}
/**
* Helpful method for setting an enabled property on several components at
* the same time.
*
* @param enabled
* @param gwtHasEnabledArray
*/
public static void setEnabled(boolean enabled, com.google.gwt.user.client.ui.HasEnabled... gwtHasEnabledArray) {
if (gwtHasEnabledArray != null) {
for (com.google.gwt.user.client.ui.HasEnabled gwtHasEnabled : gwtHasEnabledArray) {
gwtHasEnabled.setEnabled(enabled);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy