Search in sources :

Example 1 with Credentials

use of org.eclipse.che.ide.api.subversion.Credentials in project che by eclipse.

the class SwitchPresenter method showWindow.

public void showWindow() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    switchView.showWindow();
    switchView.setSwitchButtonEnabled(false);
    invalidateLoadedData();
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {

        @Override
        public Promise<InfoResponse> perform(Credentials credentials) {
            return service.info(appContext.getRootProject().getLocation(), ".", "HEAD", false, credentials);
        }
    }, null).then(new Operation<InfoResponse>() {

        @Override
        public void apply(InfoResponse response) throws OperationException {
            if (!response.getItems().isEmpty()) {
                SubversionItem subversionItem = response.getItems().get(0);
                projectUri = subversionItem.getProjectUri();
            }
            defaultViewInitialization();
            handleSwitchButton();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            projectUri = "^";
            Path location = appContext.getRootProject().getLocation();
            notificationManager.notify(constants.infoRequestError(location.toString()), error.getMessage(), FAIL, EMERGE_MODE);
            defaultViewInitialization();
            handleSwitchButton();
        }
    });
}
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) InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) SubversionItem(org.eclipse.che.plugin.svn.shared.SubversionItem) PromiseError(org.eclipse.che.api.promises.client.PromiseError) 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 2 with Credentials

use of org.eclipse.che.ide.api.subversion.Credentials in project che by eclipse.

the class UpdatePresenter method doUpdate.

protected void doUpdate(final String revision, final String depth, final boolean ignoreExternals, final UpdateToRevisionView view) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    final StatusNotification notification = new StatusNotification(constants.updateToRevisionStarted(revision), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputWithRevisionResponse>() {

        @Override
        public Promise<CLIOutputWithRevisionResponse> perform(Credentials credentials) {
            notification.setStatus(PROGRESS);
            notification.setTitle(constants.updateToRevisionStarted(revision));
            return service.update(project.getLocation(), toRelative(project, resources), revision, depth, ignoreExternals, "postpone", credentials);
        }
    }, notification).then(new Operation<CLIOutputWithRevisionResponse>() {

        @Override
        public void apply(CLIOutputWithRevisionResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandUpdate());
            notification.setTitle(constants.updateSuccessful(Long.toString(response.getRevision())));
            notification.setStatus(SUCCESS);
            if (view != null) {
                view.close();
            }
        }
    }).catchError(new Operation<PromiseError>() {

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

Example 3 with Credentials

use of org.eclipse.che.ide.api.subversion.Credentials in project che by eclipse.

the class ShowLogPresenter method showLog.

/**
     * Fetches the count of revisions and opens the popup.
     */
public void showLog() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    checkState(resources.length == 1);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {

        @Override
        public Promise<InfoResponse> perform(Credentials credentials) {
            return service.info(project.getLocation(), toRelative(project, resources[0]).toString(), "HEAD", false, credentials);
        }
    }, null).then(new Operation<InfoResponse>() {

        @Override
        public void apply(InfoResponse response) throws OperationException {
            if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) {
                printErrors(response.getErrorOutput(), constants.commandInfo());
                notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
                return;
            }
            SubversionItem subversionItem = response.getItems().get(0);
            view.setRevisionCount(subversionItem.getRevision());
            view.rangeField().setValue("1:" + subversionItem.getRevision());
            view.show();
        }
    }).catchError(new Operation<PromiseError>() {

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

Example 4 with Credentials

use of org.eclipse.che.ide.api.subversion.Credentials in project che by eclipse.

the class SubversionCredentialsDialogImpl method onAuthenticateClicked.

@Override
public void onAuthenticateClicked() {
    callback.onSuccess(new Credentials(view.getUsername(), view.getPassword()));
    view.closeDialog();
}
Also used : Credentials(org.eclipse.che.ide.api.subversion.Credentials)

Example 5 with Credentials

use of org.eclipse.che.ide.api.subversion.Credentials in project che by eclipse.

the class DiffPresenter method showDiff.

public void showDiff() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {

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

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandDiff());
            ;
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) 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)

Aggregations

Credentials (org.eclipse.che.ide.api.subversion.Credentials)11 Operation (org.eclipse.che.api.promises.client.Operation)10 OperationException (org.eclipse.che.api.promises.client.OperationException)10 Promise (org.eclipse.che.api.promises.client.Promise)10 PromiseError (org.eclipse.che.api.promises.client.PromiseError)10 Project (org.eclipse.che.ide.api.resources.Project)10 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)6 Resource (org.eclipse.che.ide.api.resources.Resource)4 Path (org.eclipse.che.ide.resource.Path)4 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)3 InfoResponse (org.eclipse.che.plugin.svn.shared.InfoResponse)3 SubversionItem (org.eclipse.che.plugin.svn.shared.SubversionItem)3 ArrayList (java.util.ArrayList)1 AbstractTreeNode (org.eclipse.che.ide.api.data.tree.AbstractTreeNode)1 Node (org.eclipse.che.ide.api.data.tree.Node)1 CLIOutputWithRevisionResponse (org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse)1