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