Search in sources :

Example 16 with MachineEntity

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

the class MachinePanelPresenter method showMachines.

private void showMachines(Workspace workspace) {
    List<MachineEntity> machines = getMachines(workspace);
    machineNodes.clear();
    if (machines.isEmpty()) {
        appliance.showStub(locale.unavailableMachineInfo());
        return;
    }
    for (MachineEntity machine : machines) {
        addNodeToTree(machine);
    }
    view.setData(rootNode);
    selectFirstNode();
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity)

Example 17 with MachineEntity

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

the class JsonRpcWebSocketAgentEventListener method internalInitialize.

private void internalInitialize() {
    DevMachine devMachine = appContext.getDevMachine();
    String devMachineId = devMachine.getId();
    String wsAgentWebSocketUrl = devMachine.getWsAgentWebSocketUrl();
    String wsAgentUrl = wsAgentWebSocketUrl.replaceFirst("(api)(/)(ws)", "websocket" + "$2" + ENDPOINT_ID);
    String execAgentUrl = devMachine.getExecAgentUrl();
    initializer.initialize("ws-agent", singletonMap("url", wsAgentUrl));
    initializer.initialize(devMachineId, singletonMap("url", execAgentUrl));
    for (MachineEntity machineEntity : appContext.getActiveRuntime().getMachines()) {
        if (!machineEntity.isDev()) {
            initializer.initialize(machineEntity.getId(), singletonMap("url", machineEntity.getExecAgentUrl()));
        }
    }
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) DevMachine(org.eclipse.che.ide.api.machine.DevMachine)

Example 18 with MachineEntity

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

the class ProcessesPanelPresenterTest method shouldHideStopProcessButtonAtAddingTerminal.

@Test
public void shouldHideStopProcessButtonAtAddingTerminal() throws Exception {
    MachineDto machineDto = mock(MachineDto.class);
    MachineEntity machine = mock(MachineEntity.class);
    when(machine.getId()).thenReturn(MACHINE_ID);
    MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
    when(machine.getConfig()).thenReturn(machineConfigDto);
    when(machineConfigDto.isDev()).thenReturn(true);
    when(machine.getStatus()).thenReturn(MachineStatus.RUNNING);
    List<MachineDto> machines = new ArrayList<>(1);
    machines.add(machineDto);
    when(workspaceRuntime.getMachines()).thenReturn(machines);
    when(entityFactory.createMachine(machineDto)).thenReturn(machine);
    ProcessTreeNode machineNode = mock(ProcessTreeNode.class);
    when(machineNode.getId()).thenReturn(MACHINE_ID);
    List<ProcessTreeNode> children = new ArrayList<>();
    children.add(machineNode);
    presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
    TerminalPresenter terminal = mock(TerminalPresenter.class);
    when(terminalFactory.create(machine, presenter)).thenReturn(terminal);
    IsWidget terminalWidget = mock(IsWidget.class);
    when(terminal.getView()).thenReturn(terminalWidget);
    when(terminalWidget.asWidget()).thenReturn(widget);
    presenter.addCommandOutput(MACHINE_ID, outputConsole);
    presenter.onAddTerminal(MACHINE_ID, presenter);
    verify(terminalFactory).create(eq(machine), eq(presenter));
    verify(terminal).getView();
    verify(view, times(2)).setProcessesData(anyObject());
    verify(view, times(2)).selectNode(anyObject());
    verify(view).addWidget(anyString(), anyString(), anyObject(), eq(terminalWidget), anyBoolean());
    verify(view, times(1)).addProcessNode(anyObject());
    verify(terminal).setVisible(eq(true));
    verify(terminal).connect();
    verify(terminal).setListener(anyObject());
    verify(view).setStopButtonVisibility(anyString(), eq(false));
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) IsWidget(com.google.gwt.user.client.ui.IsWidget) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) ArrayList(java.util.ArrayList) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) TerminalPresenter(org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter) Test(org.junit.Test)

Example 19 with MachineEntity

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

the class TargetsPresenter method updateTargets.

/**
     * Fetches all recipes from the server, makes a list of targets and selects specified target.
     */
@Override
public void updateTargets(final String preselectTargetName) {
    targets.clear();
    machines.clear();
    getMachines(appContext.getWorkspaceId()).then(new Operation<List<MachineEntity>>() {

        @Override
        public void apply(List<MachineEntity> machineList) throws OperationException {
            //create Target objects from all machines
            for (MachineEntity machine : machineList) {
                final MachineConfig machineConfig = machine.getConfig();
                machines.put(machineConfig.getName(), machine);
                final String targetCategory = machineConfig.isDev() ? machineLocale.devMachineCategory() : machineConfig.getType();
                final Target target = createTarget(machineConfig.getName(), targetCategory);
                target.setConnected(isMachineRunning(machine));
                targets.put(target.getName(), target);
            }
            //create Target objects from recipe with ssh type
            recipeServiceClient.getAllRecipes().then(new Operation<List<RecipeDescriptor>>() {

                @Override
                public void apply(List<RecipeDescriptor> recipeList) throws OperationException {
                    for (RecipeDescriptor recipe : recipeList) {
                        //only for SSH recipes
                        if (!machineLocale.targetsViewCategorySsh().equalsIgnoreCase(recipe.getType())) {
                            continue;
                        }
                        Target target = targets.get(recipe.getName());
                        if (target == null) {
                            target = createTarget(recipe.getName(), recipe.getType());
                        }
                        target.setRecipe(recipe);
                        categoryPageRegistry.getCategoryPage(target.getCategory()).getTargetManager().restoreTarget(target);
                        targets.put(target.getName(), target);
                    }
                    view.showTargets(new ArrayList<>(targets.values()));
                    selectTarget(preselectTargetName == null ? selectedTarget : targets.get(preselectTargetName));
                }
            });
        }
    });
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) MachineConfig(org.eclipse.che.api.core.model.machine.MachineConfig) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Operation(org.eclipse.che.api.promises.client.Operation) RecipeDescriptor(org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 20 with MachineEntity

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

the class ProcessesPanelPresenter method onWsAgentStarted.

@Override
public void onWsAgentStarted(WsAgentStateEvent event) {
    List<MachineEntity> machines = getMachines(appContext.getWorkspace());
    if (machines.isEmpty()) {
        return;
    }
    for (MachineEntity machine : machines) {
        restoreState(machine);
    }
    selectDevMachine();
    newTerminal(this);
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity)

Aggregations

MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)23 ArrayList (java.util.ArrayList)8 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)8 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)5 Test (org.junit.Test)5 Machine (org.eclipse.che.api.core.model.machine.Machine)3 WorkspaceRuntime (org.eclipse.che.api.core.model.workspace.WorkspaceRuntime)3 MachineStateEvent (org.eclipse.che.ide.api.machine.events.MachineStateEvent)3 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)3 MachineConfig (org.eclipse.che.api.core.model.machine.MachineConfig)2 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)2 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)2 Element (elemental.dom.Element)1 Node (elemental.dom.Node)1 Event (elemental.events.Event)1 EventListener (elemental.events.EventListener)1 DivElement (elemental.html.DivElement)1 SpanElement (elemental.html.SpanElement)1