Java Code Examples for com.google.gwt.dom.client.Element#hasAttribute()
The following examples show how to use
com.google.gwt.dom.client.Element#hasAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlipMetaDomImpl.java From swellrt with Apache License 2.0 | 6 votes |
/** * Scrapes the menu state from the DOM. The menu state describes what options * exist, and which, if any, are currently selected. * * @return a mapping from available options to their UI objects, and the * subset of those options that are currently selected. */ private Pair<EnumMap<MenuOption, BlipMenuItemDomImpl>, EnumSet<MenuOption>> getMenuState() { EnumMap<MenuOption, BlipMenuItemDomImpl> options = new EnumMap<MenuOption, BlipMenuItemDomImpl>(MenuOption.class); EnumSet<MenuOption> selected = EnumSet.noneOf(MenuOption.class); Element e = getMenu().getFirstChildElement(); while (e != null) { if (e.hasAttribute(KIND_ATTRIBUTE) && e.getAttribute(KIND_ATTRIBUTE).equals(TypeCodes.kind(Type.MENU_ITEM))) { BlipMenuItemDomImpl item = BlipMenuItemDomImpl.of(e, css); MenuOption option = item.getOption(); options.put(option, item); if (item.isSelected()) { selected.add(option); } } e = e.getNextSiblingElement(); } return Pair.of(options, selected); }
Example 2
Source File: BlipMetaDomImpl.java From swellrt with Apache License 2.0 | 6 votes |
public StringSequence getInlineLocators() { if (inlineLocators == null) { Element content = getContentContainer().getFirstChildElement(); if (content != null) { inlineLocators = (StringSequence) content.getPropertyObject(INLINE_LOCATOR_PROPERTY); if (inlineLocators == null) { // Note: getAttribute() of a missing attribute does not return null on // all browsers. if (content.hasAttribute(INLINE_LOCATOR_ATTRIBUTE)) { String serial = content.getAttribute(INLINE_LOCATOR_ATTRIBUTE); inlineLocators = StringSequence.create(serial); } else { inlineLocators = StringSequence.create(); } content.setPropertyObject(INLINE_LOCATOR_PROPERTY, inlineLocators); } } else { // Leave inlineLocators as null, since the document is not here yet. } } return inlineLocators; }
Example 3
Source File: BlipMetaDomImpl.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
/** * Scrapes the menu state from the DOM. The menu state describes what options * exist, and which, if any, are currently selected. * * @return a mapping from available options to their UI objects, and the * subset of those options that are currently selected. */ private Pair<EnumMap<MenuOption, BlipMenuItemDomImpl>, EnumSet<MenuOption>> getMenuState() { EnumMap<MenuOption, BlipMenuItemDomImpl> options = new EnumMap<MenuOption, BlipMenuItemDomImpl>(MenuOption.class); EnumSet<MenuOption> selected = EnumSet.noneOf(MenuOption.class); Element e = getMenu().getFirstChildElement(); while (e != null) { if (e.hasAttribute(KIND_ATTRIBUTE) && e.getAttribute(KIND_ATTRIBUTE).equals(TypeCodes.kind(Type.MENU_ITEM))) { BlipMenuItemDomImpl item = BlipMenuItemDomImpl.of(e, css); MenuOption option = item.getOption(); options.put(option, item); if (item.isSelected()) { selected.add(option); } } e = e.getNextSiblingElement(); } return Pair.of(options, selected); }
Example 4
Source File: BlipMetaDomImpl.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
public StringSequence getInlineLocators() { if (inlineLocators == null) { Element content = getContentContainer().getFirstChildElement(); if (content != null) { inlineLocators = (StringSequence) content.getPropertyObject(INLINE_LOCATOR_PROPERTY); if (inlineLocators == null) { // Note: getAttribute() of a missing attribute does not return null on // all browsers. if (content.hasAttribute(INLINE_LOCATOR_ATTRIBUTE)) { String serial = content.getAttribute(INLINE_LOCATOR_ATTRIBUTE); inlineLocators = StringSequence.create(serial); } else { inlineLocators = StringSequence.create(); } content.setPropertyObject(INLINE_LOCATOR_PROPERTY, inlineLocators); } } else { // Leave inlineLocators as null, since the document is not here yet. } } return inlineLocators; }
Example 5
Source File: JQueryFileUploadOverlay.java From cuba with Apache License 2.0 | 5 votes |
protected void addPendingUpload(JavaScriptObject jqXHR) { Element fileInput = fileUploadWidget.getFileInputElement(); if (!fileUploadWidget.isEnabled()) { for (JavaScriptObject currentXHR : currentXHRs) { cancelXHR(currentXHR); } return; } boolean multiple = fileInput.hasAttribute("multiple"); if (!multiple) { if (!currentXHRs.isEmpty()) return; currentXHRs.add(jqXHR); skipLastFiles(jqXHR); } else { currentXHRs.add(jqXHR); } if (currentXHRs.size() == getOriginalFilesCount(jqXHR)) { for (JavaScriptObject xhr : currentXHRs) { if (!isValidFile(getFileName(xhr), getFileSize(xhr))) { currentXHRs.clear(); return; } } queueUploadStart(); // all files added to pending queue, start uploading submitXHR(currentXHRs.get(0)); } }
Example 6
Source File: HtmlSelectionHelperImpl.java From swellrt with Apache License 2.0 | 5 votes |
private boolean isInChildEditor(Point<Node> point) { // The editable doc is marked by an attribute EDITABLE_DOC_MARKER, if // an element is found with that attribute, and is not the element of this // editor's doc element, then it must be a child's doc element. Node n = point.getContainer(); Element e = DomHelper.isTextNode(n) ? n.getParentElement() : (Element) n; while (e != null && e != doc) { if (e.hasAttribute(EditorImpl.EDITABLE_DOC_MARKER)) { return true; } e = e.getParentElement(); } return false; }
Example 7
Source File: DOMMutationExtractor.java From swellrt with Apache License 2.0 | 5 votes |
private boolean handleDOMNodeInserted(final Element e) { if (e.getTagName().equals("SPAN") && e.hasAttribute("class") && e.getAttribute("class").equals("Apple-style-span")) { scheduleElementForRevert(e.getParentElement()); } return true; }
Example 8
Source File: FullStructure.java From swellrt with Apache License 2.0 | 5 votes |
/** @return the view type of an element. */ private Type typeOf(Element e) { Type type = e.hasAttribute(KIND_ATTRIBUTE) ? type(e.getAttribute(KIND_ATTRIBUTE)) : null; if (type == null) { throw new RuntimeException("element has no known kind: " + e.getAttribute(KIND_ATTRIBUTE)); } else { return type; } }
Example 9
Source File: EventDispatcherPanel.java From swellrt with Apache License 2.0 | 5 votes |
/** * Dispatches an event through this handler collection. * * @param event event to dispatch * @param target target element of the event * @return true if a handled, false otherwise. */ boolean dispatch(E event, Element target) { while (target != null) { if (target.hasAttribute(KIND_ATTRIBUTE)) { W handler = waveHandlers.get(target.getAttribute(KIND_ATTRIBUTE)); if (handler != null) { if (dispatch(event, target, handler)) { return true; } } } target = !target.equals(top) ? target.getParentElement() : null; } return dispatchGlobal(event); }
Example 10
Source File: HtmlSelectionHelperImpl.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
private boolean isInChildEditor(Point<Node> point) { // The editable doc is marked by an attribute EDITABLE_DOC_MARKER, if // an element is found with that attribute, and is not the element of this // editor's doc element, then it must be a child's doc element. Node n = point.getContainer(); Element e = DomHelper.isTextNode(n) ? n.getParentElement() : (Element) n; while (e != null && e != doc) { if (e.hasAttribute(EditorImpl.EDITABLE_DOC_MARKER)) { return true; } e = e.getParentElement(); } return false; }
Example 11
Source File: DOMMutationExtractor.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
private boolean handleDOMNodeInserted(final Element e) { if (e.getTagName().equals("SPAN") && e.hasAttribute("class") && e.getAttribute("class").equals("Apple-style-span")) { scheduleElementForRevert(e.getParentElement()); } return true; }
Example 12
Source File: FullStructure.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** @return the view type of an element. */ private Type typeOf(Element e) { Type type = e.hasAttribute(KIND_ATTRIBUTE) ? type(e.getAttribute(KIND_ATTRIBUTE)) : null; if (type == null) { throw new RuntimeException("element has no known kind: " + e.getAttribute(KIND_ATTRIBUTE)); } else { return type; } }
Example 13
Source File: EventDispatcherPanel.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Dispatches an event through this handler collection. * * @param event event to dispatch * @param target target element of the event * @return true if a handled, false otherwise. */ boolean dispatch(E event, Element target) { while (target != null) { if (target.hasAttribute(KIND_ATTRIBUTE)) { W handler = waveHandlers.get(target.getAttribute(KIND_ATTRIBUTE)); if (handler != null) { if (dispatch(event, target, handler)) { return true; } } } target = !target.equals(top) ? target.getParentElement() : null; } return dispatchGlobal(event); }
Example 14
Source File: FinderColumn.java From core with GNU Lesser General Public License v2.1 | 5 votes |
private ButtonRef resolveActionAttribute(Element element) { if(!element.hasAttribute("action")) { if(element.hasParentElement()) return resolveActionAttribute(element.getParentElement()); else new ButtonRef("unresolved", element); } return new ButtonRef(element.getAttribute("action"), element); }
Example 15
Source File: FullStructure.java From swellrt with Apache License 2.0 | 2 votes |
/** * @return true if {@code e} has a kind supported by a view implementation * from this package. */ private boolean hasKnownType(Element e) { return e.hasAttribute(KIND_ATTRIBUTE) && KNOWN_KINDS.contains(e.getAttribute(KIND_ATTRIBUTE)); }
Example 16
Source File: FullStructure.java From incubator-retired-wave with Apache License 2.0 | 2 votes |
/** * @return true if {@code e} has a kind supported by a view implementation * from this package. */ private boolean hasKnownType(Element e) { return e.hasAttribute(KIND_ATTRIBUTE) && KNOWN_KINDS.contains(e.getAttribute(KIND_ATTRIBUTE)); }