void focusInputField(final FormItem focusItem) { Scheduler.get().scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { // Reset the search field for next time focusItem.focusInItem(); } }); // DeferredCommand.addCommand(new Command() { // public void execute() { // // Reset the search field for next time // focusItem.focusInItem(); // } // }); }
public void openNew() { setText(MESSAGES.dialogNewGroup()); iGrOldName = null; iGrName.setText(String.valueOf((char)('A' + getGroups().size()))); iGrType.setSelectedIndex(0); iGrAssign.setVisible(true); iGrDelete.setVisible(false); iGrUpdate.setVisible(false); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iGrName.setFocus(true); iGrName.selectAll(); } }); center(); }
public SessionDatesSelector(AcademicSessionProvider session) { iAcademicSession = session; iPanel = new UniTimeWidget<DatesPanel>(new DatesPanel()); initWidget(iPanel); iAcademicSession.addAcademicSessionChangeHandler(new AcademicSessionChangeHandler() { @Override public void onAcademicSessionChange(AcademicSessionChangeEvent event) { if (event.isChanged()) init(event.getNewAcademicSessionId()); } }); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { init(iAcademicSession.getAcademicSessionId()); } }); }
public void authenticate() { if (!CONSTANTS.allowUserLogin()) { if (isAllowLookup()) doLookup(); else ToolBox.open(GWT.getHostPageBaseURL() + "login.do?target=" + URL.encodeQueryString(Window.Location.getHref())); return; } AriaStatus.getInstance().setText(ARIA.authenticationDialogOpened()); iError.setVisible(false); iDialog.center(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iUserName.selectAll(); iUserName.setFocus(true); } }); }
public void onModuleLoad() { // Create Exception alert GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable e) { Throwable unwrapped = unwrap(e); LOG.log(Level.SEVERE, "Ex caught!", e); } }); Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { onModuleLoad2(); } }); }
@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(); } }); } }
@Override protected void applySelectionCommand(final Scheduler.ScheduledCommand command) { if (!doubleClickMode || doubleClickHandling) { super.applySelectionCommand(command); } else { Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() { private long scheduledTimestamp = System.currentTimeMillis(); @Override public boolean execute() { if (!doubleClickHandling && lastDoubleClickHandled < scheduledTimestamp) { command.execute(); } return false; } }, 250); } }
@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()) { final Widget hoveredButton = WidgetUtil.findWidget(target, null); if (getElement().isOrHasChild(target)) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { hide(); if (BrowserInfo.get().isIE9()) { if (hoveredButton instanceof CubaButtonWidget) { hoveredButton.removeStyleName("ie9-hover"); } } } }); } } }
@Override public void render(RendererCellReference rendererCellReference, final ComponentConnector componentConnector, final SimplePanel panel) { if (componentConnector != null) { // render chart widgets deferred so measurements are correct. Do not render // normal component widgets deferred as it causes some flicker when rerendering the grid if (componentConnector.getClass().getName().equals("com.vaadin.addon.charts.shared.ChartConnector")) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { panel.setWidget(componentConnector.getWidget()); } }); } else { panel.setWidget(componentConnector.getWidget()); } } else { panel.clear(); } }
@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"); }); } } } }
/** * Populates the info box. Continuously reports which element has browser * focus, and reports timing information for the stage loading. * * @param timeline timeline to report */ private static void showInfo(Timeline timeline) { Element timeBox = Document.get().getElementById("timeline"); timeline.dump(timeBox); Scheduler.get().scheduleFixedDelay(new RepeatingCommand() { private final Element activeBox = Document.get().getElementById("active"); @Override public boolean execute() { Element e = getActiveElement(); String text = (e != null ? e.getTagName() + " id:" + e.getId() : "none"); activeBox.setInnerText(text); return true; } private native Element getActiveElement() /*-{ return $doc.activeElement; }-*/; }, 1000); }
/** * Shows the last stack element in the scroll panel */ private void scrollToLastStackElement() { //Make it into the deferred command because the element might be shown later, //such as if this method is called before the forum section is selected if( messageStack.size() > 0 ) { final MessageStackElement element = messageStack.get( messageStack.size() - 1 ); Scheduler.get().scheduleDeferred( new ScheduledCommand(){ @Override public void execute() { //Ensure that the top stack element is visible in the stack if( element.isAttached() ) { scrollPanel.ensureVisible( element ); } } }); } }
@Override public void onAfterComponentIsAdded() { //Re-add the panel size, here we have to account for the //browsers because they do not render the first view correctly //if the person comes directly to the forum page BrowserDetect detect = BrowserDetect.getBrowserDetect(); if( isFirstTime && ( detect.isChrome() || detect.isSafari() || detect.isFirefox() ) ) { //We do the update in the deferred command because only this way //the browser does it after the rendering of the view is complete Scheduler.get().scheduleDeferred( new ScheduledCommand(){ @Override public void execute() { updateUIElements(); } }); isFirstTime = false; } }
private void onFirstLoadComplete() { WebPlotGroup plotGroup = _plot.getPlotGroup(); plotGroup.computeMinMax(); WebPlotGroup.fireReplotEvent(ReplotDetails.Reason.IMAGE_RELOADED, _plot); if (_pv != null && _pv.contains(_plot)) { if (_firstLoad) { _pv.reconfigure(); Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { public void execute() { _pv.smartCenter(); } }); _firstLoad = false; } else { ImageWorkSpacePt pt = _pv.findCurrentCenterPoint(); _pv.reconfigure(); if (!AllPlots.getInstance().isWCSMatch())_pv.centerOnPoint(pt); } } }
/** * Allows to open a new popup with the url link * @param opener the widget from which we open this pop-up * @param url the url to be displayed */ public static void showPopup( final Widget opener, final String url ) { //Create the popup panel object final CopyUrlInfoPanel panel = new CopyUrlInfoPanel( true, true, url ); //Do not do animation because otherwise Firefox will remove url text selection panel.setAnimationEnabled(false); //Show the pop-up panel at some proper position, in such a way that //it does not go outside the window area, also make the popup modal panel.setPopupPositionAndShow( panel.new InfoPopUpPositionCallback( opener ) ); //Set the text in the text field to be selected, also add focus //Do it deferred in order to make sure that the selectAll is //called after the pop-up is shown and visible Scheduler.get().scheduleDeferred( new ScheduledCommand(){ @Override public void execute() { panel.urlTextBox.setFocus(true); panel.urlTextBox.selectAll(); } }); }
@Override public void updateUIElements() { Scheduler.get().scheduleDeferred( new ScheduledCommand(){ @Override public void execute() { //Adjust the width of the recipients panel, do it in a deferred //command just in case the element is not visible yet commonWidgets.addjustRecipientsScrollPanel(); } }); //Opera can not set the proper width for the message body wrapper. Therefore, //we first try to put the focus to the button and then to the text box if( BrowserDetect.getBrowserDetect().isOpera() ) { sendButton.setFocus(true); } //Propagate the call commonWidgets.updateUIElements(); }
@Override protected void extend(ServerConnector serverConnector) { serverConnector .addStateChangeHandler(new StateChangeEvent.StateChangeHandler() { @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { Scheduler.get().scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { updateResetButtonVisibility(); } }); } }); textField = (VTextField) ((ComponentConnector) serverConnector) .getWidget(); textField.addStyleName(CLASSNAME + "-textfield"); resetButtonElement = DOM.createDiv(); resetButtonElement.addClassName(CLASSNAME + "-resetbutton"); textField.addAttachHandler(this); textField.addKeyUpHandler(this); }
@Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); switch (event.getTypeInt()) { case Event.ONKEYUP: case Event.ONPASTE: { // Scheduler needed so pasted data shows up in TextBox before we fire event Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { fireEvent(new TextChangeEvent()); } }); break; } default: // Do nothing } }
@Override protected void onLoad() { super.onLoad(); load(); if (showOnAttach != null) { // Ensure the side nav starts closed $(activator).trigger("menu-in", null); if (showOnAttach) { Scheduler.get().scheduleDeferred(() -> { // We are ignoring cases with mobile if (Window.getClientWidth() > 960) { show(); } }); } } else { if (Window.getClientWidth() > 960) { $(activator).trigger("menu-out", null); } } }
private SelectableTableWithConstraintsPanel loadCatalogTable(TableServerRequest req) { BaseTableConfig<TableServerRequest> tableConfig = new BaseTableConfig<TableServerRequest>(req, req.getParam(CatalogRequest.CATALOG), req.getParam(CatalogRequest.CATALOG), null, null, null); Loader<TableDataView> loader = tableConfig.getLoader(); loader.setPageSize(300); final SelectableTableWithConstraintsPanel table = new SelectableTableWithConstraintsPanel(loader); table.setMaskDelayMillSec(1); Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { public void execute() { addListeners(table); table.init(); } }); return table; }
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(); } }); } }
public void updateDimensions() { String useragent = getUserAgent(); // Fix some IE/iOS 7.1 bugs if(useragent.contains("msie") || useragent.matches(".*(ipad|iphone);.*cpu.*os 7_\\d.*")) { final SimplePanel panel = this; Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { int width = panel.getOffsetWidth(); //GWT.log(width+"px"); if(width > 0){ panel.getElement().getStyle().setHeight(width, Unit.PX); } } }); } }
@Override public void emit (StringBuilder out, final List<String> lines, final Map<String, String> params) { final String id = HTMLPanel.createUniqueId(); out.append("<div id=\""); out.append(id); out.append("\"> Loading gallery...</div>"); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute () { if (manager != null) { manager.fireEvent(new PluginContentReadyEvent( GalleryPlugin.this, lines, params, id, "None")); } } }); }
@Override protected void onBind() { super.onBind(); getView().setPresenter(this); _serverStore.addChangeHandler(new PropagatesChange.Handler() { @Override public void onChange(Action action) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { if (isVisible()) { loadMetrics(); } } }); } }); }
@Override public void emit (StringBuilder out, final List<String> lines, final Map<String, String> params) { final String id = HTMLPanel.createUniqueId(); out.append("<div id=\""); out.append(id); out.append("\"> Loading form...</div>"); Scheduler.get().scheduleDeferred( () -> { if (manager != null) { manager.fireEvent(new PluginContentReadyEvent(FormPlugin.this, lines, params, id, "None")); } }); }
/** * * @param url * @param checkIntvlInMsec check interval in milliseconds * @param maxTries * @param confirmationCallback */ public static void submitDownloadUrl(String url, int checkIntvlInMsec, final int maxTries, final Command confirmationCallback) { if (checkIntvlInMsec > 0 && maxTries > 0 && confirmationCallback != null) { Frame f = Application.getInstance().getNullFrame(); final String codId = String.valueOf(System.currentTimeMillis()); url += (url.contains("?") ? "&" : "?") + COD_ID + "="+ codId; f.setUrl(url); Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() { int tries = 0; public boolean execute() { String c = Cookies.getCookie(COD_ID); tries++; if ((c != null && c.equals(codId)) || tries > maxTries) { Cookies.removeCookie(COD_ID, "/"); confirmationCallback.execute(); return false; } else { return true; } } }, checkIntvlInMsec); } else { showDebugMsg("InvalidArgumentException: submitDownloadUrl"); } }
@Override public Promise<Void> removeCommand(String name) { final CommandImpl command = commands.get(name); if (command == null) { return promiseProvider.reject(new Exception("Command '" + name + "' does not exist.")); } return doRemoveCommand(name) .then( aVoid -> { // listeners should be notified after returning from #removeCommand method // so let's postpone notification Scheduler.get().scheduleDeferred(() -> notifyCommandRemoved(command)); }); }
void setupSyntaxHighlighting() { if (prefs.syntaxHighlighting() && fileSize.compareTo(FileSize.SMALL) > 0) { Scheduler.get() .scheduleFixedDelay( new RepeatingCommand() { @Override public boolean execute() { if (prefs.syntaxHighlighting() && isAttached()) { setSyntaxHighlighting(prefs.syntaxHighlighting()); } return false; } }, 250); } }
private GutterClickHandler onGutterClick(CodeMirror cm) { return new GutterClickHandler() { @Override public void handle( CodeMirror instance, int line, String gutterClass, NativeEvent clickEvent) { if (Element.as(clickEvent.getEventTarget()).hasClassName(getLineNumberClassName()) && clickEvent.getButton() == NativeEvent.BUTTON_LEFT && !clickEvent.getMetaKey() && !clickEvent.getAltKey() && !clickEvent.getCtrlKey() && !clickEvent.getShiftKey()) { cm.setCursor(Pos.create(line)); Scheduler.get() .scheduleDeferred( new ScheduledCommand() { @Override public void execute() { getCommentManager().newDraftOnGutterClick(cm, gutterClass, line + 1); } }); } } }; }
@Override public void onContextMenu(final int mouseX, final int mouseY, final ProcessTreeNode node) { view.selectNode(node); notifyTreeNodeSelected(node); Scheduler.get() .scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { contextTreeNode = node; ConsoleTreeContextMenu contextMenu = consoleTreeContextMenuFactory.newContextMenu(node); contextMenu.show(mouseX, mouseY); } }); }
@Override public void selectNode(final ProcessTreeNode node) { final SelectionModel<ProcessTreeNode> selectionModel = processTree.getSelectionModel(); if (node == null) { selectionModel.clearSelections(); } else { selectionModel.setTreeActive(true); selectionModel.clearSelections(); selectionModel.selectSingleNode(node); node.getTreeNodeElement().scrollIntoView(); } Scheduler.get() .scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { delegate.onTreeNodeSelected(node); } }); }
private void onRightClick(Event event) { event.preventDefault(); event.stopPropagation(); final int x = event.getClientX(); final int y = event.getClientY(); Scheduler.get() .scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { getSelectionModel().fireSelectionChange(); if (contextMenuInvocationHandler != null && disableNativeContextMenu) { contextMenuInvocationHandler.onInvokeContextMenu(x, y); } } }); }
private void constrainFocusElement() { if (!focusConstrainScheduled) { focusConstrainScheduled = true; Scheduler.get() .scheduleFinally( new Scheduler.ScheduledCommand() { @Override public void execute() { focusConstrainScheduled = false; int scrollLeft = getElement().getScrollLeft(); int scrollTop = getElement().getScrollTop(); int left = getElement().getOffsetWidth() / 2 + scrollLeft; int top = getElement().getOffsetHeight() / 2 + scrollTop; focusEl.getStyle().setTop(top, Style.Unit.PX); focusEl.getStyle().setLeft(left, Style.Unit.PX); } }); } }
@Override public void show(final String value) { super.show(); nameField.setValue(value); setPopupPositionAndShow( new PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { setPopupPosition((Window.getClientWidth() / 2) - (offsetWidth / 2), 60); } }); Scheduler.get() .scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { delegate.valueChanged(value); nameField.setFocus(true); } }); }
public void scrollToStickie(final int absoluteTop) { if (UserAgentChecker.isMobileUserAgent()) { Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() { @Override public boolean execute() { Window.scrollTo(Window.getScrollLeft(), absoluteTop - TOP_MARGIN); return false; } }, DELAY_MS); } }
protected void checkEvents(DeliveryEvent flowEvent) { if (counter < types.length) { assertEquals(types[counter].toString(), flowEvent.getType().toString()); if (flowEvent.getType() == DeliveryEventType.ASSESSMENT_STARTED) { Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { @Override public void execute() { flowInvoker.invokeRequest(new FlowRequest.NavigateFirstItem()); } }); } counter++; } }
public void onModuleLoad() { GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void onUncaughtException(Throwable e) { Throwable u = ToolBox.unwrap(e); sLogger.log(Level.WARNING, MESSAGES.failedUncaughtException(u.getMessage()), u); } }); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { onModuleLoadDeferred(); } }); }
@Override public void center() { super.center(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { if (iTextBox != null) { iTextBox.setFocus(true); iTextBox.selectAll(); } else { iYes.setFocus(true); } } }); }