use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.
the class SelectCommandComboBox method updateMachineActions.
private void updateMachineActions() {
machinesActions.removeAll();
final DefaultActionGroup actionList = (DefaultActionGroup) actionManager.getAction(GROUP_MACHINES_LIST);
if (actionList != null) {
machinesActions.addAll(actionList);
}
if (registeredMachineMap.isEmpty()) {
return;
}
final List<Map.Entry<String, Machine>> machineEntryList = new LinkedList(registeredMachineMap.entrySet());
// defined MachineDto Comparator here
Collections.sort(machineEntryList, new MachineListEntryComparator());
String machineCategory = null;
for (Map.Entry<String, Machine> machineEntry : machineEntryList) {
final Machine machine = machineEntry.getValue();
final MachineConfig machineConfig = machine.getConfig();
if (!this.getMachineCategory(machineConfig).equals(machineCategory)) {
machineCategory = this.getMachineCategory(machineConfig);
machinesActions.addSeparator(machineCategory);
}
machinesActions.add(machinesListWidget.createAction(machine.getId(), machineConfig.getName()));
}
machinesListWidget.updatePopup();
if (machinesListWidget.getSelectedName() == null && machinesActions.getChildrenCount() > 0) {
Machine firstMachine = machineEntryList.get(0).getValue();
if (firstMachine == null) {
return;
}
machinesListWidget.selectElement(firstMachine.getId(), firstMachine.getConfig().getName());
}
}
use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.
the class SelectCommandComboBox method onMachineRunning.
@Override
public void onMachineRunning(MachineStateEvent event) {
Machine machine = event.getMachine();
addMachineAction(machine);
}
use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.
the class ProcessesPanelPresenter method getMachines.
private List<MachineEntity> getMachines(Workspace workspace) {
WorkspaceRuntime workspaceRuntime = workspace.getRuntime();
if (workspaceRuntime == null) {
return emptyList();
}
List<? extends Machine> runtimeMachines = workspaceRuntime.getMachines();
List<MachineEntity> machines = new ArrayList<>(runtimeMachines.size());
for (Machine machine : runtimeMachines) {
if (machine instanceof MachineDto) {
MachineEntity machineEntity = entityFactory.createMachine((MachineDto) machine);
machines.add(machineEntity);
}
}
return machines;
}
use of org.eclipse.che.api.core.model.machine.Machine in project che by eclipse.
the class DevelopmentCategoryPresenter method onRestoreTargetFields.
@Override
public boolean onRestoreTargetFields(DevelopmentMachineTarget target) {
if (target == null) {
return false;
}
final Machine machine = this.getMachineByName(target.getName());
if (machine == null) {
return false;
}
target.setOwner(machine.getOwner());
target.setType(machine.getConfig().getType());
target.setSourceType(machine.getConfig().getSource().getType());
target.setSourceContent(machine.getConfig().getSource().getContent());
target.setSource(machine.getConfig().getSource().getLocation());
return true;
}
use of org.eclipse.che.api.core.model.machine.Machine 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)));
}
});
}
});
}
});
});
}
Aggregations