Search in sources :

Example 6 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class CleanupPresenter method cleanup.

public void cleanup() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    service.cleanup(project.getLocation(), toRelative(project, resources)).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse result) throws OperationException {
            printResponse(result.getCommand(), result.getOutput(), result.getErrOutput(), constants.commandCleanup());
            notificationManager.notify(constants.cleanupSuccessful());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(constants.cleanupFailed() + ": " + error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 7 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class CommitPresenter method loadAllChanges.

private void loadAllChanges() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    service.status(project.getLocation(), new Path[0], null, false, false, false, true, false, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            List<StatusItem> statusItems = parseChangesList(response);
            view.setChangesList(statusItems);
            view.onShow();
            cache.put(Changes.ALL, statusItems);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            Log.error(CommitPresenter.class, error.getMessage());
        }
    });
}
Also used : StatusItem(org.eclipse.che.plugin.svn.shared.StatusItem) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 8 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class CommitPresenter method showDiff.

/** {@inheritDoc} */
@Override
public void showDiff(final String path) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {

        @Override
        public Promise<CLIOutputResponse> perform(Credentials credentials) {
            return service.showDiff(project.getLocation(), new Path[] { valueOf(path) }, "HEAD", credentials);
        }
    }, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            String content = Joiner.on('\n').join(response.getOutput());
            diffViewerPresenter.showDiff(content);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Operation(org.eclipse.che.api.promises.client.Operation) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 9 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class SubversionApi method revert.

/**
     * Perform an "svn revert" based on the request.
     *
     * @param request
     *         the request
     * @return the response
     * @throws IOException
     *         if there is a problem executing the command
     * @throws SubversionException
     *         if there is a Subversion issue
     */
public CLIOutputResponse revert(RevertRequest request) throws IOException, SubversionException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    final List<String> cliArgs = defaultArgs();
    addOption(cliArgs, "--depth", request.getDepth());
    cliArgs.add("revert");
    final CommandLineResult result = runCommand(null, cliArgs, projectPath, addWorkingCopyPathIfNecessary(request.getPaths()));
    return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
Also used : CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) File(java.io.File)

Example 10 with CLIOutputResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.

the class RemovePresenter method showRemove.

public void showRemove() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    final StatusNotification notification = new StatusNotification(constants.removeStarted(resources.length), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    service.remove(project.getLocation(), toRelative(project, resources)).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandRemove());
            notification.setTitle(constants.removeSuccessful());
            notification.setStatus(SUCCESS);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notification.setTitle(constants.removeFailed());
            notification.setStatus(FAIL);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)49 Operation (org.eclipse.che.api.promises.client.Operation)21 OperationException (org.eclipse.che.api.promises.client.OperationException)21 PromiseError (org.eclipse.che.api.promises.client.PromiseError)21 Project (org.eclipse.che.ide.api.resources.Project)18 File (java.io.File)14 Resource (org.eclipse.che.ide.api.resources.Resource)14 CommandLineResult (org.eclipse.che.plugin.svn.server.upstream.CommandLineResult)14 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)7 Promise (org.eclipse.che.api.promises.client.Promise)6 Credentials (org.eclipse.che.ide.api.subversion.Credentials)6 ArrayList (java.util.ArrayList)5 CheckoutRequest (org.eclipse.che.plugin.svn.shared.CheckoutRequest)5 Test (org.junit.Test)4 Path (org.eclipse.che.ide.resource.Path)3 ListRequest (org.eclipse.che.plugin.svn.shared.ListRequest)3 PropertyListRequest (org.eclipse.che.plugin.svn.shared.PropertyListRequest)3 CLIOutputResponseList (org.eclipse.che.plugin.svn.shared.CLIOutputResponseList)2 Depth (org.eclipse.che.plugin.svn.shared.Depth)2 LockRequest (org.eclipse.che.plugin.svn.shared.LockRequest)2