Search in sources :

Example 1 with ScheduledCommand

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

the class AnnotationModelImpl method cleanup.

/**
     * Removes all annotations from the model whose associated positions have been deleted. If requested inform all model listeners about
     * the change. If requested a new thread is created for the notification of the model listeners.
     *
     * @param fireModelChanged indicates whether to notify all model listeners
     */
private void cleanup(final boolean fireModelChanged) {
    if (documentChanged) {
        documentChanged = false;
        final List<Annotation> deleted = new ArrayList<Annotation>();
        final Iterator<Annotation> e = getAnnotationIterator();
        while (e.hasNext()) {
            final Annotation annotation = e.next();
            final Position pos = annotations.get(annotation);
            if (pos == null || pos.isDeleted()) {
                deleted.add(annotation);
            }
        }
        if (fireModelChanged) {
            removeAnnotations(deleted, false);
            if (modelEvent != null) {
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        fireModelChanged();
                    }
                });
            }
        } else {
            removeAnnotations(deleted, fireModelChanged);
        }
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Position(org.eclipse.che.ide.api.editor.text.Position) TypedPosition(org.eclipse.che.ide.api.editor.text.TypedPosition) ArrayList(java.util.ArrayList) Annotation(org.eclipse.che.ide.api.editor.text.annotation.Annotation)

Example 2 with ScheduledCommand

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

the class BootstrapController method startComponents.

private void startComponents(final Iterator<Map.Entry<String, Provider<Component>>> componentIterator) {
    if (componentIterator.hasNext()) {
        Map.Entry<String, Provider<Component>> entry = componentIterator.next();
        final String componentName = entry.getKey();
        try {
            Provider<Component> componentProvider = entry.getValue();
            final Component component = componentProvider.get();
            component.start(new Callback<Component, Exception>() {

                @Override
                public void onSuccess(Component result) {
                    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                        @Override
                        public void execute() {
                            startComponents(componentIterator);
                        }
                    });
                }

                @Override
                public void onFailure(Exception reason) {
                    Log.error(getClass(), "Unable to start " + componentName, reason);
                    initializationFailed(reason.getMessage());
                }
            });
        } catch (Exception e) {
            Log.error(getClass(), "Unable to start " + componentName, e);
            initializationFailed(e.getMessage());
        }
    } else {
        startExtensionsAndDisplayUI();
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) WsAgentComponent(org.eclipse.che.ide.api.component.WsAgentComponent) Component(org.eclipse.che.ide.api.component.Component) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) OperationException(org.eclipse.che.api.promises.client.OperationException) Provider(com.google.inject.Provider)

Example 3 with ScheduledCommand

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

the class AnimationController method show.

/**
     * Animates the element into view. Do not enable transitions in the CSS for this element, or the
     * animations may not work correctly. AnimationController will enable animations automatically.
     */
public void show(final Element element) {
    // Early exit if the element is shown or showing.
    if (isAnyState(element, State.SHOWN, State.SHOWING)) {
        return;
    }
    if (!isAnimated) {
        showWithoutAnimating(element);
        return;
    }
    // Cancel pending transition event listeners.
    hideEndHandler.unhandleEndFor(element);
    /*
     * Make this "visible" again so we can measure its eventual height (required
     * for CSS transitions). We will set its initial state in this event loop,
     * so the element will not be fully visible.
     */
    final CSSStyleDeclaration style = element.getStyle();
    element.getStyle().removeProperty("display");
    final int measuredHeight = getCurrentHeight(element);
    /*
     * Set the initial state, but not if the element is in the process of
     * hiding.
     */
    if (!isAnyState(element, State.HIDING)) {
        if (options.collapse) {
            // Start the animation at a height of zero.
            style.setHeight("0");
            // We want to animate from total height of 0
            style.setMarginTop("0");
            style.setMarginBottom("0");
            style.setPaddingTop("0");
            style.setPaddingBottom("0");
            CssUtils.setBoxShadow(element, "0 0");
            /*
         * Hide overflow if expanding the element, or the entire element will be
         * instantly visible. Do not do this by default, because it could hide
         * absolutely positioned elements outside of the root element, such as
         * the arrow on a tooltip.
         */
            AnimationUtils.backupOverflow(style);
        }
        if (options.fade) {
            style.setOpacity(0);
        }
    }
    // Give the browser a chance to accept the properties set above
    setState(element, State.SHOWING);
    schedule(element, new ScheduledCommand() {

        @Override
        public void execute() {
            // The user changed the state before this command executed.
            if (!clearLastCommand(element, this) || !isAnyState(element, State.SHOWING)) {
                return;
            }
            // Enable animations before setting the end state.
            AnimationUtils.enableTransitions(style);
            // Set the end state.
            if (options.collapse) {
                if (options.fixedHeight) {
                    // The element's styles have a fixed height set, so we just want to
                    // clear our override
                    style.setHeight("");
                } else {
                    // Give it an explicit height to animate to, because the element's
                    // height is auto otherwise
                    style.setHeight(measuredHeight + CSSStyleDeclaration.Unit.PX);
                }
                style.removeProperty("margin-top");
                style.removeProperty("margin-bottom");
                style.removeProperty("padding-top");
                style.removeProperty("padding-bottom");
                CssUtils.removeBoxShadow(element);
            }
            if (options.fade) {
                style.setOpacity(1);
            }
        }
    });
    // For webkit based browsers.
    showEndHandler.handleEndFor(element);
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) CSSStyleDeclaration(elemental.css.CSSStyleDeclaration)

Example 4 with ScheduledCommand

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

the class AnimationUtils method fadeIn.

public static void fadeIn(final Element elem) {
    elem.getStyle().setDisplay(CSSStyleDeclaration.Display.BLOCK);
    // TODO: This smells like a chrome bug to me that we need to do a
    // deferred command here.
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            animatePropertySet(elem, "opacity", "1.0", SHORT_TRANSITION_DURATION);
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand)

Example 5 with ScheduledCommand

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

the class Window method show.

/**
     * Displays the {@link Window} popup. The popup will animate into view.
     *
     * @param selectAndFocusElement
     *         an {@link Focusable} to select and focus on when the panel is
     *         shown. If null, no element will be given focus
     */
public void show(@Nullable final Focusable selectAndFocusElement) {
    setBlocked(false);
    if (isShowing) {
        return;
    }
    isShowing = true;
    // Attach the popup to the body.
    final JsElement popup = view.popup.getElement().cast();
    if (popup.getParentElement() == null) {
        // Hide the popup so it can enter its initial state without flickering.
        popup.getStyle().setVisibility("hidden");
        RootLayoutPanel.get().add(view);
    }
    // The popup may have been hidden before this timer executes.
    if (isShowing) {
        popup.getStyle().removeProperty("visibility");
        // Start the animation after the element is attached.
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                // The popup may have been hidden before this timer executes.
                view.setShowing(true);
                if (selectAndFocusElement != null) {
                    selectAndFocusElement.setFocus(true);
                }
            }
        });
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) JsElement(elemental.js.dom.JsElement)

Aggregations

ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)104 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