Search in sources :

Example 11 with GitOutputConsole

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

the class AddToIndexAction method addToIndex.

private void addToIndex(final GitOutputConsole console) {
    Resource[] resources = appContext.getResources();
    Path[] paths = new Path[resources.length];
    for (int i = 0; i < resources.length; i++) {
        Path path = resources[i].getLocation().removeFirstSegments(1);
        paths[i] = path.segmentCount() == 0 ? Path.EMPTY : path;
    }
    service.add(appContext.getDevMachine(), appContext.getRootProject().getLocation(), false, paths).then(voidArg -> {
        console.print(constant.addSuccess());
        notificationManager.notify(constant.addSuccess());
    }).catchError(error -> {
        console.printError(constant.addFailed());
        notificationManager.notify(constant.addFailed(), FAIL, FLOAT_MODE);
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Inject(com.google.inject.Inject) GitServiceClient(org.eclipse.che.ide.api.git.GitServiceClient) FAIL(org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL) Resource(org.eclipse.che.ide.api.resources.Resource) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) AddToIndexPresenter(org.eclipse.che.ide.ext.git.client.add.AddToIndexPresenter) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) FontAwesome(org.eclipse.che.ide.FontAwesome) FLOAT_MODE(org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE) AppContext(org.eclipse.che.ide.api.app.AppContext) GitLocalizationConstant(org.eclipse.che.ide.ext.git.client.GitLocalizationConstant) GitOutputConsoleFactory(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsoleFactory) NotificationManager(org.eclipse.che.ide.api.notification.NotificationManager) Singleton(com.google.inject.Singleton) ProcessesPanelPresenter(org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter) Path(org.eclipse.che.ide.resource.Path) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 12 with GitOutputConsole

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

the class PullPresenter method handleError.

/**
     * Handler some action whether some exception happened.
     *
     * @param exception
     *         exception that happened
     * @param commandName
     *         name of the command
     */
private void handleError(@NotNull Throwable exception, @NotNull String commandName) {
    int errorCode = getErrorCode(exception);
    if (errorCode == ErrorCodes.NO_COMMITTER_NAME_OR_EMAIL_DEFINED) {
        dialogFactory.createMessageDialog(constant.pullTitle(), constant.committerIdentityInfoEmpty(), null).show();
        return;
    } else if (errorCode == ErrorCodes.UNABLE_GET_PRIVATE_SSH_KEY) {
        dialogFactory.createMessageDialog(constant.pullTitle(), constant.messagesUnableGetSshKey(), null).show();
        return;
    }
    String errorMessage = exception.getMessage();
    if (errorMessage == null) {
        switch(commandName) {
            case REMOTE_REPO_COMMAND_NAME:
                errorMessage = constant.remoteListFailed();
                break;
            case BRANCH_LIST_COMMAND_NAME:
                errorMessage = constant.branchesListFailed();
                break;
            case PULL_COMMAND_NAME:
                errorMessage = constant.pullFail(view.getRepositoryUrl());
                break;
        }
    }
    GitOutputConsole console = gitOutputConsoleFactory.create(commandName);
    console.printError(errorMessage);
    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 13 with GitOutputConsole

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

the class PushToRemotePresenter method updateRemoteBranches.

/**
     * Update list of remote branches on view.
     */
void updateRemoteBranches() {
    getBranchesForCurrentProject(LIST_REMOTE, new AsyncCallback<List<Branch>>() {

        @Override
        public void onSuccess(final List<Branch> result) {
            // Need to add the upstream of local branch in the list of remote branches
            // to be able to push changes to the remote upstream branch
            getUpstreamBranch(new AsyncCallback<Branch>() {

                @Override
                public void onSuccess(Branch upstream) {
                    BranchFilterByRemote remoteRefsHandler = new BranchFilterByRemote(view.getRepository());
                    final List<String> remoteBranches = branchSearcher.getRemoteBranchesToDisplay(remoteRefsHandler, result);
                    String selectedRemoteBranch = null;
                    if (upstream != null && upstream.isRemote() && remoteRefsHandler.isLinkedTo(upstream)) {
                        String simpleUpstreamName = remoteRefsHandler.getBranchNameWithoutRefs(upstream);
                        if (!remoteBranches.contains(simpleUpstreamName)) {
                            remoteBranches.add(simpleUpstreamName);
                        }
                        selectedRemoteBranch = simpleUpstreamName;
                    }
                    // Need to add the current local branch in the list of remote branches
                    // to be able to push changes to the remote branch  with same name
                    final String currentBranch = view.getLocalBranch();
                    if (!remoteBranches.contains(currentBranch)) {
                        remoteBranches.add(currentBranch);
                    }
                    if (selectedRemoteBranch == null) {
                        selectedRemoteBranch = currentBranch;
                    }
                    view.setRemoteBranches(remoteBranches);
                    view.selectRemoteBranch(selectedRemoteBranch);
                }

                @Override
                public void onFailure(Throwable caught) {
                    GitOutputConsole console = gitOutputConsoleFactory.create(CONFIG_COMMAND_NAME);
                    console.printError(constant.failedGettingConfig());
                    processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
                    notificationManager.notify(constant.failedGettingConfig(), FAIL, FLOAT_MODE);
                }
            });
        }

        @Override
        public void onFailure(Throwable exception) {
            String errorMessage = exception.getMessage() != null ? exception.getMessage() : constant.remoteBranchesListFailed();
            GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_LIST_COMMAND_NAME);
            console.printError(errorMessage);
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.remoteBranchesListFailed(), FAIL, FLOAT_MODE);
            view.setEnablePushButton(false);
        }
    });
}
Also used : Branch(org.eclipse.che.api.git.shared.Branch) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) BranchFilterByRemote(org.eclipse.che.ide.ext.git.client.BranchFilterByRemote) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List)

Example 14 with GitOutputConsole

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

the class RemoveFromIndexPresenter method onRemoveClicked.

/** {@inheritDoc} */
@Override
public void onRemoveClicked() {
    final GitOutputConsole console = gitOutputConsoleFactory.create(REMOVE_FROM_INDEX_COMMAND_NAME);
    final Resource[] resources = appContext.getResources();
    checkState(!isNullOrEmpty(resources));
    service.remove(appContext.getDevMachine(), project.getLocation(), toRelativePaths(resources), view.isRemoved()).then(new Operation<Void>() {

        @Override
        public void apply(Void ignored) throws OperationException {
            console.print(constant.removeFilesSuccessfull());
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.removeFilesSuccessfull());
            project.synchronize();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), console);
            consolesPanelPresenter.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) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 15 with GitOutputConsole

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

the class ResetToCommitPresenter method reset.

/**
     * Reset current HEAD to the specified state and refresh project in the success case.
     */
private void reset() {
    ResetRequest.ResetType type = view.isMixMode() ? ResetRequest.ResetType.MIXED : null;
    type = (type == null && view.isSoftMode()) ? ResetRequest.ResetType.SOFT : type;
    type = (type == null && view.isHardMode()) ? ResetRequest.ResetType.HARD : type;
    final GitOutputConsole console = gitOutputConsoleFactory.create(RESET_COMMAND_NAME);
    service.reset(appContext.getDevMachine(), project.getLocation(), selectedRevision.getId(), type, null).then(new Operation<Void>() {

        @Override
        public void apply(Void ignored) throws OperationException {
            console.print(constant.resetSuccessfully());
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.resetSuccessfully());
            project.synchronize();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            String errorMessage = (error.getMessage() != null) ? error.getMessage() : constant.resetFail();
            console.printError(errorMessage);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.resetFail(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) Operation(org.eclipse.che.api.promises.client.Operation) ResetRequest(org.eclipse.che.api.git.shared.ResetRequest) OperationException(org.eclipse.che.api.promises.client.OperationException)

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