Example usage for com.google.gwt.user.client Event getCurrentEventTarget

List of usage examples for com.google.gwt.user.client Event getCurrentEventTarget

Introduction

In this page you can find the example usage for com.google.gwt.user.client Event getCurrentEventTarget.

Prototype

public final EventTarget getCurrentEventTarget() 

Source Link

Document

Gets the current target element of this event.

Usage

From source file:com.arcbees.gquery.tooltip.client.TooltipImpl.java

License:Apache License

private static void enter(Event e, TooltipImpl originalImpl) {
    if (!originalImpl.enabled) {
        return;/*from  w  ww  . j a v  a 2  s . c o  m*/
    }

    Element target = e.getCurrentEventTarget().cast();
    final TooltipImpl impl = getTooltipImpl(target, originalImpl.delegationOptions);

    impl.cancelTimer();

    if (impl.options.getDelayShow() == 0) {
        impl.show();
        return;
    }

    impl.setHover(true);

    Timer timer = new Timer() {
        @Override
        public void run() {
            if (impl.isHover()) {
                impl.show();
            }
        }
    };

    impl.setTimer(timer);
    timer.schedule(impl.options.getDelayShow());
}

From source file:com.arcbees.gquery.tooltip.client.TooltipImpl.java

License:Apache License

private static void leave(Event e, TooltipOptions delegateOptions) {
    Element target = e.getCurrentEventTarget().cast();
    final TooltipImpl impl = getTooltipImpl(target, delegateOptions);

    impl.cancelTimer();//from   w w w  . j  a  v a  2 s . co m

    if (impl.options.getDelayHide() == 0) {
        impl.hide();
        return;
    }

    impl.setHover(false);

    Timer timer = new Timer() {
        @Override
        public void run() {
            if (!impl.isHover()) {
                impl.hide();
            }
        }
    };

    impl.setTimer(timer);
    timer.schedule(impl.options.getDelayHide());
}

From source file:com.arcbees.gquery.tooltip.client.TooltipImpl.java

License:Apache License

private static void toggle(Event e, TooltipOptions options) {
    Element target = e.getCurrentEventTarget().cast();
    TooltipImpl impl = getTooltipImpl(target, options);

    impl.toggle();/*from   w w  w.  java  2s .c o m*/
}

From source file:com.cgxlib.core.component.modal.Modal.java

License:Apache License

protected void backdrop(final Function callback) {
    boolean doAnimate = transitions() && viewHandler.useTransitions();

    final String backdropOpt = options.backdrop();
    if (isShown && backdropOpt != null && !"false".equals(backdropOpt.toLowerCase())) {
        $backdrop = viewHandler.createBackdropEl();
        viewHandler.appendBackdropToBody($backdrop);

        Function clickDismiss = new Function() {
            @Override// w  w w .  j  a v  a2 s  .c  om
            public boolean f(Event e) {
                if (ignoreBackdropClick) {
                    ignoreBackdropClick = false;
                } else if (e.getEventTarget() == e.getCurrentEventTarget()) {
                    boolean isBackdropStatic = "static".equals(backdropOpt);
                    if (isBackdropStatic) {
                        viewHandler.handleDismissStaticBackdrop();
                    } else {
                        modalHide(e);
                    }
                }

                return true;
            }
        };
        this.on("click.dismiss.cgx.modal", clickDismiss);

        viewHandler.showBackdrop($backdrop);

        if (callback == null) {
            return;
        }

        if (doAnimate) {
            $backdrop.as(CGXlib.CGX).onceWhenTransitionEnds(callback)
                    .emulateTransitionEnd(transitionDuration());
        } else {
            callback.f();
        }

    } else if (!isShown && $backdrop != null) {
        viewHandler.preRemoveBackdrop($backdrop);

        Function callbackRemove = new Function() {
            @Override
            public void f() {
                viewHandler.removeBackdrop($backdrop);
                $backdrop = null;
                if (callback != null) {
                    callback.f();
                }
            }
        };

        if (doAnimate) {
            $backdrop.as(CGXlib.CGX).onceWhenTransitionEnds(callbackRemove)
                    .emulateTransitionEnd(transitionDuration());
        } else {
            callbackRemove.f();
        }

    } else if (callback != null) {
        callback.f();
    }
}

From source file:com.cgxlib.core.component.tooltip.SingleTooltip.java

License:Apache License

protected SingleTooltip tooltipToggle(Event e, SingleTooltip tooltip) {
    SingleTooltip self = tooltip;/*from w w  w . j  ava2s  .  c o m*/
    if (e != null) {
        XQ $target = $(e.getCurrentEventTarget());
        self = $target.data("cgx." + this.type);
        if (self == null) {
            self = $target.as(CGX);
            $target.data("cgx." + this.type, self);
        }
    }

    if (e != null) {
        self.inState.click = !self.inState.click;
        if (self.inState.isAnyStateTrue()) {
            self.enter(self, false);
        } else {
            self.leave(self, false);
        }
    } else if (viewHandler.isTipIn(self.tip())) {
        self.leave(self, false);
    } else {
        self.enter(self, false);
    }

    return this;
}

From source file:com.cgxlib.xq.client.Function.java

License:Apache License

public Function setEvent(Event e) {
    event = e;/*from   w w  w  .  j a va 2 s . c o  m*/
    element = e != null ? e.getCurrentEventTarget().<com.google.gwt.dom.client.Element>cast() : null;
    return this;
}

From source file:com.urlisit.siteswrapper.cloud.utilities.UrleLoader.java

License:Apache License

private static void init() {
    if (loadingArea == null) {
        loadingArea = DOM.createDiv();/*from www. j  a  va 2s  .c o m*/
        loadingArea.getStyle().setProperty("visibility", "hidden");
        loadingArea.getStyle().setProperty("position", "absolute");
        loadingArea.getStyle().setProperty("width", "1px");
        loadingArea.getStyle().setProperty("height", "1px");
        loadingArea.getStyle().setProperty("overflow", "hidden");
        Document.get().getBody().appendChild(loadingArea);
        Event.setEventListener(loadingArea, new EventListener() {
            @Override
            public void onBrowserEvent(Event event) {
                boolean success;
                if (Event.ONLOAD == event.getTypeInt()) {
                    success = true;
                } else if (Event.ONERROR == event.getTypeInt()) {
                    success = false;
                } else {
                    return;
                }
                if (!ImageElement.is(event.getCurrentEventTarget())) {
                    return;
                }
                ImageElement image = ImageElement.as(Element.as(event.getCurrentEventTarget()));
                int index = findImageInPool(image);
                ImageLoader loader = activeLoaders.get(index);
                Dimensions dim = null;
                if (success) {
                    dim = new Dimensions(image.getWidth(), image.getHeight());
                    dimensionCache.put(loader.url, dim);
                } else {
                    dimensionCache.put(loader.url, new Dimensions(-1, -1));
                }
                loadingArea.removeChild(image);
                activeLoaders.remove(index);
                ImageLoadEvent evt = new ImageLoadEvent(image, dim);
                loader.fireHandlers(evt);
            }

        });
    }
}

From source file:cu.softel.integro.client.shared.tooltip.TooltipImpl.java

License:Apache License

private static void enter(Event e, TooltipOptions delegateOptions) {
    Element target = e.getCurrentEventTarget().cast();
    final TooltipImpl impl = getImpl(target, delegateOptions);

    impl.cancelTimer();//w  w w  . j ava  2s  .c  om

    if (impl.options.getDelayShow() == 0) {
        impl.show();
        return;
    }

    impl.setHover(true);

    Timer timer = new Timer() {
        @Override
        public void run() {
            if (impl.isHover()) {
                impl.show();
            }
        }
    };

    impl.setTimer(timer);
    timer.schedule(impl.options.getDelayShow());
}

From source file:cu.softel.integro.client.shared.tooltip.TooltipImpl.java

License:Apache License

private static void leave(Event e, TooltipOptions delegateOptions) {
    Element target = e.getCurrentEventTarget().cast();
    final TooltipImpl impl = getImpl(target, delegateOptions);

    impl.cancelTimer();//from  www  .j  a va2s.co m

    if (impl.options.getDelayHide() == 0) {
        impl.hide();
        return;
    }

    impl.setHover(false);

    Timer timer = new Timer() {
        @Override
        public void run() {
            if (!impl.isHover()) {
                impl.hide();
            }
        }
    };

    impl.setTimer(timer);
    timer.schedule(impl.options.getDelayHide());
}

From source file:cu.softel.integro.client.shared.tooltip.TooltipImpl.java

License:Apache License

private static void toggle(Event e, TooltipOptions options) {
    Element target = e.getCurrentEventTarget().cast();
    TooltipImpl impl = getImpl(target, options);

    impl.toggle();//from w  w  w  .  ja v  a 2s  .c  o  m
}