示例#1
0
  /**
   * Handler some action whether some exception happened.
   *
   * @param throwable exception what happened
   * @param console console for displaying error
   */
  void handleError(@NotNull Throwable throwable, GitOutputConsole console) {
    String errorMessage = throwable.getMessage();
    if (errorMessage == null) {
      console.printError(constant.branchDeleteFailed());
      notificationManager.notify(
          constant.branchDeleteFailed(), FAIL, true, project.getRootProject());
      return;
    }

    try {
      errorMessage = dtoFactory.createDtoFromJson(errorMessage, ServiceError.class).getMessage();
      if (errorMessage.equals("Unable get private ssh key")) {
        console.printError(constant.messagesUnableGetSshKey());
        notificationManager.notify(
            constant.messagesUnableGetSshKeyTitle(),
            constant.messagesUnableGetSshKey(),
            FAIL,
            true,
            project.getRootProject());
        return;
      }
      console.printError(errorMessage);
      notificationManager.notify(errorMessage, FAIL, true, project.getRootProject());
    } catch (Exception e) {
      console.printError(errorMessage);
      notificationManager.notify(errorMessage, FAIL, true, project.getRootProject());
    }
  }
 private void handleError(PromiseError error) {
   view.showLoader(false);
   final ServiceError serviceError =
       dtoFactory.createDtoFromJson(error.getMessage(), ServiceError.class);
   notificationManager.notify(serviceError.getMessage(), FAIL, true);
   view.showError(serviceError.getMessage());
 }
  @Inject
  public MachinePerspective(
      PerspectiveViewImpl view,
      PartStackViewFactory partViewFactory,
      WorkBenchControllerFactory controllerFactory,
      PartStackPresenterFactory stackPresenterFactory,
      MachineConsolePresenter console,
      MachinePanelPresenter machinePanel,
      RecipePartPresenter recipePanel,
      NotificationManager notificationManager,
      OutputsContainerPresenter outputsContainer,
      MachineAppliancePresenter infoContainer,
      EventBus eventBus) {
    super(
        MACHINE_PERSPECTIVE_ID,
        view,
        stackPresenterFactory,
        partViewFactory,
        controllerFactory,
        eventBus);

    notificationManager.addRule(MACHINE_PERSPECTIVE_ID);

    // central panel
    partStacks.put(EDITING, infoContainer);

    addPart(console, INFORMATION);
    addPart(notificationManager, INFORMATION, FIRST);
    addPart(outputsContainer, INFORMATION);
    addPart(machinePanel, NAVIGATION);
    addPart(recipePanel, NAVIGATION);

    setActivePart(machinePanel);
  }
 /** {@inheritDoc} */
 @Override
 public void onAuthenticated(OAuthStatus authStatus) {
   if (LOGGED_IN.equals(authStatus)) {
     generateKey(userId, callback);
   } else {
     notificationManager.showNotification(
         new Notification(constant.gitHubSshKeyUpdateFailed(), Notification.Type.ERROR));
   }
 }
示例#5
0
 /** {@inheritDoc} */
 @Override
 public void onGenerateGithubKeyClicked() {
   CurrentUser user = appContext.getCurrentUser();
   if (user != null && service.getSshKeyProviders().containsKey(GITHUB_HOST)) {
     generateGithubKey(user);
   } else {
     notificationManager.showError(constant.sshKeysProviderNotFound(GITHUB_HOST));
   }
 }
示例#6
0
  /** {@inheritDoc} */
  @Override
  public void onCopyClicked() {
    final Project project = appContext.getRootProject();

    Preconditions.checkState(project != null);

    final Path src =
        view.isSourceCheckBoxSelected()
            ? Path.valueOf(view.getSourcePath())
            : toRelative(project, sourceNode);
    final Path target =
        view.isTargetCheckBoxSelected()
            ? Path.valueOf(view.getTargetUrl())
            : toRelative(project, this.target);
    final String comment = view.isTargetCheckBoxSelected() ? view.getComment() : null;

    final StatusNotification notification =
        new StatusNotification(
            constants.copyNotificationStarted(src.toString()), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);

    view.hide();

    performOperationWithCredentialsRequestIfNeeded(
            new RemoteSubversionOperation<CLIOutputResponse>() {
              @Override
              public Promise<CLIOutputResponse> perform(Credentials credentials) {
                notification.setStatus(PROGRESS);
                notification.setTitle(constants.copyNotificationStarted(src.toString()));

                return service.copy(project.getLocation(), src, target, comment, credentials);
              }
            },
            notification)
        .then(
            new Operation<CLIOutputResponse>() {
              @Override
              public void apply(CLIOutputResponse response) throws OperationException {
                printResponse(
                    response.getCommand(),
                    response.getOutput(),
                    response.getErrOutput(),
                    constants.commandCopy());

                notification.setTitle(constants.copyNotificationSuccessful());
                notification.setStatus(SUCCESS);
              }
            })
        .catchError(
            new Operation<PromiseError>() {
              @Override
              public void apply(PromiseError error) throws OperationException {
                notification.setTitle(constants.copyNotificationFailed());
                notification.setStatus(FAIL);
              }
            });
  }
  /**
   * Adds command node to process tree and displays command output
   *
   * @param machineId id of machine in which the command will be executed
   * @param outputConsole the console for command output
   */
  public void addCommandOutput(@NotNull String machineId, @NotNull OutputConsole outputConsole) {
    ProcessTreeNode machineTreeNode = findProcessTreeNodeById(machineId);
    if (machineTreeNode == null) {
      notificationManager.notify(
          localizationConstant.failedToExecuteCommand(),
          localizationConstant.machineNotFound(machineId),
          FAIL,
          FLOAT_MODE);
      Log.error(getClass(), localizationConstant.machineNotFound(machineId));
      return;
    }

    String commandId;
    String outputConsoleTitle = outputConsole.getTitle();
    ProcessTreeNode processTreeNode = getProcessTreeNodeByName(outputConsoleTitle, machineTreeNode);
    if (processTreeNode != null && isCommandStopped(processTreeNode.getId())) {
      commandId = processTreeNode.getId();
      view.hideProcessOutput(commandId);
    } else {
      ProcessTreeNode commandNode =
          new ProcessTreeNode(
              COMMAND_NODE,
              machineTreeNode,
              outputConsoleTitle,
              outputConsole.getTitleIcon(),
              null);
      commandId = commandNode.getId();
      view.addProcessNode(commandNode);
      addChildToMachineNode(commandNode, machineTreeNode);
    }

    updateCommandOutput(commandId, outputConsole);

    resfreshStopButtonState(commandId);
    workspaceAgent.setActivePart(this);
  }