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);
}
}
}
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();
}
}
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);
}
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);
}
});
}
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);
}
}
});
}
}
Aggregations