com.google.gwt.core.client.RunAsyncCallback Java Examples

The following examples show how to use com.google.gwt.core.client.RunAsyncCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DemoGwtWebApp.java    From demo-gwt-springboot with Apache License 2.0 6 votes vote down vote up
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...");
		}
	});
}
 
Example #2
Source File: Client.java    From unitime with Apache License 2.0 6 votes vote down vote up
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);
		}
	});
}
 
Example #3
Source File: Mvp4gGenerator.java    From mvp4g with Apache License 2.0 6 votes vote down vote up
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() };
}
 
Example #4
Source File: Console.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void bootstrap() {
    GWT.runAsync(new RunAsyncCallback() {
        @Override
        public void onFailure(Throwable reason) {
            Window.alert("Failed to load application components!");
        }

        @Override
        public void onSuccess() {
            DelayedBindRegistry.bind(MODULES);
            MODULES.getEventBus().addHandler(AsyncCallFailEvent.getType(),
                    new AsyncCallHandler(MODULES.getPlaceManager()));
            MODULES.getBootstrapper().go(new BootstrapOutcome());
        }
    });
}
 
Example #5
Source File: Client.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void initComponentAsync(final RootPanel panel, final Components comp) {
	GWT.runAsync(new RunAsyncCallback() {
		public void onSuccess() {
			comp.insert(panel);
		}
		public void onFailure(Throwable reason) {
		}
	});
}
 
Example #6
Source File: CourseSelectionSuggestBox.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void openDialogAsync() {
       GWT.runAsync(new RunAsyncCallback() {
       	public void onSuccess() {
       		openDialog();
       	}
       	public void onFailure(Throwable reason) {
       		UniTimeNotifications.error(MESSAGES.failedToLoadTheApp(reason.getMessage()));
       	}
       });
}
 
Example #7
Source File: CourseRequestBox.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void openDialogAsync() {
       GWT.runAsync(new RunAsyncCallback() {
       	public void onSuccess() {
       		openDialog();
       	}
       	public void onFailure(Throwable reason) {
       		UniTimeNotifications.error(MESSAGES.failedToLoadTheApp(reason.getMessage()));
       	}
       });
}
 
Example #8
Source File: StudentSectioningWidget.java    From unitime with Apache License 2.0 5 votes vote down vote up
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);
		}
	});
}
 
Example #9
Source File: ProxyViewCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #10
Source File: Client.java    From unitime with Apache License 2.0 4 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);
		}
	});
}
 
Example #11
Source File: Mvp4gRunAsyncGenerator.java    From mvp4g with Apache License 2.0 4 votes vote down vote up
String[] getClassesToImport() {
  return new String[] { GWT.class.getName(),
                        RunAsyncCallback.class.getName() };
}