Search in sources :

Example 6 with DevMachine

use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.

the class ComparePresenter method showCompareBetweenRevisions.

/**
     *
     * @param file
     *         path of the file
     * @param status
     *         status of the file
     * @param revisionA
     *         hash of the first revision or branch.
     *         If it is set to {@code null}, compare with empty repository state will be performed
     * @param revisionB
     *         hash of the second revision or branch.
     *         If it is set to {@code null}, compare with latest repository state will be performed
     */
public void showCompareBetweenRevisions(final Path file, final Status status, @Nullable final String revisionA, @Nullable final String revisionB) {
    this.compareWithLatest = false;
    final DevMachine devMachine = appContext.getDevMachine();
    final Path projectLocation = appContext.getRootProject().getLocation();
    view.setTitle(file.toString());
    if (status == Status.ADDED) {
        service.showFileContent(devMachine, projectLocation, file, revisionB).then(new Operation<ShowFileContentResponse>() {

            @Override
            public void apply(ShowFileContentResponse response) throws OperationException {
                view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA == null ? "" : revisionA + locale.compareReadOnlyTitle());
                view.show("", response.getContent(), file.toString(), true);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError error) throws OperationException {
                notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
            }
        });
    } else if (status == Status.DELETED) {
        service.showFileContent(devMachine, projectLocation, file, revisionA).then(new Operation<ShowFileContentResponse>() {

            @Override
            public void apply(ShowFileContentResponse response) throws OperationException {
                view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA + locale.compareReadOnlyTitle());
                view.show(response.getContent(), "", file.toString(), true);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError error) throws OperationException {
                notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
            }
        });
    } else {
        service.showFileContent(devMachine, projectLocation, file, revisionA).then(new Operation<ShowFileContentResponse>() {

            @Override
            public void apply(final ShowFileContentResponse contentAResponse) throws OperationException {
                service.showFileContent(devMachine, projectLocation, file, revisionB).then(new Operation<ShowFileContentResponse>() {

                    @Override
                    public void apply(ShowFileContentResponse contentBResponse) throws OperationException {
                        view.setColumnTitles(revisionB + locale.compareReadOnlyTitle(), revisionA + locale.compareReadOnlyTitle());
                        view.show(contentAResponse.getContent(), contentBResponse.getContent(), file.toString(), true);
                    }
                }).catchError(new Operation<PromiseError>() {

                    @Override
                    public void apply(PromiseError error) throws OperationException {
                        notificationManager.notify(error.getMessage(), FAIL, NOT_EMERGE_MODE);
                    }
                });
            }
        });
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) DevMachine(org.eclipse.che.ide.api.machine.DevMachine) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ShowFileContentResponse(org.eclipse.che.api.git.shared.ShowFileContentResponse) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 7 with DevMachine

use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.

the class AbstractServerMacro method registerProviders.

/**
     * Register macro providers which returns the implementation.
     *
     * @see AbstractServerMacro#getMacros(DevMachine)
     * @since 4.7.0
     */
private void registerProviders() {
    final DevMachine devMachine = appContext.getDevMachine();
    if (devMachine == null) {
        return;
    }
    final Set<Macro> providers = getMacros(devMachine);
    checkNotNull(providers);
    if (providers.isEmpty()) {
        return;
    }
    providerRegistry.register(providers);
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Macro(org.eclipse.che.ide.api.macro.Macro)

Example 8 with DevMachine

use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.

the class ProcessesPanelPresenterTest method setUp.

@Before
public void setUp() {
    DevMachine devMachine = mock(DevMachine.class);
    when(devMachine.getId()).thenReturn(WORKSPACE_ID);
    when(appContext.getDevMachine()).thenReturn(devMachine);
    when(appContext.getWorkspace()).thenReturn(workspace);
    when(workspace.getRuntime()).thenReturn(workspaceRuntime);
    when(processesPromise.then(Matchers.<Operation<List<MachineProcessDto>>>anyObject())).thenReturn(processesPromise);
    when(commandConsoleFactory.create(anyString())).thenReturn(mock(OutputConsole.class));
    when(appContext.getWorkspaceId()).thenReturn(WORKSPACE_ID);
    when(workspaceAgent.getPartStack(eq(PartStackType.INFORMATION))).thenReturn(partStack);
    when(execAgentCommandManager.getProcesses(anyString(), anyBoolean())).thenReturn(promise);
    when(promise.then(any(Operation.class))).thenReturn(promise);
    presenter = new ProcessesPanelPresenter(view, localizationConstant, resources, eventBus, workspaceAgent, appContext, notificationManager, entityFactory, terminalFactory, commandConsoleFactory, dialogFactory, consoleTreeContextMenuFactory, commandTypeRegistry, sshService, execAgentCommandManager, macroProcessor, dtoFactory);
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine) CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OutputConsole(org.eclipse.che.ide.api.outputconsole.OutputConsole) List(java.util.List) ArrayList(java.util.ArrayList) Operation(org.eclipse.che.api.promises.client.Operation) Before(org.junit.Before)

Example 9 with DevMachine

use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.

the class StopWorkspaceActionTest method actionShouldBePerformed.

@Test
public void actionShouldBePerformed() throws Exception {
    when(workspaceService.stop(anyString())).thenReturn(voidPromise);
    DevMachine devMachine = mock(DevMachine.class);
    when(devMachine.getId()).thenReturn("id");
    when(appContext.getWorkspace()).thenReturn(workspace);
    when(workspace.getId()).thenReturn("id");
    action.actionPerformed(actionEvent);
    verify(workspaceService).stop("id");
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine) Test(org.junit.Test)

Example 10 with DevMachine

use of org.eclipse.che.ide.api.machine.DevMachine in project che by eclipse.

the class BootstrapController method startWsAgentComponents.

@Inject
private void startWsAgentComponents(EventBus eventBus, final Map<String, Provider<WsAgentComponent>> components) {
    eventBus.addHandler(WorkspaceStartedEvent.TYPE, new WorkspaceStartedEvent.Handler() {

        @Override
        public void onWorkspaceStarted(WorkspaceStartedEvent event) {
            workspaceService.getWorkspace(event.getWorkspace().getId()).then(new Operation<WorkspaceDto>() {

                @Override
                public void apply(WorkspaceDto ws) throws OperationException {
                    MachineDto devMachineDto = ws.getRuntime().getDevMachine();
                    DevMachine devMachine = new DevMachine(devMachineDto);
                    if (appContext instanceof AppContextImpl) {
                        ((AppContextImpl) appContext).setProjectsRoot(Path.valueOf(devMachineDto.getRuntime().projectsRoot()));
                    }
                    wsAgentStateControllerProvider.get().initialize(devMachine);
                    wsAgentURLModifier.initialize(devMachine);
                    SortedMap<String, Provider<WsAgentComponent>> sortedComponents = new TreeMap<>();
                    sortedComponents.putAll(components);
                    startWsAgentComponents(sortedComponents.values().iterator());
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError err) throws OperationException {
                    Log.error(getClass(), err.getCause());
                    initializationFailed(err.getMessage());
                }
            });
        }
    });
}
Also used : DevMachine(org.eclipse.che.ide.api.machine.DevMachine) WorkspaceStartedEvent(org.eclipse.che.ide.api.workspace.event.WorkspaceStartedEvent) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Operation(org.eclipse.che.api.promises.client.Operation) AppContextImpl(org.eclipse.che.ide.context.AppContextImpl) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) PromiseError(org.eclipse.che.api.promises.client.PromiseError) SortedMap(java.util.SortedMap) WsAgentComponent(org.eclipse.che.ide.api.component.WsAgentComponent) OperationException(org.eclipse.che.api.promises.client.OperationException) Inject(com.google.inject.Inject)

Aggregations

DevMachine (org.eclipse.che.ide.api.machine.DevMachine)15 Operation (org.eclipse.che.api.promises.client.Operation)5 Before (org.junit.Before)5 OperationException (org.eclipse.che.api.promises.client.OperationException)4 PromiseError (org.eclipse.che.api.promises.client.PromiseError)4 Path (org.eclipse.che.ide.resource.Path)4 Test (org.junit.Test)4 List (java.util.List)3 Inject (com.google.inject.Inject)2 ArrayList (java.util.ArrayList)2 Machine (org.eclipse.che.api.core.model.machine.Machine)2 AppContext (org.eclipse.che.ide.api.app.AppContext)2 ProcessesPanelPresenter (org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 Singleton (com.google.inject.Singleton)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1