@Override
    public void onComplete(NbGradleModel model, Throwable error) {
      loadedAtLeastOnceSignal.signal();

      boolean hasChanged = false;
      if (model != null) {
        NbGradleModelRef newModel = new NbGradleModelRef(model);
        NbGradleModelRef lastModel = currentModelRef.getAndSet(newModel);
        hasChanged = !lastModel.isSameModel(newModel);
      }

      if (error != null) {
        ProjectInfo.Entry entry =
            new ProjectInfo.Entry(ProjectInfo.Kind.ERROR, NbStrings.getErrorLoadingProject(error));
        getLoadErrorRef().setInfo(new ProjectInfo(Collections.singleton(entry)));
        LOGGER.log(Level.INFO, "Error while loading the project model.", error);
        displayError(NbStrings.getProjectLoadFailure(name), error, true);
      } else {
        getLoadErrorRef().setInfo(null);
      }

      if (hasChanged) {
        if (model == null) {
          notifyEmptyModelChange();
        } else {
          notifyModelChange(model);
        }
      }
    }
 public NbGradleModel getAvailableModel() {
   NbGradleModelRef resultRef = currentModelRef.get();
   NbGradleModel result = resultRef.model;
   // This is not a completely correct solution. The correct
   // solution would be to listen when the model becomes dirty (based on
   // the directory of the project). The problem is that there is no place
   // to unregister such listener.
   //
   // However this should work in most practical cases since
   // getAvailableModel() often gets called.
   if (result.isDirty() || !resultRef.isUpdateToDate()) {
     // Set a non-dirty to prevent many unnecessary project reload.
     currentModelRef.set(new NbGradleModelRef(result.createNonDirtyCopy()));
     reloadProject(true);
   }
   return result;
 }