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

The following are top voted examples for showing how to use com.google.gwt.core.client.Scheduler.ScheduledCommand. 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: unitime   File: TimeSelector.java   View source code 8 votes vote down vote up
private TimeMenuItem(final int slot) {
	super(slot2time(slot, iStart == null || iStart.getValue() == null ? 0 : slot - iStart.getValue()),
		true,
		new ScheduledCommand() {
			@Override
			public void execute() {
				hideSuggestions();
				setValue(slot, true);
				iLastSelected = iText.getText();
				fireSuggestionEvent(slot);
			}
		}
	);
	setStyleName("item");
	getElement().setAttribute("whiteSpace", "nowrap");
	iSlot = slot;
}
 
Example 2
Project: empiria.player   File: EntriesController.java   View source code 6 votes vote down vote up
public void loadEntry(String password, final int index, final boolean playSound) {
    final String path = dictionaryFilenameProvider.getFilePathForIndex(index);

    scheduler.scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            try {
                FileRequestCallback fileRequestCallback = dictionaryModuleFactory.createFileRequestCallback(index, playSound);

                FileRequest fileRequest = fileRequestProvider.get();
                fileRequest.setUrl(path);
                fileRequest.send(null, fileRequestCallback);
            } catch (FileRequestException exception) {
                logger.error(exception);
            }
        }
    });
}
 
Example 3
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 4
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 5
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 6
Project: unitimes   File: TimeSelector.java   View source code 6 votes vote down vote up
private TimeMenuItem(final int slot) {
	super(slot2time(slot, iStart == null || iStart.getValue() == null ? 0 : slot - iStart.getValue()),
		true,
		new ScheduledCommand() {
			@Override
			public void execute() {
				hideSuggestions();
				setValue(slot, true);
				iLastSelected = iText.getText();
				fireSuggestionEvent(slot);
			}
		}
	);
	setStyleName("item");
	getElement().setAttribute("whiteSpace", "nowrap");
	iSlot = slot;
}
 
Example 7
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 8
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 9
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 10
Project: gwt-oauth2   File: Auth.java   View source code 6 votes vote down vote up
/**
 * Request an access token from an OAuth 2.0 provider.
 *
 * <p>
 * If it can be determined that the user has already granted access, and the
 * token has not yet expired, and that the token will not expire soon, the
 * existing token will be passed to the callback.
 * </p>
 *
 * <p>
 * Otherwise, a popup window will be displayed which may prompt the user to
 * grant access. If the user has already granted access the popup will
 * immediately close and the token will be passed to the callback. If access
 * hasn't been granted, the user will be prompted, and when they grant, the
 * token will be passed to the callback.
 * </p>
 *
 * @param req Request for authentication.
 * @param callback Callback to pass the token to when access has been granted.
 */
public void login(AuthRequest req, final Callback<String, Throwable> callback) {
  lastRequest = req;
  lastCallback = callback;

  String authUrl = req.toUrl(urlCodex) + "&redirect_uri=" + urlCodex.encode(oauthWindowUrl);

  // Try to look up the token we have stored.
  final TokenInfo info = getToken(req);
  if (info == null || info.expires == null || expiringSoon(info)) {
    // Token wasn't found, or doesn't have an expiration, or is expired or
    // expiring soon. Requesting access will refresh the token.
    doLogin(authUrl, callback);
  } else {
    // Token was found and is good, immediately execute the callback with the
    // access token.

    scheduler.scheduleDeferred(new ScheduledCommand() {
      @Override
      public void execute() {
        callback.onSuccess(info.accessToken);
      }
    });
  }
}
 
Example 11
Project: gwt-oauth2   File: AuthTest.java   View source code 6 votes vote down vote up
/**
 * When the token is found in cookies and will not expire soon, neither popup
 * nor iframe is used, and the token is immediately passed to the callback.
 */
public void testLogin_notExpiringSoon() {
  AuthRequest req = new AuthRequest("url", "clientId").withScopes("scope");

  // Storing a token that does not expire soon (in exactly 10 minutes)
  TokenInfo info = new TokenInfo();
  info.accessToken = "notExpiringSoon";
  info.expires = String.valueOf(MockClock.now + 10 * 60 * 1000);
  auth.setToken(req, info);

  MockCallback callback = new MockCallback();
  auth.login(req, callback);

  // A deferred command will have been scheduled. Execute it.
  List<ScheduledCommand> deferred = ((StubScheduler) auth.scheduler).getScheduledCommands();
  assertEquals(1, deferred.size());
  deferred.get(0).execute();

  // The iframe was used and the popup wasn't.
  assertFalse(auth.loggedInViaPopup);

  // onSuccess() was called and onFailure() wasn't.
  assertEquals("notExpiringSoon", callback.token);
  assertNull(callback.failure);
}
 
Example 12
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 13
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 14
Project: x-cure-chat   File: RoomUserAccessDialogUI.java   View source code 6 votes vote down vote up
/**
 * Enable/Disable dialog buttons and other elements
 */
private void setEnabledElements(final boolean enableLeft, final boolean enableRight, final boolean other ){
	Scheduler.get().scheduleDeferred( new ScheduledCommand(){
		public void execute(){
			setLeftEnabled( enableLeft );
			setRightEnabled( enableRight );
			
			//The other room access dialog elements
			isReadCheckBox.setEnabled( other );
			isWriteCheckBox.setEnabled( other && ( ! isSystemCheckBox.getValue() ) );
			isSystemCheckBox.setEnabled( other && ( ! isWriteCheckBox.getValue() ) );					
			//Enable the read all check box only if it is a system property
			isReadAllCheckBox.setEnabled( other && isSystemCheckBox.getValue() );
			//Enable the selection list only if the read all is checked  
			readAllDurationListBox.setEnabled( other && isReadAllCheckBox.getValue() );
		}
	});
}
 
Example 15
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 16
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 17
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 18
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 19
Project: gwt-oauth   File: Auth.java   View source code 6 votes vote down vote up
/**
 * Request an access token from an OAuth 2.0 provider.
 *
 * <p>
 * If it can be determined that the user has already granted access, and the
 * token has not yet expired, and that the token will not expire soon, the
 * existing token will be passed to the callback.
 * </p>
 *
 * <p>
 * Otherwise, a popup window will be displayed which may prompt the user to
 * grant access. If the user has already granted access the popup will
 * immediately close and the token will be passed to the callback. If access
 * hasn't been granted, the user will be prompted, and when they grant, the
 * token will be passed to the callback.
 * </p>
 *
 * @param req Request for authentication.
 * @param callback Callback to pass the token to when access has been granted.
 */
public void login(AuthRequest req, final Callback<String, Throwable> callback) {
  lastRequest = req;
  lastCallback = callback;

  String authUrl = req.toUrl(urlCodex) + "&redirect_uri=" + urlCodex.encode(oauthWindowUrl);

  // Try to look up the token we have stored.
  final TokenInfo info = getToken(req);
  if (info == null || info.expires == null || expiringSoon(info)) {
    // Token wasn't found, or doesn't have an expiration, or is expired or
    // expiring soon. Requesting access will refresh the token.
    doLogin(authUrl, callback);
  } else {
    // Token was found and is good, immediately execute the callback with the
    // access token.

    scheduler.scheduleDeferred(new ScheduledCommand() {
      @Override
      public void execute() {
        callback.onSuccess(info.accessToken);
      }
    });
  }
}
 
Example 20
Project: forplay   File: HtmlGame.java   View source code 6 votes vote down vote up
@Override
public final void onModuleLoad() {
  GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
    @Override
    public void onUncaughtException(Throwable e) {
      ForPlay.log().error("Uncaught Exception: ", e);
    }
  });

  // Need to do everything else in a deferred command, so that
  // the uncaught exception handler has taken effect
  Scheduler.get().scheduleDeferred(new ScheduledCommand() {

    @Override
    public void execute() {
      start();
    }

  });
}
 
Example 21
Project: che   File: AnimationUtils.java   View source code 6 votes vote down vote up
/** 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);
            }
          });
}
 
Example 22
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 23
Project: proarc   File: ImportBatchItemEditor.java   View source code 6 votes vote down vote up
private void selectNextChildAndFocus(Record record) {
    int nextSelection = getNextSelection(record);
    if (nextSelection < 0) {
        return ;
    }
    final HandlerRegistration[] editorLoadHandler = new HandlerRegistration[1];
    editorLoadHandler[0] = childEditor.addEditorLoadHandler(new EditorLoadHandler() {

        @Override
        public void onEditorLoad(EditorLoadEvent evt) {
            editorLoadHandler[0].removeHandler();
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    childEditor.focus();
                }
            });
        }
    });
    batchItemGrid.selectSingleRecord(nextSelection);
    batchItemGrid.scrollToRow(nextSelection);
}
 
Example 24
Project: OpenTripPlanner-client-gwt   File: OpenLayersPlannerMapWidget.java   View source code 6 votes vote down vote up
@Override
public void setBounds(Wgs84BoundsBean aBounds) {
	bounds = aBounds;
	Scheduler.get().scheduleDeferred(new ScheduledCommand() {
		@Override
		public void execute() {
			map.updateSize();
			Bounds extent = convertBounds(bounds);
			map.setMaxExtent(extent);
			map.setRestrictedExtent(extent);
			map.zoomToExtent(extent);
			// Zoom a bit inside as fitting bounds will be too large
			map.setCenter(map.getCenter(), map.getZoom() + 1);
		}
	});
}
 
Example 25
Project: vaadin-scrollable-panel   File: ScrollablePanelWidget.java   View source code 6 votes vote down vote up
private void startTrigger() {
	if (this.executor == null) {
		this.executor = new VLazyExecutor(this.scrollEventDelayMillis, new ScheduledCommand() {
			@Override
			public void execute() {
				if (ScrollablePanelWidget.this.timedHandler != null
				        && ScrollablePanelWidget.this.currentScrollingPos != null
				        && (ScrollablePanelWidget.this.lastSentScrollPos == null || !ScrollablePanelWidget.this.currentScrollingPos
				                .equals(ScrollablePanelWidget.this.lastSentScrollPos))) {
					ScrollablePanelWidget.this.timedHandler.onScroll(ScrollablePanelWidget.this.currentScrollingPos);
					ScrollablePanelWidget.this.lastSentScrollPos = ScrollablePanelWidget.this.currentScrollingPos;
				}
			}
		});
	}
	this.executor.trigger();
}
 
Example 26
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 27
Project: gerrit   File: OnEditEnabler.java   View source code 6 votes vote down vote up
private void onTextBoxBase(TextBoxBase tb) {
  // The text appears to not get updated until the handlers complete.
  Scheduler.get()
      .scheduleDeferred(
          new ScheduledCommand() {
            @Override
            public void execute() {
              String orig = strings.get(tb);
              if (orig == null) {
                orig = "";
              }
              if (!orig.equals(tb.getText().trim())) {
                widget.setEnabled(true);
              }
            }
          });
}
 
Example 28
Project: umlet   File: MenuPopup.java   View source code 6 votes vote down vote up
public MenuPopup(List<MenuPopupItem> items) {
	super(false, Type.MENU);
	MenuBar popupMenuBar = new MenuBar(true);

	for (final MenuPopupItem item : items) {
		popupMenuBar.addItem(new MenuItem(item.getText(), true, new ScheduledCommand() {
			@Override
			public void execute() {
				item.execute();
				hide();
			}
		}));
	}
	popupMenuBar.setVisible(true);
	add(popupMenuBar);
}
 
Example 29
Project: unitime   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 30
Project: unitime   File: UniTimeConfirmationDialog.java   View source code 6 votes vote down vote up
@Override
public void center() {
	super.center();
	if (iMessage != null && !iMessage.isEmpty())
		AriaStatus.getInstance().setText(ARIA.dialogOpened(getText()) + " " + iMessage + (iNo == null ? "" : " " + ARIA.confirmationEnterToAcceptEscapeToReject()));
	Scheduler.get().scheduleDeferred(new ScheduledCommand() {
		@Override
		public void execute() {
			if (iTextBox != null) {
				iTextBox.setFocus(true);
				iTextBox.selectAll();
			} else {
				iYes.setFocus(true);
			}
		}
	});
}
 
Example 31
Project: unitime   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 32
Project: unitime   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 33
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 34
Project: blogwt   File: CachedIncludePlugin.java   View source code 6 votes vote down vote up
@Override
protected void getContent (final String src, final String id,
		final List<String> lines, final Map<String, String> params)
		throws IOException {
	if (src != null && src.length() > 0) {
		if (ensureCache().containsKey(src)) {
			Scheduler.get().scheduleDeferred(new ScheduledCommand() {

				@Override
				public void execute () {
					CachedIncludePlugin.super.gotContent(null,
							ensureCache().get(src), src, id, lines, params);
				}
			});
		} else {
			super.getContent(src, id, lines, params);
		}
	}
}
 
Example 35
Project: platypus-js   File: ModelGrid.java   View source code 6 votes vote down vote up
protected void enqueueServiceColumnsRedraw() {
	serviceColumnsRedrawQueued = true;
	Scheduler.get().scheduleDeferred(new ScheduledCommand() {

		@Override
		public void execute() {
			if (serviceColumnsRedrawQueued) {
				serviceColumnsRedrawQueued = false;
				if (getDataColumnCount() > 0) {
					for (int i = 0; i < getDataColumnCount(); i++) {
						ModelColumn col = (ModelColumn) getDataColumn(i);
						if (col instanceof UsualServiceColumn) {
							if (i < frozenColumns) {
								frozenLeft.redrawAllRowsInColumn(i, dataProvider);
								scrollableLeft.redrawAllRowsInColumn(i, dataProvider);
							} else {
								frozenRight.redrawAllRowsInColumn(i - frozenColumns, dataProvider);
								scrollableRight.redrawAllRowsInColumn(i - frozenColumns, dataProvider);
							}
						}
					}
				}
			}
		}
	});
}
 
Example 36
Project: platypus-js   File: JsTree.java   View source code 6 votes vote down vote up
protected void enqueueChanges() {
	changesQueued = new ScheduledCommand() {

           @Override
           public void execute() {
               if (changesQueued == this) {
                   changesQueued = null;
                   if (data != null) {
                       List<JavaScriptObject> items = new JsArrayList(data);
                       for (int i = 0; i < items.size(); i++) {
                           JavaScriptObject item = items.get(i);
                           changed(item);
                       }
                   }
               }
           }
       };
	Scheduler.get().scheduleDeferred(changesQueued);
}
 
Example 37
Project: platypus-js   File: JsTree.java   View source code 6 votes vote down vote up
private void enqueueReadd() {
	readdQueued = new ScheduledCommand() {

           @Override
           public void execute() {
               if (readdQueued == this) {
                   readdQueued = null;
                   if (boundToDataElements != null) {
                       boundToDataElements.removeHandler();
                       boundToDataElements = null;
                   }
                   if (data != null) {
                       boundToDataElements = Utils.listenElements(data, new Utils.OnChangeHandler() {

                           @Override
                           public void onChange(JavaScriptObject anEvent) {
                               enqueueChanges();
                           }
                       });
                   }
                   everythingChanged();
               }
           }
       };
	Scheduler.get().scheduleDeferred(readdQueued);
}
 
Example 38
Project: platypus-js   File: ModelCombo.java   View source code 6 votes vote down vote up
private void enqueueListReadd() {
    readdQueued = true;
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            if (readdQueued) {
                readdQueued = false;
                if (boundToListElements != null) {
                    boundToListElements.removeHandler();
                    boundToListElements = null;
                }
                if (displayList != null) {
                    boundToListElements = Utils.listenElements(displayList, new Utils.OnChangeHandler() {

                        @Override
                        public void onChange(JavaScriptObject anEvent) {
                            enqueueListChanges();
                        }
                    });
                }
                rebindList();
            }
        }
    });
}
 
Example 39
Project: ahome-touch   File: Component.java   View source code 6 votes vote down vote up
public void hide() {

		hideRendered();
		if (!isRendered()) {
			initHidden = true;
			this.addEventHandler(TouchAttribute.RENDERED_CHANGE.getValue(), new Function() {

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

						public void execute() {
							hideRendered();
						}
					});
				}
			});
		}

	}
 
Example 40
Project: ahome-touch   File: Component.java   View source code 6 votes vote down vote up
/**
 * Sets the value of docked.
 * 
 * @param dock
 */
public void setDocked(Dock dock) {
	setDocked(dock.getValue());
	/**
	 * TODO This is a work around for a Sencha Bug. Documented as issue #1 in github.
	 */
	if (dock == Dock.BOTTOM) {
		Scheduler.get().scheduleDeferred(new ScheduledCommand() {

			public void execute() {
				com.google.gwt.dom.client.Element parent = getElement().getParentElement();
				Element child = getElement();
				getElement().removeFromParent();
				parent.appendChild(child);
			}
		});
	}
}