Java Code Examples for com.google.gwt.core.client.Scheduler

The following examples show how to use com.google.gwt.core.client.Scheduler. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: core   Source File: SearchTool.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public void showPopup() {

        popup.setWidth(640);
        popup.setHeight(480);
        popup.setModal(true);
        popup.setGlassEnabled(true);
        popup.center();

        Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
            @Override
            public void execute() {
                if (index.isEmpty()) {
                    popup.index();
                } else {
                    popup.showSearchPage();
                }
            }
        });
    }
 
Example 2
Source Project: gwtbootstrap3-extras   Source File: Animate.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Animate any element with specific animation. Animation is done by CSS and runs multiple times.
 *
 * Animation is started when element is appended to the DOM or new (not same) animation is added
 * to already displayed element. Animation runs on hidden elements too and is not paused/stopped
 * when element is set as hidden.
 *
 * @param widget Widget to apply animation to.
 * @param animation Custom CSS class name used as animation.
 * @param count Number of animation repeats. 0 disables animation, any negative value set repeats to infinite.
 * @param duration Animation duration in ms. 0 disables animation, any negative value keeps default of original animation.
 * @param delay Delay before starting the animation loop in ms. Value <= 0 means no delay.
 * @param <T> Any object extending UIObject class (typically Widget).
 * @return Animation's CSS class name, which can be removed to stop animation.
 */
public static <T extends UIObject> String animate(final T widget, final String animation, final int count, final int duration, final int delay) {

    if (widget != null && animation != null) {
        // on valid input
        if (widget.getStyleName().contains(animation)) {
            // animation is present, remove it and run again.
            stopAnimation(widget, animation);
            Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
                @Override
                public boolean execute() {
                    styleElement(widget.getElement(), animation, count, duration, delay);
                    return false;
                }
            }, 200);
            return animation + " " + getStyleNameFromAnimation(animation,count,duration,delay);
        } else {
            // animation was not present, run immediately
            return styleElement(widget.getElement(), animation, count, duration, delay);
        }
    } else {
        return null;
    }

}
 
Example 3
Source Project: cuba   Source File: CubaFileUploadProgressWindow.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onAttach() {
    super.onAttach();

    /*
     * When this window gets reattached, set the tabstop to the previous
     * state.
     */
    setTabStopEnabled(doTabStop);

    // Fix for #14413. Any pseudo elements inside these elements are not
    // visible on initial render unless we shake the DOM.
    if (BrowserInfo.get().isIE8()) {
        closeBox.getStyle().setDisplay(Style.Display.NONE);
        Scheduler.get().scheduleFinally(new Command() {
            @Override
            public void execute() {
                closeBox.getStyle().clearDisplay();
            }
        });
    }
}
 
Example 4
Source Project: unitime   Source File: PinDialog.java    License: Apache License 2.0 6 votes vote down vote up
public void checkEligibility(boolean online, boolean sectioning, Long sessionId, Long studentId, PinCallback callback, AcademicSessionInfo session) {
	iOnline = online;
	iSectioning = sectioning;
	iSessionId = sessionId;
	iStudentId = studentId;
	iCallback = callback;
	if (session != null) {
		setText(MESSAGES.dialogPinForSession(session.getTerm(), session.getYear()));
		iPinLabel.setText(MESSAGES.pinForSession(session.getTerm(), session.getYear()));
	} else {
		setText(MESSAGES.dialogPin());
		iPinLabel.setText(MESSAGES.pin());
	}
	iPin.setText("");
	center();
	Scheduler.get().scheduleDeferred(new ScheduledCommand() {
		@Override
		public void execute() {
			iPin.setFocus(true);
		}
	});
}
 
Example 5
Source Project: cuba   Source File: CubaMaskedFieldWidget.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onFocus(FocusEvent event) {
    super.onFocus(event);

    if (!this.focused) {
        this.focused = true;

        if (!isReadOnly() && isEnabled()) {
            if (mask != null && nullRepresentation != null && nullRepresentation.equals(super.getText())) {
                addStyleName("c-focus-move");

                Scheduler.get().scheduleDeferred(() -> {
                    if (!isReadOnly() && isEnabled() && focused) {
                        setSelectionRange(getPreviousPos(0), 0);
                    }

                    removeStyleName("c-focus-move");
                });
            }
        }
    }
}
 
Example 6
private void initOnEdit() {
//        LOG.info("initOnEdit");
        originChildren = null;
        lastClicked = null;
        updateReorderUi(false);
        attachListResultSet();
        // select first
        if (!childrenListGrid.getOriginalResultSet().isEmpty()) {
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    // defer the select as it is ignored after refresh in onDataArrived
                    selectChildFromHistory();
                }
            });
        }
    }
 
Example 7
Source Project: core   Source File: Bootstrapper.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private void prepareSecurityContext(Scheduler.ScheduledCommand andThen) {
    // creates an empty (always true) security context for the bootstrap steps
    /*securityFramework.createSecurityContext(null, Collections.<String>emptySet(), false,
            new AsyncCallback<SecurityContext>() {
                @Override
                public void onFailure(Throwable caught) {
                    andThen.execute();
                }

                @Override
                public void onSuccess(SecurityContext result) {
                    andThen.execute();
                }
            });*/
    andThen.execute();
}
 
Example 8
@Override
public void setPreview(final SafeHtml html) {
    Scheduler.get().scheduleDeferred(() -> {
        contentCanvas.clear();
        contentCanvas.add(new ScrollPanel(new HTML(html)));
    });
}
 
Example 9
Source Project: core   Source File: DataSourceFinder.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void verifyConnection(final DataSource dataSource, boolean xa, boolean existing,
        Scheduler.ScheduledCommand onCreated) {
    VerifyConnectionOp vop = new VerifyConnectionOp(dataSourceStore, dispatcher, beanFactory,
            currentProfileSelection.getName());
    vop.execute(dataSource, xa, existing, new SimpleCallback<VerifyConnectionOp.VerifyResult>() {
        @Override
        public void onSuccess(final VerifyConnectionOp.VerifyResult result) {
            getView().showVerifyConncectionResult(dataSource.getName(), result);
            if (result.wasCreated() && onCreated != null) {
                Scheduler.get().scheduleDeferred(onCreated);
            }
        }
    });
}
 
Example 10
@Override
public void setPreview(final SafeHtml html) {

    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            previewCanvas.clear();
            previewCanvas.add(new ScrollPanel(new HTML(html)));
        }
    });

}
 
Example 11
public Widget asWidget() {


        filter.setMaxLength(30);
        filter.setVisibleLength(20);
        filter.getElement().setAttribute("style", "width:120px;");

        filter.addKeyUpHandler(new KeyUpHandler() {
            @Override
            public void onKeyUp(KeyUpEvent keyUpEvent) {

                Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

                    @Override
                    public void execute() {
                        String prefix = filter.getText();

                        if (prefix != null && !prefix.equals("")) {
                            // filter by prefix
                            filterByPrefix(prefix);
                        } else {
                            clearFilter();
                        }
                    }

                });
            }
        });
        HorizontalPanel panel = new HorizontalPanel();
        Label label = new Label(Console.CONSTANTS.common_label_filter() + ": ");
        panel.add(label);
        panel.add(filter);

        label.getElement().setAttribute("style", "padding-top:8px;margin-right:8px");
        return panel;
    }
 
Example 12
Source Project: core   Source File: SearchPopup.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
void showSearchPage() {
    deck.showWidget(1);
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            textBox.setFocus(true);
        }
    });
}
 
Example 13
Source Project: appinventor-extensions   Source File: YaProjectEditor.java    License: Apache License 2.0 5 votes vote down vote up
private void callLoadProject() {
  Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
    @Override
    public void execute() {
      if (!readyToLoadProject()) { // wait till project is processed
        Scheduler.get().scheduleDeferred(this);
      } else {
        loadProject();
      }
    }
  });
}
 
Example 14
Source Project: cuba   Source File: CubaFileUploadWidget.java    License: Apache License 2.0 5 votes vote down vote up
public void setPasteZone(final Widget pasteZone) {
    if (pasteZone != null) {
        Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
            @Override
            public void execute() {
                fileUpload.setPasteZone(pasteZone.getElement());
            }
        });
    } else {
        fileUpload.setPasteZone(null);
    }
}
 
Example 15
Source Project: core   Source File: LogFilePanel.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void onResize() {
    Scheduler.get().scheduleDeferred(() -> {
        int panelHeight = panel.getElement().getParentElement().getOffsetHeight();
        int editorHeight = panelHeight - HEADER_HEIGHT - TOOLS_HEIGHT - MARGIN_BOTTOM;

        if (panelHeight > 0) {
            editor.setHeight(editorHeight + "px");
        }
    });
}
 
Example 16
Source Project: cuba   Source File: CubaTooltip.java    License: Apache License 2.0 5 votes vote down vote up
protected void showTooltip(boolean forceShow) {
    // Schedule timer for showing the tooltip according to if it
    // was recently closed or not.
    int timeout = 0;
    if (!forceShow) {
        timeout = justClosed ? getQuickOpenDelay() : getOpenDelay();
    }
    if (timeout == 0) {
        Scheduler.get().scheduleDeferred(this::showTooltip);
    } else {
        showTimer.schedule(timeout);
        opening = true;
    }
}
 
Example 17
@Override
public void setPreview(final SafeHtml html) {
    Scheduler.get().scheduleDeferred(() -> {
        previewCanvas.clear();
        previewCanvas.add(new ScrollPanel(new HTML(html)));
    });
}
 
Example 18
Source Project: cuba   Source File: CubaSuggestionFieldWidget.java    License: Apache License 2.0 5 votes vote down vote up
protected void showSuggestions(boolean userOriginated) {
    Scheduler.get().scheduleDeferred(() -> {
        suggestionsContainer.clearItems();

        for (Suggestion suggestion : suggestions) {
            SuggestionItem menuItem = new SuggestionItem(suggestion);
            menuItem.setScheduledCommand(this::selectSuggestion);

            String styleName = suggestion.getStyleName();
            if (styleName != null && !styleName.isEmpty()) {
                menuItem.addStyleName(suggestion.getStyleName());
            }

            suggestionsContainer.addItem(menuItem);
        }
        suggestionsContainer.selectItem(0);

        suggestionsPopup.removeAutoHidePartner(getElement());
        suggestionsPopup.addAutoHidePartner(getElement());

        if ((isFocused() || !userOriginated)
                && (!suggestionsPopup.isAttached() || !suggestionsPopup.isVisible())) {
            suggestionsPopup.showPopup();
        }

        suggestionsPopup.updateWidth();
    });
}
 
Example 19
Source Project: gantt   Source File: GanttConnector.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onElementResize(ElementResizeEvent e) {
    final int height = e.getElement().getClientHeight();
    final int width = e.getElement().getClientWidth();
    if (previousHeight != height) {
        previousHeight = height;

        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                getWidget().notifyHeightChanged(height);
                updateDelegateTargetHeight();
            }
        });
    }
    if (previousWidth != width) {
        previousWidth = width;
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                getWidget().notifyWidthChanged(width);
                updateAllStepsPredecessors();
                updateDelegateTargetHeight();
            }
        });
    }
}
 
Example 20
@Override
protected void onAction(Action action) {
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            loadEndpoints(false);

        }
    });    }
 
Example 21
@Override
public void setPreview(SafeHtml html) {
    Scheduler.get().scheduleDeferred(() -> {
        previewCanvas.clear();
        previewCanvas.add(new ScrollPanel(new HTML(html)));
    });
}
 
Example 22
Source Project: cuba   Source File: CubaGroupTableWidget.java    License: Apache License 2.0 5 votes vote down vote up
private void setSpannedRowWidthAfterDOMFullyInited() {
    // Defer setting width on spanned columns to make sure that
    // they are added to the DOM before trying to calculate
    // widths.
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            calcAndSetWidthForSpannedCell();
        }
    });
}
 
Example 23
Source Project: cuba   Source File: Tools.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreviewNativeEvent(Event.NativePreviewEvent event) {
    super.onPreviewNativeEvent(event);

    NativeEvent nativeEvent = event.getNativeEvent();
    Element target = Element.as(nativeEvent.getEventTarget());

    if (Event.ONCLICK == event.getTypeInt()) {
        if (getElement().isOrHasChild(target)) {
            Scheduler.get().scheduleDeferred(this::hide);
        }
    }

    previewTableContextMenuEvent(event);
}
 
Example 24
Source Project: swellrt   Source File: ServerlessEntryPoint.java    License: Apache License 2.0 5 votes vote down vote up
@JsIgnore
@Override
public void onModuleLoad() {

  // Model factory is used in remote Waves
  ModelFactory.instance = null;
  ServiceConfig.configProvider = getConfigProvider();
  getEditorConfigProvider();

  GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {

    @Override
    public void onUncaughtException(Throwable e) {
      Console.log("Uncaught Exception: " + e.getMessage());
      String string = "";
      for (StackTraceElement element : e.getStackTrace()) {
        string += element + "\n";
      }
      Console.log("Trace: ");
      Console.log(string);

    }
  });

  Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
    @Override
    public void execute() {

      service = new ServerlessFrontend();
      notifyOnLoadHandlers(service);

    }
  });

}
 
Example 25
public void doCollapse(final boolean collapse) {
	if (collapse != this.collapsed) {
		EventBus.get().fireEventFromSource(new CollapseEvent(CollapseHelper.this, collapse), CollapseHelper.this);

		this.collapsableElement.getStyle().setHeight(this.collapsableElement.getOffsetHeight(), Unit.PX);

		StyleUtils.removeStyle(this.collapsableElement, CollapseHelper.STYLE_COLLAPSE);
		StyleUtils.removeStyle(this.collapsableElement, CollapseHelper.STYLE_VISIBLE);
		StyleUtils.addStyle(this.collapsableElement, CollapseHelper.STYLE_COLLAPSING);

		final int endHeight = collapse ? 0 : this.collapsableElement.getScrollHeight();

		Scheduler.get().scheduleDeferred(new ScheduledCommand() {

			@Override
			public void execute() {
				CollapseHelper.this.collapsableElement.getStyle().setHeight(endHeight, Unit.PX);
			}
		});

		Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

			@Override
			public boolean execute() {
				CollapseHelper.this.collapsableElement.getStyle().clearHeight();
				StyleUtils.removeStyle(CollapseHelper.this.collapsableElement, CollapseHelper.STYLE_COLLAPSING);
				StyleUtils.addStyle(CollapseHelper.this.collapsableElement, CollapseHelper.STYLE_COLLAPSE);
				StyleUtils.toggleStyle(CollapseHelper.this.collapsableElement, CollapseHelper.STYLE_VISIBLE, !collapse);
				return false;
			}
		}, 350);
		this.collapsed = collapse;
	}
}
 
Example 26
@Override
protected void onAction(Action action) {
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            refresh(true);
        }
    });
}
 
Example 27
Source Project: cuba   Source File: CubaVerticalSplitPanelConnector.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void postLayout() {
    // Have to re-layout after parent layout expand hack applied
    // to avoid split position glitch.
    if (updateLayout) {
        Scheduler.get().scheduleFinally(this::layout);
        updateLayout = false;
    }
}
 
Example 28
Source Project: cuba   Source File: CubaTreeGridWidget.java    License: Apache License 2.0 5 votes vote down vote up
protected Scheduler.ScheduledCommand getSelectAllCommand() {
    return () -> {
        for (Column column : getColumns()) {
            if (column.isHidden()) {
                column.setHidden(false);
            }
        }
    };
}
 
Example 29
@Override
public void setPreview(final SafeHtml html) {
    Scheduler.get().scheduleDeferred(() -> {
        contentCanvas.clear();
        contentCanvas.add(new ScrollPanel(new HTML(html)));
    });
}
 
Example 30
Source Project: core   Source File: RepositoryView.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setFullScreen(final boolean fullscreen) {
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            layout.setWidgetHidden(nav, fullscreen);

            editor.updateEditorConstraints();
        }
    });

}