Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.temp.client.foundation.util;

import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.HasCssName;
import com.google.gwt.dom.client.Style.Visibility;

/**
 * This Utility class provides low level support for GWT Elements.
 *
 * @author georgs
 */
public class CommonElementHelper {

    public static final String TABLE = "table";
    public static final String TD = "td";

    public static void hide(Element pElement) {
        setHidden(pElement, true);
    }

    public static void unhide(Element pElement) {
        setHidden(pElement, false);
    }

    public static void setHidden(Element pElement, boolean pHide) {
        pElement.getStyle().setVisibility(
                pHide ? Visibility.HIDDEN : Visibility.VISIBLE);
    }

    public static boolean isHidden(Element pElement) {
        return is(pElement.getStyle().getVisibility(), Visibility.HIDDEN);
    }

    public static boolean isVisible(Element pElement) {
        return !is(pElement.getStyle().getDisplay(), Display.NONE);
    }

    private static boolean is(String pPropertyValue, HasCssName pExpected) {
        return pExpected.getCssName().equals(pPropertyValue);
    }

    public static Element findElementWithTagNameUpDOM(Element pElement, String pTagName) {
        if (pTagName != null) {
            for (; pElement != null; pElement = pElement.getParentElement()) {
                if (pTagName.equalsIgnoreCase(pElement.getTagName())) {
                    return pElement;
                }
            }
        }
        return null;
    }
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/util/CommonElementHelper.java

Diff revisions: vs.
Revision Author Commited Message
626 GeorgeS picture GeorgeS Wed 11 Apr, 2012 19:39:41 +0000