List of usage examples for com.google.gwt.user.client Element getFirstChildElement
@Override
public Element getFirstChildElement()
From source file:com.eduworks.gwt.client.pagebuilder.screen.ScreenTemplate.java
License:Apache License
public static void setAlertBoxMessage(String message, AlertType type, final String containerName) { Element messageContainer = DOM.getElementById(containerName); if (messageContainer != null) { messageContainer.getFirstChildElement().setInnerText(message); clearAlertState();/*ww w. j a v a2 s .co m*/ if (type == AlertType.WARNING) { messageContainer.addClassName("warning"); messageContainer.getStyle().setColor("white"); } else if (type == AlertType.ERROR) { messageContainer.addClassName("alert"); messageContainer.getStyle().setColor("white"); } else if (type == AlertType.INFO) { messageContainer.addClassName("info"); messageContainer.getStyle().setColor("black"); } else if (type == AlertType.SUCCESS) { messageContainer.addClassName("success"); messageContainer.getStyle().setColor("white"); } else if (type == AlertType.SECONDARY) { messageContainer.addClassName("secondary"); messageContainer.getStyle().setColor("black"); } messageContainer.addClassName("active"); messageContainer.removeClassName("hidden"); Timer timeoutTimer = new Timer() { public void run() { hideAlertBox(containerName); } }; timeoutTimer.schedule(TIMER_STATUS_WINDOW_DELAY); } }
From source file:com.extjs.gxt.ui.client.core.MarkupBase.java
License:sencha.com license
public static Element createRootElement(String html) { Element rootElement = DOM.createDiv(); rootElement.setInnerHTML(html);//from w ww .j a v a 2 s . c o m if (rootElement.getFirstChild() != null) { rootElement = rootElement.getFirstChildElement().cast(); } return rootElement; }
From source file:com.extjs.gxt.ui.client.widget.DatePicker.java
License:sencha.com license
private void setCellStyle(Element cell, Date d, long sel, long min, long max) { long t = d.getTime(); DateWrapper w = new DateWrapper(d); int year = w.getFullYear(); int month = w.getMonth(); int day = w.getDate(); String dd = year + "," + month + "," + day; cell.getFirstChildElement().setPropertyString("dateValue", dd); if (t == today) { fly(cell).addStyleName("x-date-today"); if (GXT.isAriaEnabled()) { cell.setAttribute("title", "Today"); }//from w ww .jav a2 s .c o m } if (t == sel) { fly(cell).addStyleName("x-date-selected"); if (GXT.isAriaEnabled()) { cell.getFirstChildElement().setAttribute("aria-selected", "true"); if (isAttached()) { El.fly(cell.getFirstChildElement()).focus(); } } } else { fly(cell).removeStyleName("x-date-selected"); if (GXT.isAriaEnabled()) { cell.getFirstChildElement().setAttribute("aria-selected", "false"); } } if (t > max || t < min) { fly(cell).addStyleName("x-date-disabled"); if (t > max) cell.setTitle(messages.getMaxText()); else cell.setTitle(messages.getMinText()); } }
From source file:com.extjs.gxt.ui.client.widget.grid.ColumnHeader.java
License:sencha.com license
public void setEnableColumnReorder(boolean enable) { if (enable && reorderer == null) { reorderer = new Draggable(this); reorderer.setUseProxy(true);/*ww w . j a va 2 s .c o m*/ reorderer.setSizeProxyToSource(false); reorderer.setMoveAfterProxyDrag(false); reorderer.setProxy(StatusProxy.get().el()); reorderer.addDragListener(new DragListener() { private Head active; private int newIndex = -1; private Head start; private El statusIndicatorBottom; private El statusIndicatorTop; private StatusProxy statusProxy = StatusProxy.get(); public void dragCancel(DragEvent de) { afterDragEnd(); } public void dragEnd(DragEvent de) { if (statusProxy.getStatus()) { cm.moveColumn(start.column, newIndex); } afterDragEnd(); } public void dragMove(DragEvent de) { de.setX(de.getClientX() + 12 + XDOM.getBodyScrollLeft()); de.setY(de.getClientY() + 12 + XDOM.getBodyScrollTop()); Head h = ComponentManager.get().find(adjustTargetElement(de.getTarget()), Head.class); if (h != null && !h.equals(start)) { HeaderGroupConfig g = cm.getGroup(h.row - 1, h.column); HeaderGroupConfig s = cm.getGroup(start.row - 1, start.column); if ((g == null && s == null) || (g != null && g.equals(s))) { active = h; boolean before = de.getClientX() < active.getAbsoluteLeft() + active.getWidth() / 2; showStatusIndicator(true); if (before) { statusIndicatorTop.alignTo(active.el().dom, "b-tl", new int[] { -1, 0 }); statusIndicatorBottom.alignTo(active.el().dom, "t-bl", new int[] { -1, 0 }); } else { statusIndicatorTop.alignTo(active.el().dom, "b-tr", new int[] { 1, 0 }); statusIndicatorBottom.alignTo(active.el().dom, "t-br", new int[] { 1, 0 }); } int i = active.column; if (!before) { i++; } int aIndex = i; if (start.column < active.column) { aIndex--; } newIndex = i; if (aIndex != start.column) { statusProxy.setStatus(true); } else { showStatusIndicator(false); statusProxy.setStatus(false); } } else { active = null; showStatusIndicator(false); statusProxy.setStatus(false); } } else { active = null; showStatusIndicator(false); statusProxy.setStatus(false); } } public void dragStart(DragEvent de) { Head h = ComponentManager.get().find(de.getTarget(), Head.class); if (h != null && !h.config.isFixed()) { headerDisabled = true; quickTip.disable(); if (bar != null) { bar.hide(); } if (statusIndicatorBottom == null) { statusIndicatorBottom = new El(DOM.createDiv()); statusIndicatorBottom.addStyleName("col-move-bottom"); statusIndicatorTop = new El(DOM.createDiv()); statusIndicatorTop.addStyleName("col-move-top"); } XDOM.getBody().appendChild(statusIndicatorTop.dom); XDOM.getBody().appendChild(statusIndicatorBottom.dom); start = h; statusProxy.setStatus(false); statusProxy.update(start.config.getHeaderHtml()); } else { de.setCancelled(true); } } private Element adjustTargetElement(Element target) { return (Element) (target.getFirstChildElement() != null ? target.getFirstChildElement() : target); } private void afterDragEnd() { start = null; active = null; newIndex = -1; removeStatusIndicator(); headerDisabled = false; if (bar != null) { bar.show(); } quickTip.enable(); } private void removeStatusIndicator() { if (statusIndicatorBottom != null) { statusIndicatorBottom.remove(); statusIndicatorTop.remove(); } } private void showStatusIndicator(boolean show) { if (statusIndicatorBottom != null) { statusIndicatorBottom.setVisibility(show); statusIndicatorTop.setVisibility(show); } } }); } else if (reorderer != null && !enable) { reorderer.release(); reorderer = null; } }
From source file:com.extjs.gxt.ui.client.widget.grid.ColumnHeader.java
License:sencha.com license
protected void adjustCellWidth(Element cell, int width) { cell.getStyle().setPropertyPx("width", width); int adj = fly(cell).getFrameWidth("lr"); Element inner = cell.getFirstChildElement().cast(); fly(inner).setWidth(width - adj, true); if (isAttached()) { int before = cell.getOffsetHeight(); fly(inner).setHeight(before, true); int after = cell.getOffsetHeight(); // getting different values when some browsers are zoomed which is // causing the column heights to grow if (after != before) { fly(inner).setHeight(before + (before - after), true); }// w ww. jav a 2 s .c o m } }
From source file:com.extjs.gxt.ui.client.widget.grid.ColumnHeader.java
License:sencha.com license
private final void removeChildren(Element parent) { Element child = null;//from w w w .java2 s . co m while ((child = parent.getFirstChildElement().cast()) != null) { parent.removeChild(child); } String tag = parent.getTagName().toLowerCase(); if (!tag.equals("table") && !tag.equals("tbody") && !tag.equals("tr") && !tag.equals("td")) { parent.setInnerHTML(""); } }
From source file:com.extjs.gxt.ui.client.widget.tree.DefaultTreeItemUI.java
License:Open Source License
public void afterRender() { if (item.root) return;/* ww w .ja v a 2 s .c o m*/ itemEl = item.getElement().getFirstChild().cast(); fly(itemEl).addStyleName(styleTreeItem); El el = item.el(); Element td = el.selectNode("td:first-child").dom; indentEl = td.getFirstChildElement().cast(); jointEl = td.getNextSiblingElement().cast(); jointDivEl = jointEl.getFirstChild().cast(); checkEl = jointEl.getNextSiblingElement().getNextSiblingElement().cast(); checkDivEl = checkEl.getFirstChild().cast(); iconEl = checkEl.getNextSibling().cast(); iconDivEl = iconEl.getFirstChild().cast(); textEl = iconEl.getNextSiblingElement().cast(); textSpanEl = textEl.getFirstChildElement().cast(); containerEl = el.getChild(1); containerEl.setVisible(false); containerEl.makePositionable(); if (item.getItemStyleName() != null) { item.el().firstChild().addStyleName(item.getItemStyleName()); } if (checkEl != null) { fly(checkEl).setVisible(item.tree.getCheckable()); } item.updateIconStyle(); item.updateJointStyle(); if (item.getTextStyle() != null) { onTextStyleChange(item.getTextStyle()); } if (item.isChecked()) { onCheckChange(true); } fly(indentEl).setWidth(item.getIndent() - 18); item.disableTextSelection(true); }
From source file:com.vaadin.client.ComponentLocator.java
License:Apache License
/** * Locates an element based on a DOM path and a base element. * /*from ww w. j a va 2 s . c o m*/ * @param baseElement * The base element which the path is relative to * @param path * String locator (consisting of domChild[x] parts) that * identifies the element * @return The element identified by path, relative to baseElement or null * if the element could not be found. */ private Element getElementByDOMPath(Element baseElement, String path) { String parts[] = path.split(PARENTCHILD_SEPARATOR); Element element = baseElement; for (String part : parts) { if (part.startsWith("domChild[")) { String childIndexString = part.substring("domChild[".length(), part.length() - 1); if (Util.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) { if (element.hasChildNodes()) { Element e = element.getFirstChildElement().cast(); String cn = e.getClassName(); if (cn != null && (cn.equals("v-expand") || cn.contains("v-has-caption"))) { element = e; } } } try { int childIndex = Integer.parseInt(childIndexString); element = DOM.getChild(element, childIndex); } catch (Exception e) { return null; } if (element == null) { return null; } } } return element; }
From source file:org.ednovo.gooru.client.mvp.profilepage.data.item.PartnerLessonUc.java
License:Open Source License
public void setCollectionData(final ProfileLibraryDo profileLibraryDo, boolean isLessonHighlighted, Integer lessonNumber) {/* w w w. ja v a 2s. c o m*/ if (profileLibraryDo != null) { lessonTitle.setHTML(profileLibraryDo.getTitle()); lessonList.add(lessonTitle); lessonId = lessonNumber; conceptId = profileLibraryDo.getGooruOid(); if (AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.PROFILE_PAGE)) { lessonTitle.addStyleName(style.lessonTitle()); lessonTitle.addStyleName(style.collection()); } else { //lessonTitle.addStyleName(style.libraryTitle()); lessonTitle.addStyleName(style.libraryConceptTitle()); } } if (lessonNumber == 1 && isLessonHighlighted) { if (AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.PROFILE_PAGE)) { lessonTitle.addStyleName(style.conceptActive()); } else { lessonTitle.addStyleName(style.libraryConceptActive()); lessonTitle.addStyleName(style.marginTop5()); } openCollection(); isLessonHighlighted = false; } lessonTitle.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { openCollection(); NodeList links = lessonList.getElement().getParentElement().getChildNodes(); for (int i = 0; i < links.getLength(); i++) { com.google.gwt.user.client.Element link = (com.google.gwt.user.client.Element) links.getItem(i); link.getFirstChildElement().removeClassName(style.conceptActive()); link.getFirstChildElement().removeClassName(style.libraryConceptActive()); } lessonTitle.addStyleName(style.conceptActive()); } }); }
From source file:org.geomajas.gwt.client.gfx.context.DomHelper.java
License:Open Source License
/** * Within a certain group, move an element to the back. All siblings will be rendered after this one. * /*w w w . ja v a 2s .co m*/ * @param object * The group wherein to search for the element. * @param name * The name of the element to move to the back. * @since 1.10.0 */ public void moveToBack(Object parent, String name) { Element parentElement = getGroup(parent); if (parentElement == null) { throw new IllegalArgumentException("moveToBack failed: could not find parent group."); } Element element = getElement(parent, name); if (element == null) { throw new IllegalArgumentException("moveToBack failed: could not find element within group."); } if (parentElement.getFirstChildElement() != element) { parentElement.insertFirst(element); } }