List of usage examples for com.google.gwt.user.client Timer schedule
public synchronized void schedule(int delayMs)
From source file:com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing.java
License:sencha.com license
@Override public void cancelEditing() { ignoreScroll = false;/*from w w w . j a v a 2s . co m*/ if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest("cancelEditing active is " + (activeCell == null ? "null" : "no null")); } if (activeCell != null) { Element elem = getEditableGrid().getView().getCell(activeCell.getRow(), activeCell.getCol()); elem.getFirstChildElement().getStyle().setVisibility(Style.Visibility.VISIBLE); ColumnConfig<M, ?> c = columnModel.getColumn(activeCell.getCol()); IsField<?> field = getEditor(c); field.clear(); removeEditor(activeCell, field); final GridCell gc = activeCell; activeCell = null; fireEvent(new CancelEditEvent<M>(gc)); if (focusOnComplete) { focusOnComplete = false; focusGrid(); // EXTGWT-2856 focus of grid not working after canceling an edit in IE. // something is stealing focus and the only fix so far is to run focus call in a timer. deferred does not fix. // need to find why focus is not staying on first call. if (GXT.isIE()) { Timer t = new Timer() { @Override public void run() { focusGrid(); } }; t.schedule(100); } } } stopMonitoring(); }
From source file:com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing.java
License:sencha.com license
@SuppressWarnings("unchecked") protected <N, O> void doStartEditing(final GridCell cell) { if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest("doStartEditing"); }/* www . ja va 2s. co m*/ if (getEditableGrid() != null && getEditableGrid().isAttached() && cell != null) { M value = getEditableGrid().getStore().get(cell.getRow()); ColumnConfig<M, N> c = columnModel.getColumn(cell.getCol()); if (c != null && value != null) { Converter<N, O> converter = getConverter(c); ValueProvider<? super M, N> v = c.getValueProvider(); N colValue = getEditableGrid().getStore().hasRecord(value) ? getEditableGrid().getStore().getRecord(value).getValue(v) : v.getValue(value); O convertedValue; if (converter != null) { convertedValue = converter.convertModelValue(colValue); } else { convertedValue = (O) colValue; } final IsField<O> field = getEditor(c); if (field != null) { if (field instanceof HasErrorHandler) { ((HasErrorHandler) field).setErrorSupport(null); } activeCell = cell; if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest("doStartEditing convertedValue: " + convertedValue); } field.setValue(convertedValue); if (field instanceof TriggerField<?>) { ((TriggerField<?>) field).setMonitorTab(false); } if (field instanceof CheckBox) { ((CheckBox) field).setBorders(true); } Widget w = field.asWidget(); getEditableGrid().getView().getEditorParent().appendChild(w.getElement()); ComponentHelper.setParent(getEditableGrid(), w); ComponentHelper.doAttach(w); w.setPixelSize(c.getWidth(), Integer.MIN_VALUE); w.getElement().<XElement>cast().makePositionable(true); Element row = getEditableGrid().getView().getRow(cell.getRow()); int left = 0; for (int i = 0; i < cell.getCol(); i++) { if (!columnModel.isHidden(i)) { left += columnModel.getColumnWidth(i); } } w.getElement().<XElement>cast().setLeftTop(left, row.getAbsoluteTop() - getEditableGrid().getView().getBody().getAbsoluteTop()); field.asWidget().setVisible(true); startMonitoring(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest("doStartEditing scheduleDeferred doFocus "); } // browsers select all when tabbing into a input and put cursor at location when clicking into an input // with inline editing, the field is not visible at time of click so we select all. we ignore // field.isSelectOnFocus as this only applies when clicking into a field if (field instanceof ValueBaseField<?>) { ValueBaseField<?> vf = (ValueBaseField<?>) field; vf.selectAll(); } // EXTGWT-2856 calling doFocus before selectAll is causing blur to fire which ends the edit immediately // after it starts doFocus(field); ignoreScroll = false; fieldRegistration.removeHandler(); fieldRegistration.add(field.addValueChangeHandler(new ValueChangeHandler<O>() { @Override public void onValueChange(ValueChangeEvent<O> event) { if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest("doStartEditing onValueChanged"); } // if enter key cause value change we want to ignore the next // enter key otherwise // new edit will start by onEnter ignoreNextEnter = true; Timer t = new Timer() { @Override public void run() { ignoreNextEnter = false; } }; completeEditing(); t.schedule(100); } })); fieldRegistration.add(field.addBlurHandler(new BlurHandler() { @Override public void onBlur(final BlurEvent event) { if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest("doStartEditing onBlur"); } ignoreNextEnter = true; Timer t = new Timer() { @Override public void run() { ignoreNextEnter = false; } }; if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest("doStartEditing onBlur call cancelEditing"); } cancelEditing(); t.schedule(100); } })); fireEvent(new StartEditEvent<M>(cell)); } }); } } } }
From source file:com.sencha.gxt.widget.core.client.grid.Grid.java
License:sencha.com license
@Override protected void onAfterFirstAttach() { super.onAfterFirstAttach(); if (lazyRowRender > 0) { Timer t = new Timer() { @Override//w ww. j ava2s. c o m public void run() { afterRenderView(); } }; t.schedule(lazyRowRender); } else { afterRenderView(); } }
From source file:com.sencha.gxt.widget.core.client.grid.GridView.java
License:sencha.com license
/** * Handles an update to data in the store. * * @param store the store//from w w w. j a v a 2 s. c o m * @param models the updated data */ protected void onUpdate(final ListStore<M> store, final List<M> models) { if (!deferUpdates) { for (M m : models) { refreshRow(store.indexOf(m)); } } else { Timer t = new Timer() { @Override public void run() { for (M m : models) { refreshRow(store.indexOf(m)); grid.getSelectionModel().onUpdate(m); } } }; t.schedule(deferUpdateDelay); } }
From source file:com.sencha.gxt.widget.core.client.info.Info.java
License:sencha.com license
protected void afterShow() { Timer t = new Timer() { public void run() { hide();/*from w w w . j ava 2s.c o m*/ } }; t.schedule(config.getDisplay()); }
From source file:com.sharad.quizbowl.ui.client.QuizbowlUI.java
License:Open Source License
public void onModuleLoad() { JsonpRequestBuilder dataGrabber = new JsonpRequestBuilder(); dataGrabber.setTimeout(30000);/*from www .j a v a 2 s.c o m*/ dataGrabber.requestObject(SERVER_URL + "/data?alt=json-in-script", new AsyncCallback<DataPackage>() { @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(DataPackage result) { YEARS = result.getYears(); TOURNAMENTS = result.getTournaments(); DIFFICULTIES = result.getDifficulties(); CATEGORIES = result.getCategories(); NUM_QUESTIONS = result.getNumQuestions(); NUM_USERS = result.getNumUsers(); NUM_SCORES = result.getNumScores(); for (int i = 0; i < CATEGORIES.length(); i++) { CATEGORIES_LIST.add(CATEGORIES.get(i)); } final HomeWidget home = new HomeWidget(YEARS, TOURNAMENTS, DIFFICULTIES, CATEGORIES); RootLayoutPanel.get().add(home); Timer timer = new Timer() { @Override public void run() { home.search.searchBox.setFocus(true); } }; timer.schedule(400); } }); }
From source file:com.smartgwt.extensions.htmleditor.client.HTMLEditor.java
License:Open Source License
/** * Sets the HTML currently contained in the editor * /* w ww . j a va 2 s . c om*/ * @param html the HTML currently contained in the editor */ public void setHTML(String htmlText) { savedHTML = htmlText; if (editing) jsniSetText(elementID, htmlText); else { // need to convert all relative references to point to download servlet String newText = Util.convertToAbsolute(htmlText, "/thinkspace/download" + resPath); textArea.setContents("<div id=\"" + elementID + "\">" + newText + "</div>"); textArea.setCanFocus(true); final HTMLEditor me = this; Timer t = new Timer() { public void run() { setButtonClick(me, elementID); } }; t.schedule(100); } }
From source file:com.smartgwt.extensions.htmleditor.client.HTMLEditor.java
License:Open Source License
public void edit() { textArea.setContents("<form id=\"form-" + elementID + "\"><textarea id=\"" + elementID + "\" wrap=\"virtual\">" + savedHTML + "</textarea></form>"); textArea.hide();// ww w . ja v a 2 s . c om final HTMLEditor editor = this; Timer timer = new Timer() { public void run() { initEditor(editor, elementID, cssWidth, cssHeight, resPath, stylesPath, toolBar); editing = true; textArea.show(); } }; timer.schedule(100); }
From source file:com.softlink.finance.client.view.desktop.DesktopTopPanelView.java
License:Apache License
public DesktopTopPanelView() { initWidget(binder.createAndBindUi(this)); desktopSearchTextBoxView.setListener(new DesktopSearchTextBoxView.Listener() { @Override/*from w w w .ja v a 2 s . c o m*/ public void hideSearchTextBox() { // TODO Auto-generated method stub searchtxb.setWidget(blankPanel); Timer timer = new Timer() { public void run() { searchOn = false; } }; timer.schedule(500); } }); searchtxb.add(desktopSearchTextBoxView); searchtxb.add(blankPanel); searchtxb.setWidget(blankPanel); setUpMenu(); }
From source file:com.square.client.gwt.client.presenter.personne.PersonneActionsPresenter.java
License:Open Source License
@Override public void onBind() { view.getBtnAfficherActions().addClickHandler(new ClickHandler() { @Override/*from w w w .j a va 2 s . c om*/ public void onClick(ClickEvent event) { // Suppression du filtre de recherche d'actions partir d'une opportunit view.masquerFiltre(); initListeActions(null, null, null); } }); addEventHandlerToLocalBus(ActionZoomOverEvent.TYPE, new ActionZoomOverEventHandler() { @Override public void onMouseOver(final ActionZoomOverEvent event) { if (!event.isOpen()) { // on lance le timer pour afficher l'info bulle si bloc annul ou termin if (event.getActionZoomOver().getViewAction().isAnnuleOuTermine()) { final Timer timerAffichageInfoBulle = new Timer() { @Override public void run() { actionServiceRpc.rechercherActionParIdentifiant( event.getActionZoomOver().getIdAction(), new AsyncCallback<ActionModel>() { @Override public void onFailure(Throwable caught) { view.onRpcServiceFailure(new ErrorPopupConfiguration(caught)); } @Override public void onSuccess(final ActionModel result) { view.afficherInfoBulleAction(result, event.getActionZoomOver().getViewAction()); } }); } }; timerAffichageInfoBulle .schedule(PersonneActionsPresenterConstants.DELAI_AFFICHAGE_INFOBULLE); mapTimersAffichageInfoBulle.put(event.getActionZoomOver().getIdAction(), timerAffichageInfoBulle); } } for (ActionZoomModel actionZoom : mapActionsZoom.get(event.getActionZoomOver().getIndexBloc())) { if (!event.getActionZoomOver().getIdAction().equals(actionZoom.getIdAction())) { // on verifie si l'action parcourue est la mere ou un enfant de l'action survole final boolean actionFils = event.getActionZoomOver().getIdAction() .equals(actionZoom.getIdActionMere()); final boolean actionMere = event.getActionZoomOver().getIdActionMere() != null && event.getActionZoomOver().getIdActionMere().equals(actionZoom.getIdAction()); if (!actionFils && !actionMere) { // si ce n'est ni l'un ni l'autre, on ajoute le style pastel actionZoom.getViewAction().appliquerStylePastel(true); } } } } }); addEventHandlerToLocalBus(ActionZoomOutEvent.TYPE, new ActionZoomOutEventHandler() { @Override public void onMouseOut(ActionZoomOutEvent event) { if (!event.isOpen()) { // On masque l'info bulle du bloc annul ou termin, ou on dsactive le timer if (event.getActionZoomOut().getViewAction().isAnnuleOuTermine()) { if (mapTimersAffichageInfoBulle.get(event.getActionZoomOut().getIdAction()) != null) { final Timer timerAffichageInfoBulle = mapTimersAffichageInfoBulle .get(event.getActionZoomOut().getIdAction()); timerAffichageInfoBulle.cancel(); mapTimersAffichageInfoBulle.remove(timerAffichageInfoBulle); } view.masquerInfoBulleAction(); } } for (ActionZoomModel actionZoom : mapActionsZoom.get(event.getActionZoomOut().getIndexBloc())) { // on informe les vues d'enlever le style pastel actionZoom.getViewAction().appliquerStylePastel(false); } } }); }