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

The following are top voted examples for showing how to use com.google.gwt.core.client.Scheduler. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OSWf-OSWorkflow-fork   File: ActorView.java   View source code 6 votes vote down vote up
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();
        //     }
        // });
        
    }
 
Example 2
Project: OSWf-OSWorkflow-fork   File: InputsView.java   View source code 6 votes vote down vote up
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();
    //     }
    // });
    
}
 
Example 3
Project: unitimes   File: CurriculaCourses.java   View source code 6 votes vote down vote up
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();
}
 
Example 4
Project: unitimes   File: SessionDatesSelector.java   View source code 6 votes vote down vote up
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());
		}
	});
}
 
Example 5
Project: unitimes   File: UserAuthentication.java   View source code 6 votes vote down vote up
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);
		}
	});
}
 
Example 6
Project: WebConsole   File: WebConsole.java   View source code 6 votes vote down vote up
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();  
      }  
    });
		
	}
 
Example 7
Project: cuba   File: CubaFileUploadProgressWindow.java   View source code 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 8
Project: cuba   File: CubaTreeWidget.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 9
Project: cuba   File: Tools.java   View source code 6 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()) {
        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");
                        }
                    }
                }
            });
        }
    }
}
 
Example 10
Project: cuba   File: ComponentRenderer.java   View source code 6 votes vote down vote up
@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();
    }
}
 
Example 11
Project: cuba   File: CubaMaskedFieldWidget.java   View source code 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 12
Project: Wiab.pro   File: UndercurrentHarness.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 13
Project: x-cure-chat   File: MessagesStackNavigator.java   View source code 6 votes vote down vote up
/**
 * 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 );
				}
			}
		});
	}
}
 
Example 14
Project: x-cure-chat   File: ForumBodyWidget.java   View source code 6 votes vote down vote up
@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;
	}
}
 
Example 15
Project: firefly   File: TileDrawer.java   View source code 6 votes vote down vote up
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);
        }
    }
}
 
Example 16
Project: x-cure-chat   File: CopyUrlInfoPanel.java   View source code 6 votes vote down vote up
/**
 * 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();
		}
	});
}
 
Example 17
Project: x-cure-chat   File: SendChatMessagePanelUI.java   View source code 6 votes vote down vote up
@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();
}
 
Example 18
Project: VaadinSpringShiroMongoDB   File: ResetButtonForTextFieldConnector.java   View source code 6 votes vote down vote up
@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);
}
 
Example 19
Project: teiid-webui   File: ExtendedTextBox.java   View source code 6 votes vote down vote up
@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
	}
}
 
Example 20
Project: teiid-webui   File: ExtendedTextArea.java   View source code 6 votes vote down vote up
@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
	}
}
 
Example 21
Project: gwt-material   File: AbstractSideNav.java   View source code 6 votes vote down vote up
@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);
        }
    }
}
 
Example 22
Project: firefly   File: CatddEnhancedPanel.java   View source code 6 votes vote down vote up
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;
}
 
Example 23
Project: proarc   File: DigitalObjectChildrenEditor.java   View source code 6 votes vote down vote up
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 24
Project: ontosoft   File: CategoryPieChart.java   View source code 6 votes vote down vote up
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);
        }
      } 
    });
  }
}
 
Example 25
Project: blogwt   File: GalleryPlugin.java   View source code 6 votes vote down vote up
@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"));
			}
		}
	});
}
 
Example 26
Project: switchyard   File: MetricsPresenter.java   View source code 6 votes vote down vote up
@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();
                    }
                }
            });
        }
    });
}
 
Example 27
Project: blogwt   File: FormPlugin.java   View source code 6 votes vote down vote up
@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"));
		}
	});
}
 
Example 28
Project: firefly   File: GwtUtil.java   View source code 6 votes vote down vote up
/**
 *
 * @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");
    }
}
 
Example 29
Project: che   File: CommandManagerImpl.java   View source code 6 votes vote down vote up
@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));
          });
}
 
Example 30
Project: gerrit   File: DiffScreen.java   View source code 6 votes vote down vote up
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);
  }
}
 
Example 31
Project: gerrit   File: DiffScreen.java   View source code 6 votes vote down vote up
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);
                  }
                });
      }
    }
  };
}
 
Example 32
Project: che   File: ProcessesPanelPresenter.java   View source code 6 votes vote down vote up
@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);
            }
          });
}
 
Example 33
Project: che   File: ProcessesPanelViewImpl.java   View source code 6 votes vote down vote up
@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);
            }
          });
}
 
Example 34
Project: che   File: Tree.java   View source code 6 votes vote down vote up
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);
              }
            }
          });
}
 
Example 35
Project: che   File: Tree.java   View source code 6 votes vote down vote up
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);
              }
            });
  }
}
 
Example 36
Project: che   File: QuickOpenViewImpl.java   View source code 6 votes vote down vote up
@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);
            }
          });
}
 
Example 37
Project: empiria.player   File: WindowToStickieScroller.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 38
Project: empiria.player   File: DeliveryEngineGWTTestCase.java   View source code 5 votes vote down vote up
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++;
    }
}
 
Example 39
Project: unitimes   File: Client.java   View source code 5 votes vote down vote up
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();
		}
	});
}
 
Example 40
Project: unitimes   File: Client.java   View source code 5 votes vote down vote up
public void onModuleLoadDeferred() {
	// register triggers
	GWT.runAsync(new RunAsyncCallback() {
		@Override
		public void onSuccess() {
			for (Triggers t: Triggers.values())
				t.register();
			callGwtOnLoadIfExists();
		}
		@Override
		public void onFailure(Throwable reason) {
		}
	});
	
	// load page
	if (RootPanel.get("UniTimeGWT:Body") != null) {
		LoadingWidget.getInstance().show(MESSAGES.waitLoadingPage());
		Scheduler.get().scheduleDeferred(new ScheduledCommand() {
			@Override
			public void execute() {
				initPageAsync(Window.Location.getParameter("page"));
			}
		});
	}
	
	// load components
	for (final Components c: Components.values()) {
		final RootPanel p = RootPanel.get(c.id());
		if (p != null) {
			Scheduler.get().scheduleDeferred(new ScheduledCommand() {
				@Override
				public void execute() {
					initComponentAsync(p, c);
				}
			});
		}
		if (p == null && c.isMultiple()) {
			NodeList<Element> x = getElementsByName(c.id());
			if (x != null && x.getLength() > 0)
				for (int i = 0; i < x.getLength(); i++) {
					Element e = x.getItem(i);
					e.setId(DOM.createUniqueId());
					final RootPanel q = RootPanel.get(e.getId());
					Scheduler.get().scheduleDeferred(new ScheduledCommand() {
						@Override
						public void execute() {
							initComponentAsync(q, c);
						}
					});
				}
		}
	}
	
	Window.addWindowClosingHandler(new Window.ClosingHandler() {
		@Override
		public void onWindowClosing(Window.ClosingEvent event) {
			if (isLoadingDisplayed() || LoadingWidget.getInstance().isShowing()) return;
			LoadingWidget.showLoading(MESSAGES.waitPlease());
			iPageLoadingTimer = new Timer() {
				@Override
				public void run() {
					RPC.execute(new IsSessionBusyRpcRequest(), new AsyncCallback<GwtRpcResponseBoolean>() {
						@Override
						public void onFailure(Throwable caught) {
							LoadingWidget.hideLoading();
						}
						@Override
						public void onSuccess(GwtRpcResponseBoolean result) {
							if (result.getValue()) {
								iPageLoadingTimer.schedule(500);
							} else {
								LoadingWidget.hideLoading();
							}
						}
					});
				}
			};
			iPageLoadingTimer.schedule(500);
		}
	});
}