Java Code Examples for com.google.gwt.dom.client.Element#removeClassName()

The following examples show how to use com.google.gwt.dom.client.Element#removeClassName() . 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: DateCell.java    From calendar-component with Apache License 2.0 6 votes vote down vote up
private void clearSelectionRange() {
    if (eventRangeStart > -1) {
        // clear all "selected" class names
        Element main = getElement();
        NodeList<Node> nodes = main.getChildNodes();

        for (int i = 0; i <= 47; i++) {
            Element c = (Element) nodes.getItem(i);
            if (c == null) {
                continue;
            }
            c.removeClassName("v-daterange");
        }

        eventRangeStart = -1;
    }
}
 
Example 2
Source File: DomUtil.java    From mapper with Apache License 2.0 6 votes vote down vote up
public static WritableProperty<Boolean> hasClass(final Element el, final String cls) {
  return new WritableProperty<Boolean>() {
    private boolean myValue;

    @Override
    public void set(Boolean value) {
      if (myValue == value) return;
      if (value) {
        el.addClassName(cls);
      } else {
        el.removeClassName(cls);
      }
      myValue = value;
    }
  };
}
 
Example 3
Source File: CubaTableDragSourceExtensionConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected void removeDraggable(Element element) {
    if (getDragSourceWidget() instanceof TableWidget) {
        TableWidget widget = (TableWidget) getDragSourceWidget();
        List<Widget> list = widget.getRenderedRows();

        for (Widget row : list) {
            Element rowElement = row.getElement();
            rowElement.setDraggable(Element.DRAGGABLE_FALSE);

            String primaryDragSourceStyle = getStylePrimaryName(getDraggableElement()) + STYLE_SUFFIX_DRAGSOURCE;
            rowElement.removeClassName(primaryDragSourceStyle);
            rowElement.removeClassName(getStyleNameDraggable());
        }
    }
}
 
Example 4
Source File: ViewClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Hides the highlighted drop target hints.
 *
 * @param configuration
 *            for the accept criterion to retrieve the drop target hints.
 */
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
void hideDropTargetHints(final UIDL configuration) {
    final int totalDropTargetHintsCount = configuration.getIntAttribute(DROP_AREA_CONFIG_COUNT);
    for (int dropAreaIndex = 0; dropAreaIndex < totalDropTargetHintsCount; dropAreaIndex++) {
        try {
            final String dropArea = configuration.getStringAttribute(DROP_AREA_CONFIG + dropAreaIndex);
            final Element hideHintFor = Document.get().getElementById(dropArea);
            if (hideHintFor != null) {
                hideHintFor.removeClassName(ViewComponentClientCriterion.HINT_AREA_STYLE);
            }
        } catch (final Exception e) {
            // log and continue
            LOGGER.log(Level.SEVERE, "Error highlighting valid drop targets: " + e.getLocalizedMessage());
        }
    }
}
 
Example 5
Source File: EditorImpl.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the various editor bits on the document
 */
private void updateDocumentEditState(boolean editing) {
  Element topLevel = getDocumentHtmlElement();
  // Set property to some arbitrary non-null value if we're in editing mode.
  full().getDocumentElement().setProperty(AnnotationPainter.DOCUMENT_MODE, editing);

  topLevel.removeClassName(WAVE_EDITOR_EDIT_ON);
  topLevel.removeClassName(WAVE_EDITOR_EDIT_OFF);
  topLevel.addClassName(editing ? WAVE_EDITOR_EDIT_ON : WAVE_EDITOR_EDIT_OFF);

  AnnotationPainter.maybeScheduleRepaint(content.getContext(), 0, mutable().size());
  DomHelper.setContentEditable(topLevel, editing, true);

  for (ContentElement element : elementsWithDisplayEditModes) {
    if (element.getParentElement() != null) {
      DisplayEditModeHandler.onEditModeChange(element, editing);
    } else {
      elementsWithDisplayEditModes.remove(element);
    }
  }
}
 
Example 6
Source File: EditorImpl.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the various editor bits on the document
 */
private void updateDocumentEditState(boolean editing) {
  Element topLevel = getDocumentHtmlElement();
  // Set property to some arbitrary non-null value if we're in editing mode.
  full().getDocumentElement().setProperty(AnnotationPainter.DOCUMENT_MODE, editing);

  topLevel.removeClassName(WAVE_EDITOR_EDIT_ON);
  topLevel.removeClassName(WAVE_EDITOR_EDIT_OFF);
  topLevel.addClassName(editing ? WAVE_EDITOR_EDIT_ON : WAVE_EDITOR_EDIT_OFF);

  AnnotationPainter.maybeScheduleRepaint(content.getContext(), 0, mutable().size());
  DomHelper.setContentEditable(topLevel, editing, true);

  for (ContentElement element : elementsWithDisplayEditModes) {
    if (element.getParentElement() != null) {
      DisplayEditModeHandler.onEditModeChange(element, editing);
    } else {
      elementsWithDisplayEditModes.remove(element);
    }
  }
}
 
Example 7
Source File: StyleUtils.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static <S extends CssStyle> void removeStyle(Element e, S style) {
	if (e == null) {
		return;
	}
	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);
	}
}
 
Example 8
Source File: DesktopUniversalPopup.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public void hide() {
  // nothing to do if we are already invisible
  if (!showing) {
    return;
  }

  final Element clone = (Element)getElement().cloneNode(true);
  RootPanel.getBodyElement().appendChild(clone);
  showing = false;
  if (isMaskEnabled) {
    setMaskVisible(false);
  }
  RootPanel.get().remove(DesktopUniversalPopup.this);
  if (shouldAutoHide) {
    deregisterAutoHider();
  }

  // trigger fade-out
  clone.removeClassName(Resources.INSTANCE.css().fadeIn());
  clone.addClassName(Resources.INSTANCE.css().fadeOut());
  clone.getOffsetWidth(); // Force update
  clone.getStyle().setOpacity(0.0);


  // schedule removal of clone from DOM once animation complete
  new ScheduleTimer() {
    @Override
    public void run() {
      clone.removeFromParent();
    }
  }.schedule(DEFAULT_REMOVE_MS);

  // fire popup event listeners
  for (PopupEventListener listener : listeners) {
    listener.onHide(DesktopUniversalPopup.this);
  }
}
 
Example 9
Source File: Page.java    From requestor with Apache License 2.0 5 votes vote down vote up
private static void setPageElementText(String id, String title, boolean alignCenter) {
    final Element e = Document.get().getElementById(id);
    e.setInnerText(title);
    if (alignCenter) {
        e.addClassName("text-center");
    } else {
        e.removeClassName("text-center");
    }
}
 
Example 10
Source File: StyleUtils.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void cleanEnumStyle(Element e, Class<?> enumClass) {
	if (enumClass == null) {
		return;
	}
	for (Object enumValue : enumClass.getEnumConstants()) {
		if (enumValue instanceof CssStyle) {
			String currentClassName = e.getClassName();
			String styleName = ((CssStyle) enumValue).get();
			if (styleName != null && currentClassName != null && e.hasClassName(styleName)) {
				e.removeClassName(styleName);
			}
		}
	}
}
 
Example 11
Source File: Header.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void highlight(String name)
{
    toggleSubnavigation(name);

    com.google.gwt.user.client.Element target = linksPane.getElementById("header-links-ref");
    if(target!=null) // TODO: i think this cannot happen, does it?
    {
        NodeList<Node> childNodes = target.getChildNodes();
        for(int i=0; i<childNodes.getLength(); i++)
        {
            Node n = childNodes.getItem(i);
            if(Node.ELEMENT_NODE == n.getNodeType())
            {
                Element element = (Element) n;
                if(element.getId().equals("header-"+name))
                {
                    element.addClassName("header-link-selected");
                    element.setAttribute("aria-selected", "true");
                }
                else {
                    element.removeClassName("header-link-selected");
                    element.setAttribute("aria-selected", "false");
                }
            }
        }
    }
}
 
Example 12
Source File: PathStylerMixin.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
public void clearStyles() {
    Element bridgeElement = getBridgeElement();
    if (bridgeElement != null) {
        if (shadow != null) {
            bridgeElement.removeClassName("z-depth-" + shadow);
        }
        if (backgroundColor != null) {
            bridgeElement.getStyle().setProperty("background", "");
        }
        if (properties != null) {
            properties.stream().forEach(pathStyleProperty -> clearStyleProperty(pathStyleProperty.getProperty()));
        }
    }
}
 
Example 13
Source File: MaterialWidget.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
protected void clearActiveClass(HasWidgets widget) {
    for (Widget child : widget) {
        Element element = child.getElement();
        if (StyleHelper.containsStyle(element.getClassName(), CssName.ACTIVE)) {
            element.removeClassName(CssName.ACTIVE);
        }

        if (child instanceof HasWidgets) {
            clearActiveClass((HasWidgets) child);
        }
    }
}
 
Example 14
Source File: CubaTwinColSelectWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
public void removeClassName(int optionIndex) {
    Element option = getOptionElement(optionIndex);
    String className = option.getClassName();
    if (className != null && !className.isEmpty()) {
        option.removeClassName(className);
    }
}
 
Example 15
Source File: JQueryFileUploadOverlay.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected static void forceHideDropZones() {
    for (Element dropZone : dropZoneFileUploadMap.keySet()) {
        dropZone.removeClassName(CUBA_FILEUPLOAD_DROPZONE_CLASS);
    }
    if (dragStopTimer != null) {
        dragStopTimer.cancel();
    }
    dragStopTimer = null;
}
 
Example 16
Source File: DateCell.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
private void handleEventRange(final MouseEvent event) {

        if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
            return;
        }

        if (eventRangeStart >= 0) {

            int newY = event.getY();
            int fromY, toY;

            if (newY < eventRangeStart) {
                fromY = newY;
                toY = eventRangeStart;
            } else {
                fromY = eventRangeStart;
                toY = newY;
            }

            eventRangeStop = newY;

            Element main = getElement();
            NodeList<Node> nodes = main.getChildNodes();
            for (int i = 0; i < nodes.getLength(); i++) {

                Element c = (Element) nodes.getItem(i);

                if (Arrays.stream(slotElements).anyMatch(e -> e == c)) {

                    int elemStart = c.getOffsetTop();
                    int elemStop = elemStart + getSlotHeight();
                    if (elemStart >= fromY && elemStart <= toY) {
                        c.addClassName("v-daterange");
                    } else if (elemStop >= fromY && elemStop <= toY) {
                        c.addClassName("v-daterange");
                    } else if (elemStop >= fromY && elemStart <= toY) {
                        c.addClassName("v-daterange");
                    } else {
                        c.removeClassName("v-daterange");
                    }
                }
            }
        }

        event.preventDefault();
    }
 
Example 17
Source File: GanttWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
private void removeResizingStyles(Element bar) {
    bar.removeClassName(STYLE_RESIZING);
}
 
Example 18
Source File: GanttWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
private void removeMovingStyles(Element bar) {
    bar.removeClassName(STYLE_MOVING);
}
 
Example 19
Source File: Tooltip.java    From jetpad-projectional-open-source with Apache License 2.0 4 votes vote down vote up
static void bottom(Element tooltip) {
  if (!isTooltip(tooltip)) return;
  tooltip.getStyle().setMarginTop(PSEUDO_ELEMENT_HEIGHT, Style.Unit.PX);
  tooltip.removeClassName(CSS.tooltipTop());
  tooltip.addClassName(CSS.tooltipBottom());
}
 
Example 20
Source File: Tooltip.java    From jetpad-projectional-open-source with Apache License 2.0 4 votes vote down vote up
static void top(Element tooltip) {
  if (!isTooltip(tooltip)) return;
  tooltip.getStyle().clearMarginTop();
  tooltip.removeClassName(CSS.tooltipBottom());
  tooltip.addClassName(CSS.tooltipTop());
}