Example usage for com.google.gwt.dom.client Element getPropertyString

List of usage examples for com.google.gwt.dom.client Element getPropertyString

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Element getPropertyString.

Prototype

@Override
    public String getPropertyString(String name) 

Source Link

Usage

From source file:com.ait.ext4j.client.core.DomUtil.java

License:Apache License

public static String getID(Element element) {
    String id = element.getPropertyString("id");
    return id == null || id.equals("") ? null : id;

}

From source file:com.calclab.emite.browser.client.DomAssist.java

License:Open Source License

/**
 * Get the value of meta information writen in the html page. The meta
 * information is a html tag with name of meta usually placed inside the the
 * head section with two attributes: id and content. For example:
 * //  www. j  a  v a 2  s  . co  m
 * <code>&lt;meta id="name" value="userName" /&gt;</code>
 * 
 * 
 * 
 * @param id
 *            the 'id' value of the desired meta tag
 * @param isRequired
 *            if isRequired is true, this method throws a RuntimeException
 *            if the meta tag is not found
 * @return the value of the attribute 'value'
 */
public String getMeta(final String id, final boolean isRequired) {
    String value = null;
    final Element element = DOM.getElementById(id);
    if (element != null) {
        value = element.getPropertyString("content");
        Log.debug("Meta: " + id + ": " + value);
    }
    if (isRequired && value == null) {
        throw new RuntimeException("Required meta-attribute " + id + " not found.");
    }

    return value;
}

From source file:com.calclab.emite.browser.client.PageAssist.java

License:Open Source License

/**
 * Get the value of meta information writen in the html page. The meta
 * information is a html tag with name of meta usually placed inside the the
 * head section with two attributes: id and content. For example:
 * //w  w  w  .j a va 2  s. co m
 * <code>&lt;meta name="name" value="userName" /&gt;</code>
 * 
 * @param id
 *            the 'id' value of the desired meta tag
 * @return the value of the attribute 'value' or null if not found
 */
public static final String getMeta(final String id) {
    String value = null;
    Element element = null;
    final NodeList<Element> elements = Document.get().getElementsByTagName("meta");
    if (elements != null) {
        for (int i = 0; i < elements.getLength() && element == null; i++) {
            final Element candidate = elements.getItem(i);
            if (id.equals(candidate.getAttribute("name"))) {
                element = candidate;
            }
        }
    }
    if (element == null) {
        element = DOM.getElementById(id);
    }
    if (element != null) {
        value = element.getPropertyString("content");
    }
    return value;
}

From source file:com.calclab.emite.browser.PageAssist.java

License:Open Source License

/**
 * Get the value of meta information written in the html page. The meta
 * information is a html tag with name of meta usually placed inside the the
 * head section with two attributes: id and content. For example:
 * //from   www  .  ja  v a 2 s. c om
 * <code>&lt;meta name="name" value="userName" /&gt;</code>
 * 
 * @param id
 *            the 'id' value of the desired meta tag
 * @param defaultValue
 *            the default value to return if the meta is not found
 * @return the value of the attribute 'value' or null if not found
 */
@Nullable
public static final String getMeta(final String id, @Nullable final String defaultValue) {
    checkNotNull(id);
    final NodeList<Element> elements = Document.get().getElementsByTagName("meta");
    for (int i = 0; i < elements.getLength(); i++) {
        final Element candidate = elements.getItem(i);
        if (id.equals(candidate.getAttribute("name")))
            return candidate.getPropertyString("content");
    }

    final Element domElement = DOM.getElementById(id);
    if (domElement != null)
        return domElement.getPropertyString("content");

    return defaultValue;
}

From source file:com.centimia.gxt.sample.widgetdashboard.client.WidgetDashboard.java

License:Open Source License

public void onModuleLoad() {
    String styleSheetName = "resources/css/gxt-all.css";
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        styleSheetName = "resources/css/gxt-all-rtl.css";
    }/*  www  . j a va 2  s . c  om*/

    // Find existing style sheets that need to be removed
    boolean styleSheetsFound = false;
    final HeadElement headElem = StyleSheetLoader.getHeadElement();
    final List<Element> toRemove = new ArrayList<Element>();
    NodeList<Node> children = headElem.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node node = children.getItem(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element elem = Element.as(node);
            if (elem.getTagName().equalsIgnoreCase("link")
                    && elem.getPropertyString("rel").equalsIgnoreCase("stylesheet")) {
                styleSheetsFound = true;
                String href = elem.getPropertyString("href");
                // If the correct style sheets are already loaded, then we should have
                // nothing to remove.
                if (!href.equals(styleSheetName) && href.indexOf("gxt") != -1) {
                    toRemove.add(elem);
                }
            }
        }
    }

    // Return if we already have the correct style sheets
    if (styleSheetsFound && toRemove.size() != 0) {
        // Remove the old style sheets
        for (Element elem : toRemove) {
            headElem.removeChild(elem);
        }
    }

    ExampleServiceAsync service = (ExampleServiceAsync) GWT.create(ExampleService.class);
    ServiceDefTarget endpoint = (ServiceDefTarget) service;
    String moduleRelativeURL = SERVICE;
    endpoint.setServiceEntryPoint(moduleRelativeURL);
    Registry.register(SERVICE, service);

    FileServiceAsync fileservice = (FileServiceAsync) GWT.create(FileService.class);
    endpoint = (ServiceDefTarget) fileservice;
    moduleRelativeURL = FILE_SERVICE;
    endpoint.setServiceEntryPoint(moduleRelativeURL);
    Registry.register(FILE_SERVICE, fileservice);

    ExamplesModel model = new ExamplesModel();
    for (int i = 0; i < model.getChildren().size(); i++) {
        Category cat = (Category) model.getChildren().get(i);
        for (int j = 0; j < cat.getChildren().size(); j++) {
            Entry entry = (Entry) cat.getChildren().get(j);
            examples.put(entry.getId(), entry);
        }
    }

    Registry.register(MODEL, model);
    viewport = new Viewport();

    BorderLayout layout = new BorderLayout();

    demoPanel = new ContentPanel();
    demoPanel.setLayout(new BorderLayout());

    viewport.setLayout(layout);

    createNorth();

    createTree();
    panel.setResizeTabs(true);
    panel.setMinTabWidth(115);
    panel.setAnimScroll(true);
    panel.setTabScroll(true);
    panel.setCloseContextMenu(true);

    replaceView("basicgrid");
    demoPanel.add(panel, new BorderLayoutData(LayoutRegion.CENTER));

    viewport.add(tree, new BorderLayoutData(LayoutRegion.WEST));
    viewport.add(demoPanel, new BorderLayoutData(LayoutRegion.CENTER));

    StyleSheetLoader.loadStyleSheet(styleSheetName, "ext-el-mask", this);
}

From source file:com.cgxlib.xq.client.impl.DocumentStyleImpl.java

License:Apache License

/**
 * Returns the numeric value of a css property.
 * <p/>/*from   ww  w.  java2s.co  m*/
 * The parameter force has a special meaning:
 * - When force is false, returns the value of the css property defined
 * in the set of style attributes.
 * - Otherwise it returns the real computed value.
 */
public double cur(Element elem, String prop, boolean force) {
    if (JsUtils.isWindow(elem)) {
        if ("width".equals(prop)) {
            return getContentDocument(elem).getClientWidth();
        }
        if ("height".equals(prop)) {
            return getContentDocument(elem).getClientHeight();
        }
        elem = XQ.body;
    }

    if (force && sizeRegex.test(prop)) {
        // make curCSS below resolve width and height (issue #145) when force is true
    } else if (elem.getPropertyString(prop) != null
            && (elem.getStyle() == null || elem.getStyle().getProperty(prop) == null)) {
        // cases where elem.prop exists instead of elem.style.prop
        return elem.getPropertyDouble(prop);
    }
    String val = curCSS(elem, prop, force);
    if ("thick".equalsIgnoreCase(val)) {
        return (5);
    } else if ("medium".equalsIgnoreCase(val)) {
        return (3);
    } else if ("thin".equalsIgnoreCase(val)) {
        return (1);
    }
    if (!val.matches("^[\\d\\.]+.*$")) {
        val = curCSS(elem, prop, false);
    }
    val = val.trim().replaceAll("[^\\d\\.\\-]+.*$", "");
    return val.isEmpty() ? 0 : Double.parseDouble(val);
}

From source file:com.google.gwt.modernizr.client.tests.InlineSvg.java

License:MIT License

@Override
protected boolean runTest() {
    DivElement div = Document.get().createDivElement();
    div.setInnerHTML("<svg/>");
    Element firstChild = (Element) div.getFirstChild();
    return firstChild != null && SVG_NAMESPACE.equals(firstChild.getPropertyString("namespaceURI"));
}

From source file:com.sencha.gxt.widget.core.client.ListView.java

License:sencha.com license

/**
 * Returns the index of the element.//from w  ww.  j  av  a2  s  .  co m
 *
 * @param element the element
 * @return the index
 */
public int indexOf(Element element) {
    if (element == null) {
        return -1;
    }
    if (element.getPropertyString("viewIndex") != null) {
        return Util.parseInt(element.getPropertyString("viewIndex"), -1);
    }
    return all.indexOf(element);
}

From source file:com.vaadin.client.widgets.Grid.java

License:Apache License

private static void setCustomStyleName(Element element, String styleName) {
    assert element != null;

    String oldStyleName = element.getPropertyString(CUSTOM_STYLE_PROPERTY_NAME);

    if (!SharedUtil.equals(oldStyleName, styleName)) {
        if (oldStyleName != null && !oldStyleName.isEmpty()) {
            element.removeClassName(oldStyleName);
        }//from  w ww  . ja v a 2s .  c o  m
        if (styleName != null && !styleName.isEmpty()) {
            element.addClassName(styleName);
        }
        element.setPropertyString(CUSTOM_STYLE_PROPERTY_NAME, styleName);
    }

}

From source file:eu.riscoss.client.entities.RDCConfigurationPage.java

License:Apache License

public JSONObject getJson() {
    for (String key : RDCConfigurationPage.this.rdcMap.keySet()) {
        boolean enabled = enabledMap.isEnabled(key);
        enabledMap.enableRDC(key, enabled);
        if (enabled) {
            JSONArray parameters = RDCConfigurationPage.this.rdcMap.parameters(key);
            for (int i = 0; i < parameters.size(); i++) {
                String parName = RDCConfigurationPage.this.rdcMap.getParamterName(key, i);
                Element e = Document.get().getElementById("txt:" + key + ":" + parName);
                if (e == null)
                    continue;
                String value = e.getPropertyString("value");
                enabledMap.set(key, parName, value);
            }/*from  w ww  .  jav  a2  s.  c o m*/
        }
    }
    return enabledMap.getJson();
}