List of usage examples for com.google.gwt.dom.client Element hasClassName
@Override
public boolean hasClassName(String className)
From source file:client.ui.views.series.SeriesView.java
License:Open Source License
/** * Set whether scrollbars are enabled.// w w w. ja v a2 s . c om * * @param enabled Whether scrollbars are enabled. */ public void setScrollEnabled(final boolean enabled) { final Element element = (Element) getElement().getFirstChild(); boolean scrollEnabled = element.hasClassName(CLASS_NAME_SCROLL); if ((scrollEnabled && !enabled) || (!scrollEnabled && enabled)) { if (enabled) { (new Timer() { @Override public void run() { element.addClassName(CLASS_NAME_SCROLL); } }).schedule(SCROLL_DELAY); } else { element.removeClassName(CLASS_NAME_SCROLL); } } }
From source file:com.arcbees.beestore.client.application.widget.PriceView.java
License:Apache License
private boolean isPricePanel(Element element) { return !element.hasClassName(res.style().productSection()); }
From source file:com.bearsoft.gwt.ui.XElement.java
/** * Selects child nodes based on the passed CSS selector (the selector should * not contain an id)./*from w ww . j a v a 2s. com*/ * * @param aClassName * the selector/xpath query * @return the matching elements */ public final List<Element> select(final String aClassName) { final List<Element> result = new ArrayList<>(); iterate(this, new Observer() { @Override public void observe(Element anElement) { if ("*".equals(aClassName)) { result.add(anElement); } else { if (anElement.getClassName() != null && anElement.hasClassName(aClassName)) result.add(anElement); } } }); return result; }
From source file:com.googlesource.gerrit.plugins.labelui.client.LabelUIPlugin.java
License:Apache License
private static void hideDefaultLabelUi() { Element body = RootPanel.getBodyElement(); if (!body.hasClassName(HIDE_DEFAULT_LABELS_CLASS)) { body.addClassName(HIDE_DEFAULT_LABELS_CLASS); }/*from www. j ava2 s .c o m*/ }
From source file:com.googlesource.gerrit.plugins.reviewstrategy.client.ReviewStrategyPlugin.java
License:Apache License
private static void hideDefaultReviewStrategy() { Element body = RootPanel.getBodyElement(); for (Map.Entry<String, String> entry : classes.entrySet()) { if (!body.hasClassName(entry.getValue())) { body.addClassName(entry.getValue()); }/*from w w w . ja v a2 s . c o m*/ } }
From source file:com.haulmont.cuba.web.toolkit.ui.client.table.CubaScrollTableConnector.java
License:Apache License
@Override public TooltipInfo getTooltipInfo(Element element) { if (getState().columnDescriptions != null) { Element targetHeaderElement = findCurrentOrParentTd(element); if (targetHeaderElement != null && targetHeaderElement.hasClassName("v-table-header-cell")) { // if column has description int childIndex = DOM.getChildIndex(targetHeaderElement.getParentElement(), targetHeaderElement); String columnKey = getWidget().tHead.getHeaderCell(childIndex).getColKey(); if (columnKey != null) { String columnDescription = getState().columnDescriptions.get(columnKey); if (columnDescription != null && !columnDescription.isEmpty()) { return new TooltipInfo(columnDescription); }/*from www . j av a2 s. c om*/ } } } if (getState().aggregationDescriptions != null) { Element targetAggregatedElement = findCurrentOrParentTd(element); if (targetAggregatedElement != null && (targetAggregatedElement.hasClassName("v-table-aggregation-cell") || targetAggregatedElement.getFirstChildElement().hasClassName("v-table-footer-container"))) { int childIndex = DOM.getChildIndex(targetAggregatedElement.getParentElement(), targetAggregatedElement); String columnKey = getWidget().tHead.getHeaderCell(childIndex).getColKey(); if (columnKey != null) { String columnTooltip = getState().aggregationDescriptions.get(columnKey); if (columnTooltip != null && !columnTooltip.isEmpty()) { return new TooltipInfo(columnTooltip); } } } } if (element != getWidget().getElement()) { Object node = WidgetUtil.findWidget(element, CubaScrollTableWidget.CubaScrollTableBody.CubaScrollTableRow.class); if (node != null) { CubaScrollTableWidget.CubaScrollTableBody.CubaScrollTableRow row = (CubaScrollTableWidget.CubaScrollTableBody.CubaScrollTableRow) node; return row.getTooltip(element); } } return super.getTooltipInfo(element); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.treetable.CubaTreeTableConnector.java
License:Apache License
@Override public TooltipInfo getTooltipInfo(Element element) { if (getState().columnDescriptions != null) { Element targetHeaderElement = findCurrentOrParentTd(element); if (targetHeaderElement != null) { // if column has description int childIndex = DOM.getChildIndex(targetHeaderElement.getParentElement(), targetHeaderElement); String columnKey = getWidget().tHead.getHeaderCell(childIndex).getColKey(); if (columnKey != null) { String columnDescription = getState().columnDescriptions.get(columnKey); if (columnDescription != null && !columnDescription.isEmpty()) { return new TooltipInfo(columnDescription); }/*ww w. j a v a 2 s . c o m*/ } } } if (getState().aggregationDescriptions != null) { Element targetAggregatedElement = findCurrentOrParentTd(element); if (targetAggregatedElement != null && (targetAggregatedElement.hasClassName("v-table-aggregation-cell") || targetAggregatedElement.hasClassName("v-table-footer-container"))) { int childIndex = DOM.getChildIndex(targetAggregatedElement.getParentElement(), targetAggregatedElement); String columnKey = getWidget().tHead.getHeaderCell(childIndex).getColKey(); if (columnKey != null) { String columnTooltip = getState().aggregationDescriptions.get(columnKey); if (columnTooltip != null && !columnTooltip.isEmpty()) { return new TooltipInfo(columnTooltip); } } } } if (element != getWidget().getElement()) { Object node = WidgetUtil.findWidget(element, CubaTreeTableWidget.CubaTreeTableBody.CubaTreeTableRow.class); if (node != null) { CubaTreeTableWidget.CubaTreeTableBody.CubaTreeTableRow row = (CubaTreeTableWidget.CubaTreeTableBody.CubaTreeTableRow) node; return row.getTooltip(element); } } return super.getTooltipInfo(element); }
From source file:com.sencha.gxt.widget.core.client.grid.GridView.java
License:sencha.com license
/** * Returns the cell index./*from ww w .ja va 2s .co m*/ * * @param elem the cell or child element * @param requiredStyle an optional required style name * @return the cell index or -1 if not found */ public int findCellIndex(Element elem, String requiredStyle) { Element cell = findCell(elem); if (cell != null && (requiredStyle == null || elem.hasClassName(requiredStyle))) { String index = cell.getAttribute("cellindex"); return index.equals("") ? -1 : Integer.parseInt(index); } return -1; }
From source file:com.vaadin.addon.spreadsheet.client.SheetTabSheet.java
private void initListeners() { Event.sinkEvents(root, Event.ONCLICK | Event.ONDBLCLICK); Event.setEventListener(root, new EventListener() { @Override/* w w w. jav a 2 s . c o m*/ public void onBrowserEvent(Event event) { final Element target = event.getEventTarget().cast(); final int type = event.getTypeInt(); if (target.equals(input)) { return; } event.stopPropagation(); if (type == Event.ONCLICK) { if (editing && !readOnly) { commitSheetName(); } handler.onSheetTabSheetFocus(); if (options.isOrHasChild(target) && !target.hasClassName(HIDDEN)) { if (target.equals(scrollBeginning)) { tabScrollMargin = 0; tabScrollIndex = 0; container.getStyle().setMarginLeft(tabScrollMargin, Unit.PX); showHideScrollIcons(); handler.onFirstTabIndexChange(tabScrollIndex); } else if (target.equals(scrollLeft)) { if (tabScrollIndex > 0) { tabScrollIndex--; if (tabScrollIndex == 0) { tabScrollMargin = 0; } else { tabScrollMargin += getTabWidth(tabScrollIndex); } container.getStyle().setMarginLeft(tabScrollMargin, Unit.PX); } showHideScrollIcons(); handler.onFirstTabIndexChange(tabScrollIndex); } else if (target.equals(scrollRight)) { if (tabScrollIndex < (tabs.length() - 1)) { tabScrollMargin -= getTabWidth(tabScrollIndex); container.getStyle().setMarginLeft(tabScrollMargin, Unit.PX); tabScrollIndex++; showHideScrollIcons(); handler.onFirstTabIndexChange(tabScrollIndex); } } else if (target.equals(scrollEnd)) { int tempIndex = getLastTabVisibleWithScrollIndex(); setFirstVisibleTab(tempIndex); handler.onFirstTabIndexChange(tabScrollIndex); } else if (target.equals(addNewSheet)) { if (!readOnly) { handler.onNewSheetCreated(); } } } else if (container.isOrHasChild(target)) { for (int i = 0; i < tabs.length(); i++) { if (tabs.get(i).equals(target)) { if (i != selectedTabIndex) { handler.onSheetTabSelected(i); } } } } } else if (type == Event.ONDBLCLICK) { if (!readOnly) { for (int i = 0; i < tabs.length(); i++) { if (tabs.get(i).equals(target)) { if (i != selectedTabIndex) { handler.onSheetTabSelected(i); } else { editing = true; Element e = tabs.get(i).cast(); cachedSheetName = e.getInnerText(); input.setValue(cachedSheetName); e.setInnerText(""); e.appendChild(input); input.focus(); updateInputSize(); } } } } } } }); Event.sinkEvents(input, Event.ONKEYDOWN | Event.ONKEYUP | Event.ONBLUR); Event.setEventListener(input, new EventListener() { @Override public void onBrowserEvent(Event event) { final int type = event.getTypeInt(); if (editing) { if (type == Event.ONBLUR) { commitSheetName(); } else { switch (event.getKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_TAB: commitSheetName(); break; case KeyCodes.KEY_ESCAPE: editing = false; input.removeFromParent(); Element element = (Element) tabs.get(selectedTabIndex).cast(); element.getStyle().clearWidth(); element.setInnerText(cachedSheetName); handler.onSheetRenameCancel(); break; default: doDeferredInputSizeUpdate(); break; } } } event.stopPropagation(); } }); }
From source file:fr.putnami.pwt.core.widget.client.util.StyleUtils.java
License:Open Source License
public static <S extends CssStyle> void removeStyle(Element e, S style) { if (e == null) { return;/* ww w . j a v a 2 s . c o m*/ } if (style instanceof Enum) { StyleUtils.cleanEnumStyle(e, style.getClass()); } String styleName = StyleUtils.getStyle(style); String currentClassName = e.getClassName(); if (styleName != null && currentClassName != null && e.hasClassName(styleName)) { e.removeClassName(styleName); } }