static// TODO consider to make this hashmap per application
LinkedList<Command> callbacks = new LinkedList<Command>();
- private static int widgetsLoading;
+ private static int dependenciesLoading;
private static ArrayList<ApplicationConnection> runningApplications = new ArrayList<ApplicationConnection>();
*
* @param c
*/
- static void runWhenWidgetsLoaded(Command c) {
- if (widgetsLoading == 0) {
+ static void runWhenDependenciesLoaded(Command c) {
+ if (dependenciesLoading == 0) {
c.execute();
} else {
callbacks.add(c);
}
}
- static void startWidgetLoading() {
- widgetsLoading++;
+ static void startDependencyLoading() {
+ dependenciesLoading++;
}
- static void endWidgetLoading() {
- widgetsLoading--;
- if (widgetsLoading == 0 && !callbacks.isEmpty()) {
+ static void endDependencyLoading() {
+ dependenciesLoading--;
+ if (dependenciesLoading == 0 && !callbacks.isEmpty()) {
for (Command cmd : callbacks) {
cmd.execute();
}
callbacks.clear();
- } else if (widgetsLoading == 0 && deferredWidgetLoader != null) {
+ } else if (dependenciesLoading == 0 && deferredWidgetLoader != null) {
deferredWidgetLoader.trigger();
}
}
private boolean isBusy() {
- if (widgetsLoading > 0) {
+ if (dependenciesLoading > 0) {
communicationFree = 0;
return true;
}
}
};
- ApplicationConfiguration.runWhenWidgetsLoaded(c);
+ ApplicationConfiguration.runWhenDependenciesLoaded(c);
}
private static void loadStyleDependencies(JsArrayString dependencies) {
// Assuming no reason to interpret in a defined order
ResourceLoadListener resourceLoadListener = new ResourceLoadListener() {
public void onResourceLoad(ResourceLoadEvent event) {
- ApplicationConfiguration.endWidgetLoading();
+ ApplicationConfiguration.endDependencyLoading();
}
};
ResourceLoader loader = ResourceLoader.get();
for (int i = 0; i < dependencies.length(); i++) {
- ApplicationConfiguration.startWidgetLoading();
+ ApplicationConfiguration.startDependencyLoading();
loader.loadStylesheet(dependencies.get(i), resourceLoadListener);
}
}
ResourceLoadListener resourceLoadListener = new ResourceLoadListener() {
public void onResourceLoad(ResourceLoadEvent event) {
if (dependencies.length() != 0) {
- ApplicationConfiguration.startWidgetLoading();
+ ApplicationConfiguration.startDependencyLoading();
// Load next in chain (hopefully already preloaded)
event.getResourceLoader().loadScript(dependencies.shift(),
this);
}
// Call start for next before calling end for current
- ApplicationConfiguration.endWidgetLoading();
+ ApplicationConfiguration.endDependencyLoading();
}
};
ResourceLoader loader = ResourceLoader.get();
// Start chain by loading first
- ApplicationConfiguration.startWidgetLoading();
+ ApplicationConfiguration.startDependencyLoading();
loader.loadScript(dependencies.shift(), resourceLoadListener);
// Preload all remaining
abstract class WidgetLoader implements RunAsyncCallback {
public void onFailure(Throwable reason) {
- ApplicationConfiguration.endWidgetLoading();
+ ApplicationConfiguration.endDependencyLoading();
}
public void onSuccess() {
addInstantiator();
- ApplicationConfiguration.endWidgetLoading();
+ ApplicationConfiguration.endDependencyLoading();
}
abstract void addInstantiator();