public static File create(Element element, int i) throws IllegalArgumentException { if (!(element.getNodeName().toLowerCase().equals("input") && element.getAttribute("type").equals("file"))) { throw new IllegalArgumentException("Input element is not form file object."); } return _create(element, i); }
@Test public void checkGetDocumentElement() { // Test Element e = d.getDocumentElement(); // Assert Assert.assertEquals("HTML", e.getTagName()); Assert.assertEquals("HTML", e.getNodeName()); Assert.assertEquals(Node.ELEMENT_NODE, e.getNodeType()); Assert.assertEquals(d.getChild(0), e); }
/** * Called when an event occurs in a rendered instance of this Cell. The parent element refers to * the element that contains the rendered cell, NOT to the outermost element that the Cell * rendered. */ @Override public void onBrowserEvent( com.google.gwt.cell.client.Cell.Context context, Element parent, String value, NativeEvent event, com.google.gwt.cell.client.ValueUpdater<String> valueUpdater) { // Let AbstractCell handle the keydown event. super.onBrowserEvent(context, parent, value, event, valueUpdater); // Handle the click event. if ("click".equals(event.getType())) { // Ignore clicks that occur outside of the outermost element. EventTarget eventTarget = event.getEventTarget(); if (parent.isOrHasChild(Element.as(eventTarget))) { // if (parent.getFirstChildElement().isOrHasChild( // Element.as(eventTarget))) { // use this to get the selected element!! Element el = Element.as(eventTarget); // check if we really click on the image if (callback != null && el.getNodeName().equalsIgnoreCase("IMG")) { final String s = el.getParentElement().getAttribute("name"); final KieContainer container = containersProvider.getContainer(value); final boolean isUp = SharedUtils.getContainerStatus(container); final boolean isKieApp = container.getType() != null && KieImageCategory.KIEAPP.equals(container.getType().getCategory()); if (ContainerActionsCell.PLAY.equals(s) && !isUp) { callback.onStart(container); } else if (ContainerActionsCell.STOP.equals(s) && isUp) { callback.onStop(container); } else if (ContainerActionsCell.RELOAD.equals(s) && isUp) { callback.onRestart(container); } else if (ContainerActionsCell.REMOVE.equals(s)) { callback.onRemove(container); } else if (ContainerActionsCell.VIEW_LOGS.equals(s)) { callback.onViewLogs(container); } else if (ContainerActionsCell.VIEW_DETAILS.equals(s) && isUp && isKieApp) { callback.onViewDetails(container); } else if (ContainerActionsCell.NAVIGATE.equals(s) && isUp && isKieApp) { callback.onNavigate(container); } } } } };
private JsNodeArray getNotPseudo( JsNodeArray previousMatch, String pseudoValue, JsNodeArray matchingElms) { if (new JsRegexp("(:\\w+[\\w\\-]*)$").test(pseudoValue)) { matchingElms = subtractArray( previousMatch, getElementsByPseudo(previousMatch, pseudoValue.substring(1), "")); } else { pseudoValue = pseudoValue.replace("^\\[#([\\w\\u00C0-\\uFFFF\\-\\_]+)\\]$", "[id=$1]"); JsObjectArray<String> notTag = new JsRegexp("^(\\w+)").exec(pseudoValue); JsObjectArray<String> notClass = new JsRegexp("^\\.([\\w\u00C0-\uFFFF\\-_]+)").exec(pseudoValue); JsObjectArray<String> notAttr = new JsRegexp("\\[(\\w+)(\\^|\\$|\\*|\\||~)?=?([\\w\\u00C0-\\uFFFF\\s\\-_\\.]+)?\\]") .exec(pseudoValue); JsRegexp notRegExp = new JsRegexp( "(^|\\s)" + (JsUtils.truth(notTag) ? notTag.get(1) : JsUtils.truth(notClass) ? notClass.get(1) : "") + "(\\s|$)", "i"); if (JsUtils.truth(notAttr)) { String notAttribute = JsUtils.truth(notAttr.get(3)) ? notAttr.get(3).replace("\\.", "\\.") : null; String notMatchingAttrVal = attrToRegExp(notAttribute, notAttr.get(2)); notRegExp = new JsRegexp(notMatchingAttrVal, "i"); } for (int v = 0, vlen = previousMatch.size(); v < vlen; v++) { Element notElm = previousMatch.getElement(v); Element addElm = null; if (JsUtils.truth(notTag) && !notRegExp.test(notElm.getNodeName())) { addElm = notElm; } else if (JsUtils.truth(notClass) && !notRegExp.test(notElm.getClassName())) { addElm = notElm; } else if (JsUtils.truth(notAttr)) { String att = getAttr(notElm, notAttr.get(1)); if (!JsUtils.truth(att) || !notRegExp.test(att)) { addElm = notElm; } } if (JsUtils.truth(addElm) && !isAdded(addElm)) { setAdded(addElm, true); matchingElms.addNode(addElm); } } } return matchingElms; }