List of usage examples for com.google.gwt.dom.client Element getAttribute
@Override
public String getAttribute(String name)
From source file:cc.alcina.framework.gwt.client.util.ClientUtils.java
License:Apache License
public static String getHashIfSelfrefUrl(Element anchor) { String href = anchor.getAttribute("href"); String selfHref = Window.Location.getHref(); int idx = selfHref.indexOf("#"); selfHref = idx == -1 ? selfHref : selfHref.substring(0, idx); if (href.startsWith(selfHref)) { href = href.substring(selfHref.length()); }/*from www .j ava 2 s . c om*/ return href.startsWith("#") && href.length() > 1 ? href.substring(1) : null; }
From source file:cc.alcina.framework.gwt.client.widget.DivStackPanel.java
License:Apache License
@Override public void onBrowserEvent(Event event) { if (DOM.eventGetType(event) == Event.ONCLICK) { Element target = DOM.eventGetTarget(event); int index = findDividerIndex(target); if (index != -1) { showStack(index);//from ww w . j a va2 s . c om } if (target.getTagName().equalsIgnoreCase("A") && target.getAttribute("href").matches("#?")) { event.preventDefault(); } } }
From source file:com.alkacon.acacia.client.EditorBase.java
License:Open Source License
/** * Checks whether the given element is marked to receive focus once the inline editing is initialized.<p> * /*from w ww .j a v a 2 s. co m*/ * @param element the element to check * * @return <code>true</code> if the given element is marked to receive focus once the inline editing is initialized */ public static boolean shouldFocusOnInlineEdit(Element element) { return INLINE_EDIT_FOCUS_MARKER.equals(element.getAttribute("rel")); }
From source file:com.arcbees.gquery.elastic.client.ElasticImpl.java
License:Apache License
private StyleInfo initItem(Element e) { int span = getSpan(e); Integer floatColumn = null;/*www.j a v a 2 s . co m*/ String floatValue = e.getAttribute(Elastic.COLUMN_ATTRIBUTE); if (FIRST.equalsIgnoreCase(floatValue)) { floatColumn = 0; } else if (LAST.equalsIgnoreCase(floatValue)) { floatColumn = -span; } else { try { floatColumn = Integer.parseInt(floatValue) - 1; } catch (NumberFormatException ignored) { } } GQuery $e = $(e); StyleInfo styleInfo = new StyleInfo(); styleInfo.span = getSpan(e); styleInfo.rowSpanAll = "all".equals(e.getAttribute(Elastic.ROW_SPAN_ATTRIBUTE)); styleInfo.floatColumn = floatColumn; styleInfo.marginRight = $e.cur("marginRight", true); styleInfo.marginLeft = $e.cur("marginLeft", true); styleInfo.borderTopWidth = $e.cur("borderTopWidth", true); styleInfo.borderBottomWidth = $e.cur("borderBottomWidth", true); styleInfo.marginTop = $e.cur("marginTop", true); styleInfo.marginBottom = $e.cur("marginBottom", true); $e.data(STYLE_INFO_KEY, styleInfo); $e.css("position", "absolute"); // TODO Ease next width computation but check the impact of this in the content of the item if (GQuery.browser.mozilla) { $e.css("moz-box-sizing", "border-box"); } else { $e.css("box-sizing", "border-box"); } return styleInfo; }
From source file:com.arcbees.gquery.elastic.client.ElasticImpl.java
License:Apache License
private int getSpan(Element element) { String attributeValue = element.getAttribute(Elastic.SPAN_ATTRIBUTE); if (attributeValue != null && !attributeValue.isEmpty()) { if ("all".equals(attributeValue)) { return Integer.MAX_VALUE; }// w ww. j av a 2 s. c o m try { return max(1, Integer.parseInt(attributeValue)); } catch (NumberFormatException ignored) { } } return 1; }
From source file:com.arcbees.gquery.tooltip.client.TooltipDocumentation.java
License:Apache License
private void setupCellListTooltip() { final ContactDatabase contactDatabase = ContactDatabase.get(); //CellList with pager ContactCellList ccl = new ContactCellList(contactDatabase); RootPanel.get("contactCellList").add(ccl); TooltipOptions options = new TooltipOptions(); //provide dynamic content options.withContent(new TooltipContentProvider() { @Override//from w w w. j a v a 2 s.com public String getContent(Element element) { Integer id = Integer.parseInt(element.getAttribute("data-contact-id")); ContactInfo contact = contactDatabase.queryContactById(id); return ContactTemplates.INSTANCE .contactCellTooltip(contactImage, contact.getFullName(), contact.getAddress()).asString(); } }); options.withResources(ContactTooltipResources.INSTANCE); options.withPlacement(TooltipPlacement.RIGHT); // event delegation : the plugin will run on all elements inside the CellList having 'tooltipable' as css // class, present in the dom or added in the future. options.withSelector(".tooltipable"); options.withHtml(true); //apply plugin to the cell list $(ccl).as(Tooltip).tooltip(options); }
From source file:com.calclab.emite.browser.client.DomAssist.java
License:Open Source License
/** * Given an DOM element and a list of parameters, returns a HashMap with the * paramName associated to the value of this parameter defined in the * element./*from ww w .ja v a 2 s . c o m*/ * * The optional prefix is added to the paramName before extracting the * value. * * @param element * the element to be inspected * @param paramNames * the desired paramNames * @param prefix * The string added as prefix to the paramName before get the * value. It can be null * @return a HashMap that associates each paramName with the value in the * element (or null if nothing found) */ public HashMap<String, String> getProperties(final Element element, final String[] paramNames, final String prefix) { final String before = (prefix == null ? "" : prefix); final HashMap<String, String> properties = new HashMap<String, String>(); if (paramNames != null) { for (final String name : paramNames) { Log.debug("Param name of widget: " + name); final String value = element.getAttribute(before + name); Log.debug("Value: " + value); properties.put(name, value); } } return properties; }
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: * /*from w w w .ja va 2 s . c o m*/ * <code><meta name="name" value="userName" /></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 w w w .ja v a 2 s . co m * <code><meta name="name" value="userName" /></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.calclab.emite.widgets.client.AutoDeploy.java
License:Open Source License
private void setParams(final Element element, final EmiteWidget widget) { final String[] paramNames = widget.getParamNames(); if (paramNames != null) { for (final String name : paramNames) { Log.debug("Param name of widget: " + name); final String value = element.getAttribute("data-" + name); Log.debug("Value: " + value); widget.setParam(name, value); }//w ww.ja va 2 s . c o m } }