com.tractionsoftware.gwt.user.client.util.DomUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cedar-common-gwt Show documentation
Show all versions of cedar-common-gwt Show documentation
Utility code for use with GWT and Mvp4g.
/*
* Copyright 2010 Traction Software, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.tractionsoftware.gwt.user.client.util;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.UIObject;
/**
* DOM utilities.
*
*
* Created for a uniform implementation of HasEnabled, but will be
* useful in the future for other DOM related things.
*
*
*
* This is a subclass of UIObject to gain access to the useful
* setStyleName method of UIObject which is implemented as protected.
*
*
* Code Source
*
*
* This is external code that was copied into the CedarCommon codebase under
* the terms of its license.
*
*
*
*
*
*
* Source:
* Traction Software
*
*
* Date:
* July, 2014
*
*
* Reason:
* The official Traction-supplied jar in Maven only supports Java 1.7+, but CedarCommon supports Java 1.6+.
*
*
*
*
*
* @author Andy @ Traction Software
*/
public class DomUtils extends UIObject {
/**
* This object is never created.
*/
private DomUtils() {}
/**
* It's enough to just set the disabled attribute on the
* element, but we want to also add a "disabled" class so that we can
* style it.
*
* At some point we'll just be able to use .button:disabled,
* but that doesn't work in IE8-
*/
public static void setEnabled(Element element, boolean enabled) {
element.setPropertyBoolean("disabled", !enabled);
setStyleName(element, "disabled", !enabled);
}
/**
* Returns true if the element has the disabled attribute.
*/
public static boolean isEnabled(Element element) {
return element.getPropertyBoolean("disabled");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy