Search in sources :

Example 6 with GitOutputConsole

use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole in project che by eclipse.

the class AddToIndexPresenter method onAddClicked.

/** {@inheritDoc} */
@Override
public void onAddClicked() {
    DevMachine devMachine = appContext.getDevMachine();
    Resource[] resources = appContext.getResources();
    Path projectLocation = appContext.getRootProject().getLocation();
    Path[] paths = new Path[resources.length];
    for (int i = 0; i < resources.length; i++) {
        Path path = resources[i].getLocation().removeFirstSegments(projectLocation.segmentCount());
        paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
    }
    final GitOutputConsole console = gitOutputConsoleFactory.create(constant.addToIndexCommandName());
    consolesPanelPresenter.addCommandOutput(devMachine.getId(), console);
    service.add(devMachine, projectLocation, view.isUpdated(), paths).then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            console.print(constant.addSuccess());
            notificationManager.notify(constant.addSuccess());
            view.close();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            console.printError(constant.addFailed());
            notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
            view.close();
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 7 with GitOutputConsole

use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole in project che by eclipse.

the class BranchPresenter method handleError.

/**
     * Handler some action whether some exception happened.
     *
     * @param exception
     *         exception what happened
     * @param commandName
     *         name of the executed command
     */
void handleError(@NotNull Throwable exception, String commandName) {
    if (getErrorCode(exception) == ErrorCodes.UNABLE_GET_PRIVATE_SSH_KEY) {
        dialogFactory.createMessageDialog(commandName, constant.messagesUnableGetSshKey(), null).show();
        return;
    }
    String errorMessage = exception.getMessage();
    if (errorMessage == null) {
        switch(commandName) {
            case BRANCH_CREATE_COMMAND_NAME:
                errorMessage = constant.branchCreateFailed();
                break;
            case BRANCH_DELETE_COMMAND_NAME:
                errorMessage = constant.branchDeleteFailed();
                break;
            case BRANCH_LIST_COMMAND_NAME:
                errorMessage = constant.branchesListFailed();
                break;
            case BRANCH_RENAME_COMMAND_NAME:
                errorMessage = constant.branchRenameFailed();
                break;
            case BRANCH_CHECKOUT_COMMAND_NAME:
                errorMessage = constant.branchCheckoutFailed();
                break;
        }
    }
    GitOutputConsole console = gitOutputConsoleFactory.create(commandName);
    printGitMessage(errorMessage, console);
    consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
    notificationManager.notify(errorMessage, FAIL, FLOAT_MODE);
}
Also used : GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)

Example 8 with GitOutputConsole

use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole in project che by eclipse.

the class CommitPresenter method handleError.

private void handleError(@NotNull Throwable exception) {
    if (exception instanceof ServerException && ((ServerException) exception).getErrorCode() == ErrorCodes.NO_COMMITTER_NAME_OR_EMAIL_DEFINED) {
        dialogFactory.createMessageDialog(constant.commitTitle(), constant.committerIdentityInfoEmpty(), null).show();
        return;
    }
    String exceptionMessage = exception.getMessage();
    String errorMessage = (exceptionMessage != null && !exceptionMessage.isEmpty()) ? exceptionMessage : constant.commitFailed();
    GitOutputConsole console = gitOutputConsoleFactory.create(COMMIT_COMMAND_NAME);
    console.printError(errorMessage);
    consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
    notificationManager.notify(constant.commitFailed(), errorMessage, FAIL, FLOAT_MODE);
}
Also used : ServerException(org.eclipse.che.ide.commons.exception.ServerException) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)

Example 9 with GitOutputConsole

use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole in project che by eclipse.

the class PushToRemotePresenter method onPushClicked.

/** {@inheritDoc} */
@Override
public void onPushClicked() {
    final StatusNotification notification = notificationManager.notify(constant.pushProcess(), PROGRESS, FLOAT_MODE);
    final String repository = view.getRepository();
    final GitOutputConsole console = gitOutputConsoleFactory.create(PUSH_COMMAND_NAME);
    service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, false).then(new Operation<PushResponse>() {

        @Override
        public void apply(PushResponse response) throws OperationException {
            console.print(response.getCommandOutput());
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notification.setStatus(SUCCESS);
            if (response.getCommandOutput().contains("Everything up-to-date")) {
                notification.setTitle(constant.pushUpToDate());
            } else {
                notification.setTitle(constant.pushSuccess(repository));
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), notification, console);
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
        }
    });
    view.close();
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) PushResponse(org.eclipse.che.api.git.shared.PushResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 10 with GitOutputConsole

use of org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole in project che by eclipse.

the class RemotePresenter method handleError.

private void handleError(@NotNull String errorMessage) {
    GitOutputConsole console = gitOutputConsoleFactory.create(REMOTE_REPO_COMMAND_NAME);
    console.printError(errorMessage);
    consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
    notificationManager.notify(errorMessage);
}
Also used : GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)

Aggregations

GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)22 Operation (org.eclipse.che.api.promises.client.Operation)13 OperationException (org.eclipse.che.api.promises.client.OperationException)13 PromiseError (org.eclipse.che.api.promises.client.PromiseError)13 List (java.util.List)5 Resource (org.eclipse.che.ide.api.resources.Resource)5 Path (org.eclipse.che.ide.resource.Path)4 Branch (org.eclipse.che.api.git.shared.Branch)3 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)3 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)3 Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 Inject (com.google.inject.Inject)2 Singleton (com.google.inject.Singleton)2 Collections.singletonList (java.util.Collections.singletonList)2 IndexFile (org.eclipse.che.api.git.shared.IndexFile)2 FontAwesome (org.eclipse.che.ide.FontAwesome)2 ActionEvent (org.eclipse.che.ide.api.action.ActionEvent)2 AppContext (org.eclipse.che.ide.api.app.AppContext)2 GitServiceClient (org.eclipse.che.ide.api.git.GitServiceClient)2 NotificationManager (org.eclipse.che.ide.api.notification.NotificationManager)2