Search in sources :

Example 6 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class NotificationManagerImplTest method testShowStatusNotificationOnlyInEventsPanel.

@Test
public void testShowStatusNotificationOnlyInEventsPanel() throws Exception {
    StatusNotification notification = new StatusNotification("Title", "Message", SUCCESS, NOT_EMERGE_MODE, null, null);
    manager.notify(notification);
    verify(notificationContainer).addNotification(eq(notification));
    verify(notificationMessageStack, never()).push(any(StatusNotification.class));
}
Also used : StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Test(org.junit.Test)

Example 7 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class PullPresenter method onPullClicked.

/** {@inheritDoc} */
@Override
public void onPullClicked() {
    view.close();
    final StatusNotification notification = notificationManager.notify(constant.pullProcess(), PROGRESS, FLOAT_MODE);
    service.pull(appContext.getDevMachine(), project.getLocation(), getRefs(), view.getRepositoryName()).then(new Operation<PullResponse>() {

        @Override
        public void apply(PullResponse response) throws OperationException {
            GitOutputConsole console = gitOutputConsoleFactory.create(PULL_COMMAND_NAME);
            console.print(response.getCommandOutput(), GREEN_COLOR);
            consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notification.setStatus(SUCCESS);
            if (response.getCommandOutput().contains("Already up-to-date")) {
                notification.setTitle(constant.pullUpToDate());
            } else {
                project.synchronize();
                notification.setTitle(constant.pullSuccess(view.getRepositoryUrl()));
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notification.setStatus(FAIL);
            if (getErrorCode(error.getCause()) == ErrorCodes.MERGE_CONFLICT) {
                project.synchronize();
            }
            handleError(error.getCause(), PULL_COMMAND_NAME);
        }
    });
}
Also used : PullResponse(org.eclipse.che.api.git.shared.PullResponse) 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 8 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class PushToRemotePresenter method onPushClicked.

/** {@inheritDoc} */
@Override
public void onPushClicked() {
    final StatusNotification notification = notificationManager.notify(constant.pushProcess(), PROGRESS, FLOAT_MODE);
    final String repository = view.getRepository();
    final GitOutputConsole console = gitOutputConsoleFactory.create(PUSH_COMMAND_NAME);
    service.push(appContext.getDevMachine(), project.getLocation(), getRefs(), repository, false).then(new Operation<PushResponse>() {

        @Override
        public void apply(PushResponse response) throws OperationException {
            console.print(response.getCommandOutput());
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notification.setStatus(SUCCESS);
            if (response.getCommandOutput().contains("Everything up-to-date")) {
                notification.setTitle(constant.pushUpToDate());
            } else {
                notification.setTitle(constant.pushSuccess(repository));
            }
        }
    }).catchError(new Operation<PromiseError>() {

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

Example 9 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification in project che by eclipse.

the class TestServiceClient method runTestsAfterCompilation.

Promise<TestResult> runTestsAfterCompilation(String projectPath, String testFramework, Map<String, String> parameters, StatusNotification statusNotification, Promise<CommandImpl> compileCommand) {
    return compileCommand.thenPromise(command -> {
        final Machine machine;
        if (command == null) {
            machine = null;
        } else {
            machine = appContext.getDevMachine().getDescriptor();
        }
        if (machine == null) {
            if (statusNotification != null) {
                statusNotification.setContent("Executing the tests without preliminary compilation.");
            }
            return sendTests(projectPath, testFramework, parameters);
        }
        if (statusNotification != null) {
            statusNotification.setContent("Compiling the project before starting the test session.");
        }
        return promiseFromExecutorBody(new ExecutorBody<TestResult>() {

            boolean compiled = false;

            @Override
            public void apply(final ResolveFunction<TestResult> resolve, RejectFunction reject) {
                macroProcessor.expandMacros(command.getCommandLine()).then(new Operation<String>() {

                    @Override
                    public void apply(String expandedCommandLine) throws OperationException {
                        CommandImpl expandedCommand = new CommandImpl(command.getName(), expandedCommandLine, command.getType(), command.getAttributes());
                        final CommandOutputConsole console = commandConsoleFactory.create(expandedCommand, machine);
                        final String machineId = machine.getId();
                        processesPanelPresenter.addCommandOutput(machineId, console);
                        execAgentCommandManager.startProcess(machineId, expandedCommand).then(startResonse -> {
                            if (!startResonse.getAlive()) {
                                reject.apply(promiseFromThrowable(new Throwable(PROJECT_BUILD_NOT_STARTED_MESSAGE)));
                            }
                        }).thenIfProcessStartedEvent(console.getProcessStartedOperation()).thenIfProcessStdErrEvent(evt -> {
                            if (evt.getText().contains("BUILD SUCCESS")) {
                                compiled = true;
                            }
                            console.getStdErrOperation().apply(evt);
                        }).thenIfProcessStdOutEvent(evt -> {
                            if (evt.getText().contains("BUILD SUCCESS")) {
                                compiled = true;
                            }
                            console.getStdOutOperation().apply(evt);
                        }).thenIfProcessDiedEvent(evt -> {
                            console.getProcessDiedOperation().apply(evt);
                            if (compiled) {
                                if (statusNotification != null) {
                                    statusNotification.setContent(EXECUTING_TESTS_MESSAGE);
                                }
                                sendTests(projectPath, testFramework, parameters).then(new Operation<TestResult>() {

                                    @Override
                                    public void apply(TestResult result) throws OperationException {
                                        resolve.apply(result);
                                    }
                                });
                            } else {
                                reject.apply(promiseFromThrowable(new Throwable(PROJECT_BUILD_FAILED_MESSAGE)));
                            }
                        });
                    }
                });
            }
        });
    });
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) CommandManager(org.eclipse.che.ide.api.command.CommandManager) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) AsyncRequestFactory(org.eclipse.che.ide.rest.AsyncRequestFactory) JsPromiseError(org.eclipse.che.api.promises.client.js.JsPromiseError) CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) Inject(com.google.inject.Inject) HashMap(java.util.HashMap) Executor(org.eclipse.che.api.promises.client.js.Executor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Promise(org.eclipse.che.api.promises.client.Promise) ExecutorBody(org.eclipse.che.api.promises.client.js.Executor.ExecutorBody) AppContext(org.eclipse.che.ide.api.app.AppContext) Map(java.util.Map) RejectFunction(org.eclipse.che.api.promises.client.js.RejectFunction) URL(com.google.gwt.http.client.URL) HTTPHeader(org.eclipse.che.ide.rest.HTTPHeader) Operation(org.eclipse.che.api.promises.client.Operation) CommandConsoleFactory(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandConsoleFactory) DtoUnmarshallerFactory(org.eclipse.che.ide.rest.DtoUnmarshallerFactory) DtoFactory(org.eclipse.che.ide.dto.DtoFactory) OperationException(org.eclipse.che.api.promises.client.OperationException) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) PromiseProvider(org.eclipse.che.api.promises.client.PromiseProvider) MatchResult(com.google.gwt.regexp.shared.MatchResult) Machine(org.eclipse.che.api.core.model.machine.Machine) ExecAgentCommandManager(org.eclipse.che.ide.api.machine.ExecAgentCommandManager) List(java.util.List) MimeType(org.eclipse.che.ide.MimeType) TestResult(org.eclipse.che.api.testing.shared.TestResult) RegExp(com.google.gwt.regexp.shared.RegExp) ResolveFunction(org.eclipse.che.api.promises.client.js.ResolveFunction) MacroProcessor(org.eclipse.che.ide.api.macro.MacroProcessor) ProcessesPanelPresenter(org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter) Singleton(com.google.inject.Singleton) TestResult(org.eclipse.che.api.testing.shared.TestResult) Operation(org.eclipse.che.api.promises.client.Operation) Machine(org.eclipse.che.api.core.model.machine.Machine) RejectFunction(org.eclipse.che.api.promises.client.js.RejectFunction) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 10 with StatusNotification

use of org.eclipse.che.ide.api.notification.StatusNotification 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

StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)28 Operation (org.eclipse.che.api.promises.client.Operation)20 OperationException (org.eclipse.che.api.promises.client.OperationException)20 PromiseError (org.eclipse.che.api.promises.client.PromiseError)20 Project (org.eclipse.che.ide.api.resources.Project)12 Resource (org.eclipse.che.ide.api.resources.Resource)7 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)7 TestResult (org.eclipse.che.api.testing.shared.TestResult)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)5 Promise (org.eclipse.che.api.promises.client.Promise)4 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)3 NotificationListener (org.eclipse.che.ide.api.notification.NotificationListener)2 Credentials (org.eclipse.che.ide.api.subversion.Credentials)2 Path (org.eclipse.che.ide.resource.Path)2 Depth (org.eclipse.che.plugin.svn.shared.Depth)2 URL (com.google.gwt.http.client.URL)1 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 RegExp (com.google.gwt.regexp.shared.RegExp)1 Label (com.google.gwt.user.client.ui.Label)1