Search in sources :

Example 16 with GitOutputConsole

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

the class FetchPresenter method onFetchClicked.

/** {@inheritDoc} */
@Override
public void onFetchClicked() {
    final String remoteUrl = view.getRepositoryUrl();
    final StatusNotification notification = notificationManager.notify(constant.fetchProcess(), PROGRESS, FLOAT_MODE);
    final GitOutputConsole console = gitOutputConsoleFactory.create(FETCH_COMMAND_NAME);
    service.fetch(appContext.getDevMachine(), project.getLocation(), view.getRepositoryName(), getRefs(), view.isRemoveDeletedRefs()).then(new Operation<Void>() {

        @Override
        public void apply(Void ignored) throws OperationException {
            console.print(constant.fetchSuccess(remoteUrl));
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notification.setStatus(SUCCESS);
            notification.setTitle(constant.fetchSuccess(remoteUrl));
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), remoteUrl, 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) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 17 with GitOutputConsole

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

the class AddToIndexAction method actionPerformed.

/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
    final Resource[] resources = appContext.getResources();
    checkState(resources != null);
    final DevMachine devMachine = appContext.getDevMachine();
    final GitOutputConsole console = gitOutputConsoleFactory.create(constant.addToIndexCommandName());
    consolesPanelPresenter.addCommandOutput(devMachine.getId(), console);
    service.getStatus(devMachine, appContext.getRootProject().getLocation()).then(status -> {
        if (containsInSelected(status.getUntracked())) {
            presenter.showDialog();
        } else if (containsInSelected(status.getModified()) || containsInSelected(status.getMissing())) {
            addToIndex(console);
        } else {
            String message = resources.length > 1 ? constant.nothingAddToIndexMultiSelect() : constant.nothingAddToIndex();
            console.print(message);
            notificationManager.notify(message);
        }
    }).catchError(error -> {
        console.printError(constant.statusFailed());
        notificationManager.notify(constant.statusFailed(), FAIL, FLOAT_MODE);
    });
}
Also used : 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) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) Resource(org.eclipse.che.ide.api.resources.Resource)

Example 18 with GitOutputConsole

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

the class InitRepositoryPresenter method initRepository.

public void initRepository(final Project project) {
    final GitOutputConsole console = gitOutputConsoleFactory.create(INIT_COMMAND_NAME);
    service.init(appContext.getDevMachine(), project.getLocation(), false).then(new Operation<Void>() {

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

        @Override
        public void apply(PromiseError error) throws OperationException {
            handleError(error.getCause(), console);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
        }
    });
}
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) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 19 with GitOutputConsole

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

the class MergePresenter method onMergeClicked.

/** {@inheritDoc} */
@Override
public void onMergeClicked() {
    view.close();
    final GitOutputConsole console = gitOutputConsoleFactory.create(MERGE_COMMAND_NAME);
    service.merge(appContext.getDevMachine(), project.getLocation(), selectedReference.getDisplayName()).then(new Operation<MergeResult>() {

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

        @Override
        public void apply(PromiseError error) throws OperationException {
            if (error.getCause() instanceof ServerException && ((ServerException) error.getCause()).getErrorCode() == ErrorCodes.NO_COMMITTER_NAME_OR_EMAIL_DEFINED) {
                dialogFactory.createMessageDialog(constant.mergeTitle(), constant.committerIdentityInfoEmpty(), new ConfirmCallback() {

                    @Override
                    public void accepted() {
                    //do nothing
                    }
                }).show();
                return;
            }
            console.printError(error.getMessage());
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.mergeFailed(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) ServerException(org.eclipse.che.ide.commons.exception.ServerException) PromiseError(org.eclipse.che.api.promises.client.PromiseError) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) MergeResult(org.eclipse.che.api.git.shared.MergeResult) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 20 with GitOutputConsole

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

the class CommitPresenter method onCommitSuccess.

private void onCommitSuccess(@NotNull final Revision revision) {
    String date = dateTimeFormatter.getFormattedDate(revision.getCommitTime());
    String message = constant.commitMessage(revision.getId(), date);
    if ((revision.getCommitter() != null && revision.getCommitter().getName() != null && !revision.getCommitter().getName().isEmpty())) {
        message += " " + constant.commitUser(revision.getCommitter().getName());
    }
    GitOutputConsole console = gitOutputConsoleFactory.create(COMMIT_COMMAND_NAME);
    console.print(message);
    consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
    notificationManager.notify(message);
    view.setMessage("");
}
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