public void initPageAsync(final String page) { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { init(page); LoadingWidget.getInstance().hide(); } public void onFailure(Throwable reason) { Label error = new Label(MESSAGES.failedToLoadPage(reason.getMessage())); error.setStyleName("unitime-ErrorMessage"); RootPanel loading = RootPanel.get("UniTimeGWT:Loading"); if (loading != null) loading.setVisible(false); RootPanel.get("UniTimeGWT:Body").add(error); LoadingWidget.getInstance().hide(); UniTimeNotifications.error(MESSAGES.failedToLoadPage(reason.getMessage()), reason); } }); }
private void init() { logger.info("Init..."); addMetaElements(); // Disable Back Button setupHistory(); setupBootbox(); GWT.runAsync(new RunAsyncCallback() { @Override public void onFailure(Throwable reason) { logger.info("Error on Async!"); } @Override public void onSuccess() { createViews(); removeLoadingImage(); // Example calling JavaScript with JSNI - old style // alert("Lofi Old Style..."); } }); }
String[] getClassesToImport() { return new String[] { com.mvp4g.client.history.PlaceService.class.getName(), GWT.class.getName(), com.google.gwt.user.client.History.class.getName(), ServiceDefTarget.class.getName(), PresenterInterface.class.getName(), EventBus.class.getName(), Mvp4gException.class.getName(), HistoryConverter.class.getName(), Mvp4gEventPasser.class.getName(), Mvp4gModule.class.getName(), GinModules.class.getName(), Ginjector.class.getName(), BaseEventBus.class.getName(), EventFilter.class.getName(), EventHandlerInterface.class.getName(), List.class.getName(), NavigationEventCommand.class.getName(), NavigationConfirmationInterface.class.getName(), RunAsyncCallback.class.getName(), Mvp4gRunAsync.class.getName(), Command.class.getName(), HistoryProxyProvider.class.getName(), DefaultHistoryProxy.class.getName() }; }
protected void loadTests(final boolean forReal) { GWT.runAsync(JUnit4Runner.class, new RunAsyncCallback() { @Override public void onSuccess() { if (forReal) { displayTests(); runTests(); } } @Override public void onFailure(final Throwable reason) { X_Log.error(JUnitUi.class, "RunAsync Failed", reason); } }); }
protected void loadTests(final boolean forReal) { GWT.runAsync(JUnit4Executor.class, new RunAsyncCallback() { @Override public void onSuccess() { if (forReal) { displayTests(); runTests(); } } @Override public void onFailure(final Throwable reason) { } }); }
protected void addAnnotationTests() { GWT.runAsync(AnnotationTests.class, new RunAsyncCallback() { @Override public void onSuccess() { magicClass(AnnotationTests.class); try { addTests(AnnotationTests.class); } catch (final Throwable e) { print("Error adding AnnotationTests", e); } } @Override public void onFailure(final Throwable reason) { print("Error loading AnnotationTests", reason); } }); }
protected void addArrayTests() { GWT.runAsync(ArrayTests.class, new RunAsyncCallback() { @Override public void onSuccess() { magicClass(ArrayTests.class); try { addTests(ArrayTests.class); } catch (final Throwable e) { print("Error adding ArrayTests", e); } } @Override public void onFailure(final Throwable reason) { print("Error loading ArrayTests", reason); } }); }
protected void addConstructorTests() { GWT.runAsync(ConstructorTests.class, new RunAsyncCallback() { @Override public void onSuccess() { magicClass(ConstructorTests.class); try { addTests(ConstructorTests.class); } catch (final Throwable e) { print("Error adding ConstructorTests", e); } } @Override public void onFailure(final Throwable reason) { print("Error loading ConstructorTests", reason); } }); }
protected void addFieldTests() { GWT.runAsync(FieldTests.class, new RunAsyncCallback() { @Override public void onSuccess() { magicClass(FieldTests.class); try { addTests(FieldTests.class); } catch (final Throwable e) { print("Error adding FieldTests", e); } } @Override public void onFailure(final Throwable reason) { print("Error loading FieldTests", reason); } }); }
protected void addMethodTests() { GWT.runAsync(MethodTests.class, new RunAsyncCallback() { @Override public void onSuccess() { magicClass(MethodTests.class).getMethods(); try { addTests(MethodTests.class); } catch (final Throwable e) { print("Error adding MethodTests", e); } } @Override public void onFailure(final Throwable reason) { print("Error loading MethodTests", reason); } }); }
public void test(Runnable onDone) { SplitPointTest.onDone = onDone; // start with a regular gwt code split, which forces all our code into split points // this makes it more difficult for the auto-generated code splitting to make clean cuts InstanceInterface instance = X_Inject.instance(InstanceInterface.class); instance.test(); com.google.gwt.core.client.GWT.runAsync(X_Inject.class, new RunAsyncCallback() { @Override public void onSuccess() { X_Inject.singletonAsync(LogService.class, StartTest.class); X_Inject.singletonAsync(ImportTestInterface.class, ImportTestReceiver.class); X_Inject.singletonAsync(ImportTestInterface.class, ImportTestCallback.class); X_Inject.singletonAsync(ServiceTestInterface.class, ServiceTestCallback.class); } @Override public void onFailure(Throwable reason) { } }); }
public static void junitRunAsync(final RunAsyncCallback callback) { new Thread() { @Override public void run() { if (RUN_ASYNC_DELAY > 0) { try { Thread.sleep(RUN_ASYNC_DELAY); } catch (InterruptedException e) { LOG.error("Could not wait", e); } } callback.onSuccess(); } }.start(); }
@Override public void runAsync(AsyncTask asyncTask) { GWT.runAsync(new RunAsyncCallback() { @Override public void onFailure(Throwable reason) { asyncTask.onFailed(reason); } @Override public void onSuccess() { asyncTask.onSuccess(); } }); }
public void initComponentAsync(final RootPanel panel, final Components comp) { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { comp.insert(panel); } public void onFailure(Throwable reason) { } }); }
private void openDialogAsync() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { openDialog(); } public void onFailure(Throwable reason) { UniTimeNotifications.error(MESSAGES.failedToLoadTheApp(reason.getMessage())); } }); }
public void showSuggestionsAsync(final int rowIndex) { if (rowIndex < 0) return; GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { openSuggestionsBox(rowIndex); } public void onFailure(Throwable caught) { iStatus.error(MESSAGES.exceptionSuggestionsFailed(caught.getMessage()), caught); } }); }
private static void loadFacade(final Callback<Void, String> aCallback) { final CumulativeCallbackAdapter<Void, String> facadeProcess = new CumulativeCallbackAdapter<Void, String>(2) { @Override protected void doWork(Void aResult) throws Exception { GWT.runAsync(new RunAsyncCallback() { @Override public void onSuccess() { if (!asyncRan.contains(FACADE_HUB)) { asyncRan.add(FACADE_HUB); JsFacade.init(); } aCallback.onSuccess(null); } @Override public void onFailure(Throwable reason) { aCallback.onFailure(reason.toString()); } }); } @Override protected void failed(List<String> aReasons) { aCallback.onFailure(errorsToString(aReasons)); } }; loadForms(facadeProcess); loadHub(MODEL_HUB, facadeProcess); }
@Inject public CodeMirrorEditorExtension(final EditorTypeRegistry editorTypeRegistry, final RequireJsLoader requireJsLoader, final NotificationManager notificationManager, final CodeMirrorEditorModule editorModule, final BaseCodemirrorPromise basePromise, final BaseCodemirrorInitializer baseInitializer, final CodeMirrorTextEditorFactory codeMirrorTextEditorFactory, final CompletionResources completionResources, final BasePathConstant basePathConstant) { this.notificationManager = notificationManager; this.requireJsLoader = requireJsLoader; this.editorModule = editorModule; this.editorTypeRegistry = editorTypeRegistry; this.codeMirrorTextEditorFactory = codeMirrorTextEditorFactory; this.codemirrorBase = basePathConstant.basePath(); completionResources.completionCss().ensureInjected(); Log.debug(CodeMirrorEditorExtension.class, "Codemirror extension module=" + editorModule); editorModule.setEditorInitializer(new EditorInitializer() { @Override public void initialize(final InitializerCallback callback) { // add code-splitting of the whole orion editor GWT.runAsync(new RunAsyncCallback() { @Override public void onSuccess() { initBaseCodeMirror(basePromise, baseInitializer, callback); } @Override public void onFailure(final Throwable reason) { callback.onFailure(reason); } }); } }); // must not delay registerEditor(); CodeMirrorKeymaps.init(); }
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) { ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(this.packageName, this.viewProxySimpleName); composerFactory.setSuperclass(this.placeType.getSimpleSourceName()); composerFactory.addImport(GWT.class.getName()); composerFactory.addImport(RunAsyncCallback.class.getName()); composerFactory.addImport(ViewProxy.class.getName()); composerFactory.addImport(Place.class.getName()); composerFactory.addImport(ViewPlace.class.getName()); composerFactory.addImport(Activity.class.getName()); composerFactory.addImport(ViewActivity.class.getName()); composerFactory.addImport(ApplicationUnreachableException.class.getName()); composerFactory.addImport(this.placeType.getQualifiedSourceName()); composerFactory.addImport(this.activityDescrition.view().getCanonicalName()); if (this.placeTokenizerClass != null) { composerFactory.addImport(this.placeTokenizerClass.getCanonicalName()); } if (this.viewDecoratorClass != null) { composerFactory.addImport(this.viewDecoratorClass.getCanonicalName()); } composerFactory.addImplementedInterface( ViewProxy.class.getSimpleName() + "<" + this.placeType.getSimpleSourceName() + ">"); return composerFactory.createSourceWriter(ctx, printWriter); }
@Override public void onModuleLoad() { RootPanel.get().clear(); GWT.runAsync(new RunAsyncCallback() { public void onFailure(Throwable err) { Window.alert("code download failure"); } public void onSuccess() { RootPanel.get("main").add(new MainWindow()); } }); }
public Emoji setTheme (String themeName, final Ready ready) { if (instance == null && themeName == null) { themeName = "apple"; } if (currentThemeName == null || (themeName != null && !currentThemeName.equals(themeName))) { currentThemeName = themeName; GWT.runAsync(new RunAsyncCallback() { @Override public void onSuccess () { instance = ThemeFactory.getTheme(currentThemeName); if (ready != null) { ready.ready(Emoji.this); } } @Override public void onFailure (Throwable reason) {} }); } else { if (ready != null) { ready.ready(this); } } return this; }
private void removeHandler() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { removeSaveRequestHandler(oneOffHandler); } public void onFailure(Throwable reason) { } }); }
public void onMinimizeClick(MinimizeClickEvent event) { originalWidth = window.getWidth(); originalLeft = window.getLeft(); originalTop = window.getTop(); originalDragRepo = window.getCanDragReposition(); window.setCanDragReposition(false); // doens't work !? window.setAutoCenter(false); docked = true; GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { window.animateRect(currentPosition, Document.get().getBody().getClientHeight() - minimizedHeight, minimizedWidth, null, new AnimationCallback() { public void execute(boolean earlyFinish) { currentPosition += window.getWidth(); // not // necessarily // equal // to // minimizedWidth. } }); } public void onFailure(Throwable reason) { } }); }
public void onRestoreClick(RestoreClickEvent event) { if (docked) { currentPosition -= window.getWidth(); docked = false; GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { window.animateRect(originalLeft, originalTop, originalWidth, null); window.setCanDragReposition(originalDragRepo); } public void onFailure(Throwable reason) { } }); } }
public void addClass(Class<?> clazz) { if (!finished.add(clazz.getName())) { return; } addGwtModules(clazz); if (EntryPoint.class.isAssignableFrom(clazz)) { try { addMethod(clazz.getMethod("onModuleLoad")); } catch (Exception e) { X_Log.error(GwtcProjectGenerator.class, "Could not extract onModuleLoad method from ", clazz, e); } } else if (GWTTestCase.class.isAssignableFrom(clazz)) { addGwtTestCase(clazz.asSubclass(GWTTestCase.class)); } else if (GWTTestSuite.class.isAssignableFrom(clazz)) { addGwtTestSuite(clazz.asSubclass(GWTTestSuite.class)); } else if (RunAsyncCallback.class.isAssignableFrom(clazz)) { addAsyncBlock(clazz.asSubclass(RunAsyncCallback.class)); } else { // Check if this class has methods annotated w/ junit @Test for (Method m : clazz.getMethods()) { if (m.getAnnotation(Test.class) != null) { finished.remove(clazz.getName()); addJUnitClass(clazz); return; } } try { addMethod(clazz.getMethod("main", String[].class)); } catch (Exception ignored){ X_Log.warn(getClass(), "Class",clazz," was added to Gwtc, " + "but that class was not a subclass of EntryPoint, RunAsync," + " GWTTestCase, GWTTestSuite, nor did it have a main method, or" + " any JUnit 4 annotated @Test method."); } } }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwFrame.class, new RunAsyncCallback() { public void onFailure(Throwable caught) { callback.onFailure(caught); } public void onSuccess() { callback.onSuccess(onInitialize()); } }); }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwCookies.class, new RunAsyncCallback() { public void onFailure(Throwable caught) { callback.onFailure(caught); } public void onSuccess() { callback.onSuccess(onInitialize()); } }); }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwAnimation.class, new RunAsyncCallback() { public void onFailure(Throwable caught) { callback.onFailure(caught); } public void onSuccess() { callback.onSuccess(onInitialize()); } }); }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwCustomDataGrid.class, new RunAsyncCallback() { @Override public void onFailure(Throwable caught) { callback.onFailure(caught); } @Override public void onSuccess() { callback.onSuccess(onInitialize()); } }); }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwCellList.class, new RunAsyncCallback() { public void onFailure(Throwable caught) { callback.onFailure(caught); } public void onSuccess() { callback.onSuccess(onInitialize()); } }); }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwCellValidation.class, new RunAsyncCallback() { public void onFailure(Throwable caught) { callback.onFailure(caught); } public void onSuccess() { callback.onSuccess(onInitialize()); } }); }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwCellBrowser.class, new RunAsyncCallback() { public void onFailure(Throwable caught) { callback.onFailure(caught); } public void onSuccess() { callback.onSuccess(onInitialize()); } }); }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwFlexTable.class, new RunAsyncCallback() { public void onFailure(Throwable caught) { callback.onFailure(caught); } public void onSuccess() { callback.onSuccess(onInitialize()); } }); }
@Override protected void asyncOnInitialize(final AsyncCallback<Widget> callback) { GWT.runAsync(CwBidiFormatting.class, new RunAsyncCallback() { public void onFailure(Throwable caught) { callback.onFailure(caught); } public void onSuccess() { callback.onSuccess(onInitialize()); } }); }