Search in sources :

Example 56 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project che by eclipse.

the class PopupMenu method openSubPopup.

private void openSubPopup(final Element tableRowElement) {
    if (tableRowElement == null) {
        return;
    }
    if (openedSubPopup != null) {
        if (tableRowElement == subPopupAnchor) {
            return;
        }
        openedSubPopup.closePopup();
    }
    if (subPopupAnchor != null) {
        Element e = subPopupAnchor;
        subPopupAnchor = null;
        setStyleNormal(e);
    }
    subPopupAnchor = tableRowElement;
    setStyleHovered(subPopupAnchor);
    int itemIndex = Integer.parseInt(tableRowElement.getAttribute("item-index"));
    Action menuItem = list.get(itemIndex);
    String idPrefix = itemIdPrefix;
    if (idPrefix != null) {
        idPrefix += "/" + presentationFactory.getPresentation(menuItem).getText();
    }
    openedSubPopup = new PopupMenu((ActionGroup) menuItem, actionManager, managerProvider, presentationFactory, lockLayer, actionSelectedHandler, keyBindingAgent, idPrefix);
    final int HORIZONTAL_OFFSET = 3;
    final int VERTICAL_OFFSET = 1;
    openedSubPopup.getElement().getStyle().setVisibility(Visibility.HIDDEN);
    lockLayer.add(openedSubPopup, 0, 0);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            int left = getAbsoluteLeft() + getOffsetWidth() - HORIZONTAL_OFFSET;
            int top = tableRowElement.getAbsoluteTop() - lockLayer.getTopOffset() - VERTICAL_OFFSET;
            if (left + openedSubPopup.getOffsetWidth() > Window.getClientWidth()) {
                if (left > openedSubPopup.getOffsetWidth()) {
                    left = getAbsoluteLeft() - openedSubPopup.getOffsetWidth() + HORIZONTAL_OFFSET;
                } else {
                    int diff = left + openedSubPopup.getOffsetWidth() - Window.getClientWidth();
                    left -= diff;
                }
            }
            if (top + openedSubPopup.getOffsetHeight() > Window.getClientHeight()) {
                if (top > openedSubPopup.getOffsetHeight()) {
                    top = tableRowElement.getAbsoluteTop() - openedSubPopup.getOffsetHeight() + VERTICAL_OFFSET;
                } else {
                    int diff = top + openedSubPopup.getOffsetHeight() - Window.getClientHeight();
                    top -= diff;
                }
            }
            openedSubPopup.getElement().getStyle().setLeft(left, Unit.PX);
            openedSubPopup.getElement().getStyle().setTop(top, Unit.PX);
            openedSubPopup.getElement().getStyle().setVisibility(Visibility.VISIBLE);
        }
    });
}
Also used : ToggleAction(org.eclipse.che.ide.api.action.ToggleAction) Action(org.eclipse.che.ide.api.action.Action) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) Element(com.google.gwt.dom.client.Element)

Example 57 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project che by eclipse.

the class AnimationController method hide.

/**
     * Animate the element out of view. Do not enable transitions in the CSS for this element, or the
     * animations may not work correctly. AnimationController will enable animations automatically.
     *
     * @see #hideWithoutAnimating(Element)
     */
public void hide(final Element element) {
    // Early exit if the element is hidden or hiding.
    if (isAnyState(element, State.HIDDEN, State.HIDING)) {
        return;
    }
    if (!isAnimated) {
        hideWithoutAnimating(element);
        return;
    }
    // Cancel pending transition event listeners.
    showEndHandler.unhandleEndFor(element);
    final CSSStyleDeclaration style = element.getStyle();
    if (options.collapse) {
        // Set height because the CSS transition requires one
        int height = getCurrentHeight(element);
        style.setHeight(height + CSSStyleDeclaration.Unit.PX);
    }
    // Give the browser a chance to accept the height set above
    setState(element, State.HIDING);
    schedule(element, new ScheduledCommand() {

        @Override
        public void execute() {
            // The user changed the state before this command executed.
            if (!clearLastCommand(element, this) || !isAnyState(element, State.HIDING)) {
                return;
            }
            if (options.collapse) {
                /*
           * Hide overflow if changing height, or the overflow will be visible
           * even as the element collapses.
           */
                AnimationUtils.backupOverflow(style);
            }
            AnimationUtils.enableTransitions(style);
            if (options.collapse) {
                // Animate all properties that could affect height if collapsing.
                style.setHeight("0");
                style.setMarginTop("0");
                style.setMarginBottom("0");
                style.setPaddingTop("0");
                style.setPaddingBottom("0");
                CssUtils.setBoxShadow(element, "0 0");
            }
            if (options.fade) {
                style.setOpacity(0);
            }
        }
    });
    // For webkit based browsers.
    hideEndHandler.handleEndFor(element);
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) CSSStyleDeclaration(elemental.css.CSSStyleDeclaration)

Example 58 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project che by eclipse.

the class AnimationUtils method flash.

/** Flashes an element to highlight that it has recently changed. */
public static void flash(final Element elem) {
    /*
     * If we interrupt a flash with another flash, we need to disable animations
     * so the initial background color takes effect immediately. Animations are
     * reenabled in animatePropertySet.
     */
    removeTransitions(elem.getStyle());
    elem.getStyle().setBackgroundColor("#f9edbe");
    // Give the start color a chance to take effect.
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            animatePropertySet(elem, "background-color", "", ALERT_TRANSITION_DURATION);
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 59 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project che by eclipse.

the class BootstrapController method startExtensionsAndDisplayUI.

private void startExtensionsAndDisplayUI() {
    // Change background color according to the current theme
    if (Style.theme != null) {
        Document.get().getBody().getStyle().setBackgroundColor(Style.theme.backgroundColor());
    }
    appStateManagerProvider.get();
    displayIDE();
    extensionInitializer.startExtensions();
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            notifyShowIDE();
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 60 with ScheduledCommand

use of com.google.gwt.core.client.Scheduler.ScheduledCommand in project gwt-test-utils by gwt-test-utils.

the class SchedulerTest method scheduledCommandOrderWithRpcCall.

@Test
public void scheduledCommandOrderWithRpcCall() {
    // Given
    final StringBuilder sb = new StringBuilder();
    final MyRemoteServiceAsync service = GWT.create(MyRemoteService.class);
    Scheduler.get().scheduleEntry(new ScheduledCommand() {

        public void execute() {
            sb.append("scheduleEntry1 ");
        }
    });
    Scheduler.get().scheduleFinally(new ScheduledCommand() {

        public void execute() {
            sb.append("scheduleFinally1 ");
        }
    });
    service.myMethod("service1", new AsyncCallback<String>() {

        public void onFailure(Throwable caught) {
        }

        public void onSuccess(String result) {
            sb.append("onSuccess1 ");
        }
    });
    service.myMethod("service2", new AsyncCallback<String>() {

        public void onFailure(Throwable caught) {
        }

        public void onSuccess(String result) {
            sb.append("onSuccess2 ");
        }
    });
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        public void execute() {
            sb.append("scheduleDeferred1 ");
            service.myMethod("service3", new AsyncCallback<String>() {

                public void onFailure(Throwable caught) {
                }

                public void onSuccess(String result) {
                    sb.append("onSuccess3 ");
                }
            });
            Scheduler.get().scheduleEntry(new ScheduledCommand() {

                public void execute() {
                    sb.append("scheduleEntry2 ");
                    Scheduler.get().scheduleEntry(new ScheduledCommand() {

                        public void execute() {
                            sb.append("scheduleEntry3 ");
                        }
                    });
                }
            });
            Scheduler.get().scheduleFinally(new ScheduledCommand() {

                public void execute() {
                    sb.append("scheduleFinally2 ");
                    Scheduler.get().scheduleFinally(new ScheduledCommand() {

                        public void execute() {
                            sb.append("scheduleFinally3 ");
                        }
                    });
                }
            });
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                public void execute() {
                    sb.append("scheduleDeferred2 ");
                }
            });
        }
    });
    // When
    getBrowserSimulator().fireLoopEnd();
    // Then
    assertThat(sb.toString()).isEqualTo("scheduleFinally1 scheduleEntry1 scheduleDeferred1 onSuccess1 onSuccess2 scheduleFinally2 scheduleFinally3 scheduleEntry2 scheduleEntry3 scheduleDeferred2 onSuccess3 ");
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Test(org.junit.Test)

Aggregations

ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)105 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)7 Element (com.google.gwt.dom.client.Element)6 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)6 JsArray (com.google.gwt.core.client.JsArray)5 Command (com.google.gwt.user.client.Command)5 ServerError (org.rstudio.studio.client.server.ServerError)5 JsArrayString (com.google.gwt.core.client.JsArrayString)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)4 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 Event (com.google.gwt.user.client.Event)3 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)3 Timer (com.google.gwt.user.client.Timer)3 WindowEx (org.rstudio.core.client.dom.WindowEx)3 SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)3 ErrorDialog (com.google.gerrit.client.ErrorDialog)2 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2