Example usage for com.google.gwt.user.client.ui UIObject setStyleName

List of usage examples for com.google.gwt.user.client.ui UIObject setStyleName

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui UIObject setStyleName.

Prototype

public static void setStyleName(Element elem, String style, boolean add) 

Source Link

Document

This convenience method adds or removes a style name for a given element.

Usage

From source file:fi.jasoft.dragdroplayouts.client.ui.VDDVerticalLayout.java

License:Apache License

/**
 * Empasises the drop location of the component when hovering over a
 * hildComponentContainer. Passing null as the container removes any
 * previous emphasis.//from   w w  w. j  ava  2 s.  co m
 * 
 * @param container
 *            The container which we are hovering over
 * @param event
 *            The drag event
 */
protected void emphasis(Widget container, VDragEvent event) {

    // Remove emphasis from previous hovers
    deEmphasis();

    // Null check..
    if (container == null) {
        return;
    }

    currentlyEmphasised = container;

    // Assign the container the drag and drop over style
    if (spacingEnabled) {
        UIObject.setStyleName(container.getElement(), OVER_SPACED, true);
    } else {
        UIObject.setStyleName(container.getElement(), OVER, true);
    }

    // Add drop location specific style
    if (container != this) {
        UIObject.setStyleName(container.getElement(),
                OVER + "-" + getVerticalDropLocation(container, event).toString().toLowerCase(), true);
    } else {
        UIObject.setStyleName(container.getElement(),
                OVER + "-" + VerticalDropLocation.MIDDLE.toString().toLowerCase(), true);
    }
}

From source file:fi.jasoft.dragdroplayouts.client.ui.verticallayout.VDDVerticalLayout.java

License:Apache License

/**
 * Empasises the drop location of the component when hovering over a hildComponentContainer.
 * Passing null as the container removes any previous emphasis.
 * //w  w  w  .j  a  va  2s.c o m
 * @param container The container which we are hovering over
 * @param event The drag event
 */
protected void emphasis(Widget container, VDragEvent event) {

    // Remove emphasis from previous hovers
    deEmphasis();

    // validate container
    if (container == null || !getElement().isOrHasChild(container.getElement())) {
        return;
    }

    currentlyEmphasised = container;

    UIObject.setStyleName(container.getElement(), OVER, true);

    // Add drop location specific style
    if (container != this) {
        UIObject.setStyleName(container.getElement(),
                OVER + "-" + getVerticalDropLocation(container, event).toString().toLowerCase(), true);
    } else {
        UIObject.setStyleName(container.getElement(),
                OVER + "-" + VerticalDropLocation.MIDDLE.toString().toLowerCase(), true);
    }
}