List of usage examples for com.google.gwt.dom.client Element getNextSiblingElement
@Override
public Element getNextSiblingElement()
From source file:com.alkacon.geranium.client.util.DomUtil.java
License:Open Source License
/** * Determines the position of the list collector editable content.<p> * //from ww w . ja va 2s . c o m * @param editable the editable marker tag * * @return the position */ public static PositionBean getEditablePosition(Element editable) { PositionBean result = new PositionBean(); int dummy = -999; // setting minimum height result.setHeight(20); result.setWidth(60); result.setLeft(dummy); result.setTop(dummy); Element sibling = editable.getNextSiblingElement(); while ((sibling != null) && !DomUtil.hasClass("cms-editable", sibling) && !DomUtil.hasClass("cms-editable-end", sibling)) { // only consider element nodes if ((sibling.getNodeType() == Node.ELEMENT_NODE) && !sibling.getTagName().equalsIgnoreCase(Tag.script.name())) { PositionBean siblingPos = PositionBean.generatePositionInfo(sibling); result.setLeft(((result.getLeft() == dummy) || (siblingPos.getLeft() < result.getLeft())) ? siblingPos.getLeft() : result.getLeft()); result.setTop(((result.getTop() == dummy) || (siblingPos.getTop() < result.getTop())) ? siblingPos.getTop() : result.getTop()); result.setHeight( ((result.getTop() + result.getHeight()) > (siblingPos.getTop() + siblingPos.getHeight())) ? result.getHeight() : (siblingPos.getTop() + siblingPos.getHeight()) - result.getTop()); result.setWidth( ((result.getLeft() + result.getWidth()) > (siblingPos.getLeft() + siblingPos.getWidth())) ? result.getWidth() : (siblingPos.getLeft() + siblingPos.getWidth()) - result.getLeft()); } sibling = sibling.getNextSiblingElement(); } if ((result.getTop() == dummy) && (result.getLeft() == dummy)) { result = PositionBean.generatePositionInfo(editable); } if (result.getHeight() == -1) { // in case no height was set result = PositionBean.generatePositionInfo(editable); result.setHeight(20); result.setWidth((result.getWidth() < 60) ? 60 : result.getWidth()); } return result; }
From source file:com.alkacon.geranium.client.util.PositionBean.java
License:Open Source License
/** * Returns a position info representing the dimensions of all visible child elements of the given panel (excluding elements with position:absolute). * If the panel has no visible child elements, it's outer dimensions are returned.<p> * /*from ww w .j a v a 2s .c o m*/ * @param panel the panel * @param levels the levels to traverse down the DOM tree * @param includeSelf <code>true</code> to include the outer dimensions of the given panel * * @return the position info */ public static PositionBean getInnerDimensions(Element panel, int levels, boolean includeSelf) { boolean first = true; int top = 0; int left = 0; int bottom = 0; int right = 0; // if overflow is set to hidden, use the outer dimensions if (!Overflow.HIDDEN.getCssName().equals(DomUtil.getCurrentStyle(panel, Style.overflow))) { if (!includeSelf) { // check for any text content NodeList<Node> children = panel.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { if ((children.getItem(i).getNodeType() == Node.TEXT_NODE) && (children.getItem(i).getNodeValue().trim().length() > 0)) { includeSelf = true; break; } } } if (includeSelf) { top = panel.getAbsoluteTop(); left = panel.getAbsoluteLeft(); bottom = top + panel.getOffsetHeight(); right = left + panel.getOffsetWidth(); first = false; } Element child = panel.getFirstChildElement(); while (child != null) { String tagName = child.getTagName(); if (tagName.equalsIgnoreCase("br") || tagName.equalsIgnoreCase("tr") || tagName.equalsIgnoreCase("thead") || tagName.equalsIgnoreCase("tfoot") || tagName.equalsIgnoreCase("script") || tagName.equalsIgnoreCase("style")) { // ignore tags with no relevant position info child = child.getNextSiblingElement(); continue; } String positioning = DomUtil.getCurrentStyle(child, Style.position); if (!Display.NONE.getCssName().equals(DomUtil.getCurrentStyle(child, Style.display)) && !(positioning.equalsIgnoreCase(Position.ABSOLUTE.getCssName()) || positioning.equalsIgnoreCase(Position.FIXED.getCssName()))) { PositionBean childDimensions = levels > 0 ? getInnerDimensions(child, levels - 1, true) : generatePositionInfo(panel); if (first) { first = false; top = childDimensions.getTop(); left = childDimensions.getLeft(); bottom = top + childDimensions.getHeight(); right = left + childDimensions.getWidth(); } else { int wTop = childDimensions.getTop(); top = top < wTop ? top : wTop; int wLeft = childDimensions.getLeft(); left = left < wLeft ? left : wLeft; int wBottom = wTop + childDimensions.getHeight(); bottom = bottom > wBottom ? bottom : wBottom; int wRight = wLeft + childDimensions.getWidth(); right = right > wRight ? right : wRight; } } child = child.getNextSiblingElement(); } } if (!first) { PositionBean result = new PositionBean(); result.setHeight(bottom - top); result.setWidth(right - left); result.setTop(top); result.setLeft(left); return result; } else { return generatePositionInfo(panel); } }
From source file:com.arcbees.gquery.elastic.client.ElasticImpl.java
License:Apache License
private void bind() { resizeHandlerRegistration = Window.addResizeHandler(new ResizeHandler() { @Override//from w ww .j av a 2 s . c o m public void onResize(ResizeEvent event) { if (options.isAutoResize()) { layout(); } } }); if (MutationObserver.isSupported()) { mutationObserver = new MutationObserver(new DomMutationCallback() { @Override public void onNodesRemoved(JsArray<Node> removedNodes) { onItemsRemoved(); } @Override public void onNodesInserted(JsArray<Node> addedNodes, Node nextSibling) { onItemsInserted(toElementList(addedNodes)); } @Override public void onNodesAppended(JsArray<Node> addedNodes) { onItemsAppended(toElementList(addedNodes)); } }); mutationObserver.observe(container); } else { // try old api with DomMutationEvent $(container).on("DOMNodeInserted", new Function() { @Override public boolean f(Event event) { Node node = event.getEventTarget().cast(); if (node.getNodeType() != Node.ELEMENT_NODE || node.getParentElement() != container) { return false; } final Element element = node.cast(); Element prevSibling = element.getPreviousSiblingElement(); Element nextSibling = element.getNextSiblingElement(); if (prevSibling != null && getStyleInfo(prevSibling) != null && (nextSibling == null || getStyleInfo(nextSibling) == null)) { onItemsAppended(new ArrayList<Element>() { { this.add(element); } }); } else { onItemsInserted(new ArrayList<Element>() { { this.add(element); } }); } return false; } }).on("DOMNodeRemoved", new Function() { @Override public boolean f(Event event) { Node node = event.getEventTarget().cast(); if (node.getNodeType() != Node.ELEMENT_NODE || node.getParentElement() != container) { return false; } onItemsRemoved(); return false; } }); } }
From source file:com.google.speedtracer.client.visualizations.view.RequestDetails.java
License:Apache License
private void maybeShowServerEvents(final Element parent, final Element insertAfter, final Css css, final Document document) { if (!info.hasServerTraceUrl()) { return;//from www. jav a 2 s .com } final String traceUrl = info.getServerTraceUrl(); // TODO(knorton): When playing back from a dump, we do not want to try to // fetch the server-side trace. serverEventController.requestTraceFor(info, new ServerEventController.RequestTraceCallback() { public void onFailure() { if (ClientConfig.isDebugMode()) { Logging.getLogger().logText("Failed to fetch server trace: " + traceUrl); } } public void onSuccess(ServerEvent event) { // insertBefore may be null, in which case Element.insertBefore will // append. final Element insertBefore = insertAfter.getNextSiblingElement(); parent.insertBefore(createSectionHeader(css, document, "Server Trace"), insertBefore); final DivElement container = document.createDivElement(); container.setClassName(css.serverTraceTree()); parent.insertBefore(container, insertBefore); // TODO(knorton): Spring Insight specific functionality that needs // to be better generalized. maybeAddSpringInsightLinks(event, css, container); final LazyEventTree.Resources treeResources = GWT.create(LazyEventTree.Resources.class); final ServerEventTreeController controller = new ServerEventTreeController(); final LazyEventTree tree = new LazyEventTree(new DefaultContainerImpl(container), controller, event, new EventTraceBreakdown(event, controller, treeResources), treeResources); tree.addSelectionChangeListener(controller); tree.addExpansionChangeListener(controller); fixHeightOfParentRow(); } }); }
From source file:com.vaadin.client.ui.table.TableConnector.java
License:Apache License
private int getElementIndex(Element e, com.google.gwt.user.client.Element element) { int i = 0;//from w w w . jav a2s. c o m Element current = element.getFirstChildElement(); while (!current.isOrHasChild(e)) { current = current.getNextSiblingElement(); ++i; } return i; }
From source file:com.vaadin.client.ui.VMenuBar.java
License:Apache License
private Element getLastChildElement(CustomMenuItem item) { Element lastChildElement = item.getElement().getFirstChildElement(); while (lastChildElement.getNextSiblingElement() != null) { lastChildElement = lastChildElement.getNextSiblingElement(); }/*w w w . j a v a2 s. c o m*/ return lastChildElement; }
From source file:com.vaadin.client.widget.grid.selection.MultiSelectionRenderer.java
License:Apache License
private int getLogicalRowIndex(final Element target) { if (target == null) { return -1; }// w w w .j a v a2 s. c om /* * We can't simply go backwards until we find a <tr> first element, * because of the table-in-table scenario. We need to, unfortunately, go * up from our known root. */ final Element tbody = getTbodyElement(); Element tr = tbody.getFirstChildElement(); while (tr != null) { if (tr.isOrHasChild(target)) { final Element td = tr.getFirstChildElement(); assert td != null : "Cell has disappeared"; final Element checkbox = td.getFirstChildElement(); assert checkbox != null : "Checkbox has disappeared"; return checkbox.getPropertyInt(LOGICAL_ROW_PROPERTY_INT); } tr = tr.getNextSiblingElement(); } return -1; }
From source file:com.vaadin.v7.client.widget.grid.selection.MultiSelectionRenderer.java
License:Apache License
private int getLogicalRowIndex(Grid<T> grid, final Element target) { if (target == null) { return -1; }/*w w w . j ava2s . com*/ /* * We can't simply go backwards until we find a <tr> first element, * because of the table-in-table scenario. We need to, unfortunately, go * up from our known root. */ final Element tbody = getTbodyElement(); Element tr = tbody.getFirstChildElement(); while (tr != null) { if (tr.isOrHasChild(target)) { final Element td = tr.getFirstChildElement(); assert td != null : "Cell has disappeared"; final Element checkbox = td.getFirstChildElement(); assert checkbox != null : "Checkbox has disappeared"; return ((AbstractRowContainer) grid.getEscalator().getBody()) .getLogicalRowIndex((TableRowElement) tr); } tr = tr.getNextSiblingElement(); } return -1; }
From source file:de.catma.ui.client.ui.tagger.editor.TaggerEditor.java
License:Open Source License
private Element findClosestSibling(Element start) { Element curSibling = start; while ((curSibling != null) && !((lastClientX > curSibling.getAbsoluteLeft()) && (lastClientX < curSibling.getAbsoluteRight()) && (lastClientY > curSibling.getAbsoluteTop()) && (lastClientY < curSibling.getAbsoluteBottom()))) { curSibling = curSibling.getNextSiblingElement(); }/*ww w . j a va2 s . com*/ return curSibling; }
From source file:fr.fg.client.core.Client.java
License:Open Source License
public void setFullScreenMode(boolean fullScreen) { this.fullScreen = fullScreen; if (toolBar != null) { toolBar.setVisible(!fullScreen); miniMap.setVisible(!fullScreen); namePanel.setVisible(!fullScreen); empireControlPanel.setVisible(!fullScreen); empireView.setVisible(!fullScreen); progressBar.setVisible(!fullScreen); chat.setVisible(!fullScreen);/*w w w . ja va 2s . c o m*/ chat.scrollDown(); missionPanel.setVisible(!fullScreen); if (!fullScreen) chat.scrollDown(); } areaContainer.setVisible(!fullScreen); fullScreenPanel.clear(); fullScreenPanel.setVisible(fullScreen); if (fullScreen) { // Sauvegarde l'tat et masque les dialogues Element element = RootPanel.getBodyElement().getFirstChildElement(); while (element != null) { if (element.getClassName() .contains(JSComponent.getUIProperty(JSDialog.UI_CLASS_ID, OpenJWT.CSS_CLASS))) { dialogStates.add(new DialogState(element, element.getStyle().getProperty("display"))); element.getStyle().setProperty("display", "none"); } element = element.getNextSiblingElement(); } if (getSelectionInfo() != null) { systemInfoVisible = getSelectionInfo().isVisible(); getSelectionInfo().setVisible(false); } } else { // Restaure l'tat des dialogues for (DialogState dialogState : dialogStates) dialogState.getDialog().getStyle().setProperty("display", dialogState.getDisplay()); dialogStates.clear(); if (getSelectionInfo() != null) getSelectionInfo().setVisible(systemInfoVisible); } }