use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class ProcessesPanelPresenter method onWorkspaceStarted.
@Override
public void onWorkspaceStarted(WorkspaceStartedEvent event) {
List<MachineEntity> wsMachines = getMachines(event.getWorkspace());
if (wsMachines.isEmpty()) {
return;
}
MachineEntity devMachine = null;
for (MachineEntity machineEntity : wsMachines) {
if (machineEntity.isDev()) {
devMachine = machineEntity;
break;
}
}
ProcessTreeNode machineToSelect = null;
if (devMachine != null) {
machineToSelect = provideMachineNode(devMachine, true);
wsMachines.remove(devMachine);
}
for (MachineEntity machine : wsMachines) {
provideMachineNode(machine, true);
}
if (machineToSelect != null) {
view.selectNode(machineToSelect);
notifyTreeNodeSelected(machineToSelect);
} else if (!machineNodes.isEmpty()) {
machineToSelect = machineNodes.entrySet().iterator().next().getValue();
view.selectNode(machineToSelect);
notifyTreeNodeSelected(machineToSelect);
}
for (MachineEntity machine : machines.values()) {
if (RUNNING.equals(machine.getStatus()) && !wsMachines.contains(machine)) {
provideMachineNode(machine, true);
}
}
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class ProcessesPanelPresenter method hasTerminal.
/**
* Checks supporting of the terminal for machine which is running out the workspace runtime.
*
* @param machineId
* machine id
* @return
* <b>true</b> is the terminal url, otherwise return <b>false</b>
*/
private boolean hasTerminal(String machineId) {
List<MachineEntity> wsMachines = getMachines(appContext.getWorkspace());
for (MachineEntity machineEntity : wsMachines) {
if (machineId.equals(machineEntity.getId())) {
return false;
}
}
final MachineEntity machineEntity = machines.get(machineId);
return machineEntity != null && machineEntity.getServer(TERMINAL_REFERENCE) != null;
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class ProcessesPanelPresenterTest method shouldReplaceCommandOutput.
@Test
public void shouldReplaceCommandOutput() throws Exception {
MachineEntity machine = mock(MachineEntity.class);
when(machine.getId()).thenReturn(MACHINE_ID);
MachineConfigDto machineConfigDto = mock(MachineConfigDto.class);
when(machine.getConfig()).thenReturn(machineConfigDto);
List<ProcessTreeNode> children = new ArrayList<>();
ProcessTreeNode commandNode = new ProcessTreeNode(COMMAND_NODE, null, PROCESS_NAME, null, children);
children.add(commandNode);
ProcessTreeNode machineNode = new ProcessTreeNode(MACHINE_NODE, null, machine, null, children);
children.add(machineNode);
when(machineNode.getId()).thenReturn(MACHINE_ID);
String commandId = commandNode.getId();
presenter.rootNode = new ProcessTreeNode(ROOT_NODE, null, null, null, children);
presenter.consoles.put(commandId, outputConsole);
when(outputConsole.isFinished()).thenReturn(true);
when(outputConsole.getTitle()).thenReturn(PROCESS_NAME);
presenter.addCommandOutput(MACHINE_ID, outputConsole);
verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
IsWidget widget = mock(IsWidget.class);
acceptsOneWidgetCaptor.getValue().setWidget(widget);
verify(view).hideProcessOutput(eq(commandId));
verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
verify(view, times(2)).selectNode(anyObject());
verify(view).getNodeById(anyString());
}
Aggregations