Esempio n. 1
0
  // ------------------------------------------ constructor
  public HomeView() {
    super("Projet", ViewNameEnum.home);

    this.initComposants();
    this.initHandlers();

    this.setContent(this.buildContent());
    this.protectedReinit();
    this.displayPanels();
    AppController.getInstance().addAppListener(this);
  }
Esempio n. 2
0
 private String getSourceDir() {
   final String tbValue = this._tbSourceDirName.getValue();
   return (tbValue != null && tbValue.trim().length() > 0)
       ? tbValue
       : AppController.getInstance().getInfo(ActionInfo.sourceDir);
 }
Esempio n. 3
0
  private void getDataFromServer(
      final Action action, final ActionState state, final Object object) {

    if (log.isLoggable(Level.INFO)) {
      log.info(
          "getDataFromServer: action "
              + action
              + " - state: "
              + state
              + ((object == null) ? "" : " - object: " + object.toString()));
    }
    AppController.getInstance().done(Action.clearStatus);

    switch (action) {
      case uploadContent:
        switch (state) {
          case done:
            AppController.getInstance().reinit();
            getDataFromServer(Action.buildApplicationFromContent);
            this._projectName = object.toString();
            this.displayPanels();
            break;
        }
        break;

      case uploadZip:

        // controle
        IUploader uploader = null;
        if (state != ActionState.error && object != null && object instanceof IUploader) {
          uploader = (IUploader) object;
          final StringBuilder errorMessage = new StringBuilder();
          if (!controleUpload(uploader, errorMessage)) {
            getDataFromServer(Action.uploadZip, ActionState.error, errorMessage.toString());
            break;
          }
        }

        switch (state) {
          case start:
            _projectName = null;
            AppController.getInstance().reinit();
            AppController.getInstance().inProgress(action);
            break;

          case done:
            if (uploader.getStatus() == Status.SUCCESS) {

              AppController.getInstance().done(action);
              _projectName = uploader.getServerInfo().name;
              displayPanels();

              // You can send any customized message and parse it
              log.config("Server message " + uploader.getServerInfo().message);

              getDataFromServer(Action.buildApplication);
            }
            break;

          case cancel:
            AppController.getInstance().done(Action.uploadZip, "Interruption par l'utilisateur");
            _projectName = null;
            displayPanels();
            break;

          case error:
            AppController.getInstance()
                .error(Action.uploadZip, (object == null) ? "erreur inconnue!" : object.toString());
            break;
        }

        break;

      case loadModules:
        AppController.getInstance().inProgress(action);
        AppController.getService()
            .loadModules(
                new ServiceCallback<List<ModuleLightDto>>(action) {

                  @Override
                  public void onSuccess(List<ModuleLightDto> result) {
                    _tableModules.populateGrid(result);
                    AppController.getInstance().done(action);
                  }
                });
        break;

      case buildApplication:
        {
          AppController.getInstance().inProgress(action);
          AppController.getService()
              .buildApplication(
                  this.getSourceDir(),
                  new ServiceCallback<Boolean>(action) {

                    @Override
                    public void onSuccess(Boolean result) {
                      AppController.getInstance().done(action);
                      getDataFromServer(Action.loadModules);
                    }
                  });
          break;
        }

      case buildApplicationFromContent:
        {
          AppController.getInstance().inProgress(action);
          AppController.getInstance().inProgress(action);
          AppController.getService()
              .buildApplicationFromMapContent(
                  this.getSourceDir(),
                  new ServiceCallback<Boolean>(action) {

                    @Override
                    public void onSuccess(Boolean result) {
                      AppController.getInstance().done(action);
                      getDataFromServer(Action.loadModules);
                    }
                  });
          break;
        }

      case buildDemo:
        _projectName = "démo";

        AppController.getInstance().reinit();
        AppController.getInstance().inProgress(action);
        AppController.getService()
            .buildDemo(
                new ServiceCallback<Boolean>(action) {

                  @Override
                  public void onSuccess(Boolean result) {
                    AppController.getInstance().done(action);
                    displayPanels();
                    getDataFromServer(Action.loadModules);
                  }
                });
        break;
    }
  }
Esempio n. 4
0
 private void saveSourceDir() {
   AppController.getInstance().setInfo(ActionInfo.sourceDir, this.getSourceDir());
 }