Search in sources :

Example 71 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class MovePresenter method show.

/**
     * Show Move panel with the special information.
     *
     * @param refactorInfo
     *         information about the move operation
     */
public void show(final RefactorInfo refactorInfo) {
    this.refactorInfo = refactorInfo;
    view.setEnablePreviewButton(false);
    view.setEnableAcceptButton(false);
    view.clearErrorLabel();
    CreateMoveRefactoring moveRefactoring = createMoveDto();
    Promise<String> sessionIdPromise = refactorService.createMoveRefactoring(moveRefactoring);
    sessionIdPromise.then(new Operation<String>() {

        @Override
        public void apply(String sessionId) throws OperationException {
            MovePresenter.this.refactoringSessionId = sessionId;
            showProjectsAndPackages();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), Status.FAIL, FLOAT_MODE);
        }
    });
}
Also used : CreateMoveRefactoring(org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateMoveRefactoring) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 72 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class MovePresenter method onPreviewButtonClicked.

/** {@inheritDoc} */
@Override
public void onPreviewButtonClicked() {
    RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
    session.setSessionId(refactoringSessionId);
    prepareMovingChanges(session).then(new Operation<ChangeCreationResult>() {

        @Override
        public void apply(ChangeCreationResult arg) throws OperationException {
            if (arg.isCanShowPreviewPage()) {
                previewPresenter.show(refactoringSessionId, refactorInfo);
                view.hide();
            } else {
                view.showStatusMessage(arg.getStatus());
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(locale.showPreviewError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) RefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringSession) ChangeCreationResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 73 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class MovePresenter method setMoveDestinationPath.

/** {@inheritDoc} */
@Override
public void setMoveDestinationPath(String path, String projectPath) {
    ReorgDestination destination = dtoFactory.createDto(ReorgDestination.class);
    destination.setType(ReorgDestination.DestinationType.PACKAGE);
    destination.setSessionId(refactoringSessionId);
    destination.setProjectPath(projectPath);
    destination.setDestination(path);
    Promise<RefactoringStatus> promise = refactorService.setDestination(destination);
    promise.then(new Operation<RefactoringStatus>() {

        @Override
        public void apply(RefactoringStatus arg) throws OperationException {
            view.setEnableAcceptButton(true);
            view.setEnablePreviewButton(true);
            switch(arg.getSeverity()) {
                case INFO:
                    view.showStatusMessage(arg);
                    break;
                case WARNING:
                    view.showStatusMessage(arg);
                    break;
                case ERROR:
                    showErrorMessage(arg);
                    break;
                case FATAL:
                    showErrorMessage(arg);
                    break;
                case OK:
                default:
                    view.clearStatusMessage();
                    break;
            }
        }
    });
}
Also used : RefactoringStatus(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringStatus) ReorgDestination(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ReorgDestination) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 74 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class MovePresenter method showProjectsAndPackages.

private void showProjectsAndPackages() {
    Promise<List<JavaProject>> projectsPromise = navigationService.getProjectsAndPackages(true);
    projectsPromise.then(new Operation<List<JavaProject>>() {

        @Override
        public void apply(List<JavaProject> projects) throws OperationException {
            List<JavaProject> currentProject = new ArrayList<>();
            for (JavaProject project : projects) {
                currentProject.add(project);
            }
            view.setTreeOfDestinations(currentProject);
            view.show(refactorInfo);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(locale.showPackagesError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
        }
    });
}
Also used : JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 75 with OperationException

use of org.eclipse.che.api.promises.client.OperationException in project che by eclipse.

the class PreviewPresenter method onEnabledStateChanged.

/** {@inheritDoc} */
@Override
public void onEnabledStateChanged(final RefactoringPreview change) {
    ChangeEnabledState changeEnableState = dtoFactory.createDto(ChangeEnabledState.class);
    changeEnableState.setChangeId(change.getId());
    changeEnableState.setSessionId(session.getSessionId());
    changeEnableState.setEnabled(change.isEnabled());
    refactoringService.changeChangeEnabledState(changeEnableState).then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            onSelectionChanged(change);
        }
    });
}
Also used : ChangeEnabledState(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeEnabledState) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

OperationException (org.eclipse.che.api.promises.client.OperationException)158 PromiseError (org.eclipse.che.api.promises.client.PromiseError)123 Operation (org.eclipse.che.api.promises.client.Operation)115 Project (org.eclipse.che.ide.api.resources.Project)53 Resource (org.eclipse.che.ide.api.resources.Resource)48 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)21 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 List (java.util.List)19 Promise (org.eclipse.che.api.promises.client.Promise)17 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)15 Path (org.eclipse.che.ide.resource.Path)15 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)14 ArrayList (java.util.ArrayList)13 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)12 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 Optional (com.google.common.base.Optional)10 HashMap (java.util.HashMap)10 File (org.eclipse.che.ide.api.resources.File)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10