use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class SshCategoryPresenter method onConnectClicked.
@Override
public void onConnectClicked() {
if (selectedTarget == null) {
return;
}
if (selectedTarget.isConnected()) {
final MachineEntity machine = this.getMachineByName(selectedTarget.getName());
disconnect(machine);
return;
}
if (selectedTarget.getRecipe() == null) {
this.sshView.enableConnectButton(false);
return;
}
connect();
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class ProcessesPanelPresenter method updateMachineList.
/**
* Updates list of the machines from application context.
*/
public void updateMachineList() {
if (appContext.getWorkspace() == null) {
return;
}
List<MachineEntity> machines = getMachines(appContext.getWorkspace());
if (machines.isEmpty()) {
return;
}
ProcessTreeNode machineToSelect = null;
for (MachineEntity machine : machines) {
if (machine.isDev()) {
provideMachineNode(machine, true);
machines.remove(machine);
break;
}
}
for (MachineEntity machine : machines) {
provideMachineNode(machine, true);
}
if (machineToSelect == null) {
machineToSelect = machineNodes.entrySet().iterator().next().getValue();
}
view.selectNode(machineToSelect);
notifyTreeNodeSelected(machineToSelect);
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class ProcessesPanelPresenter method onAddTerminal.
/**
* Adds new terminal to the processes panel
*
* @param machineId
* id of machine in which the terminal will be added
*/
@Override
public void onAddTerminal(final String machineId, Object source) {
final MachineEntity machine = getMachine(machineId);
if (machine == null) {
notificationManager.notify(localizationConstant.failedToConnectTheTerminal(), localizationConstant.machineNotFound(machineId), FAIL, FLOAT_MODE);
Log.error(getClass(), localizationConstant.machineNotFound(machineId));
return;
}
final ProcessTreeNode machineTreeNode = provideMachineNode(machine, false);
final TerminalPresenter newTerminal = terminalFactory.create(machine, source);
final IsWidget terminalWidget = newTerminal.getView();
final String terminalName = getUniqueTerminalName(machineTreeNode);
final ProcessTreeNode terminalNode = new ProcessTreeNode(TERMINAL_NODE, machineTreeNode, terminalName, resources.terminalTreeIcon(), null);
addChildToMachineNode(terminalNode, machineTreeNode);
final String terminalId = terminalNode.getId();
terminals.put(terminalId, newTerminal);
view.addProcessNode(terminalNode);
terminalWidget.asWidget().ensureDebugId(terminalName);
view.addWidget(terminalId, terminalName, terminalNode.getTitleIcon(), terminalWidget, false);
refreshStopButtonState(terminalId);
workspaceAgent.setActivePart(this);
newTerminal.setVisible(true);
newTerminal.connect();
newTerminal.setListener(new TerminalPresenter.TerminalStateListener() {
@Override
public void onExit() {
String terminalId = terminalNode.getId();
if (terminals.containsKey(terminalId)) {
onStopProcess(terminalNode);
terminals.remove(terminalId);
}
view.hideProcessOutput(terminalId);
}
});
}
use of org.eclipse.che.ide.api.machine.MachineEntity 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.ide.api.machine.MachineEntity in project che by eclipse.
the class ProcessesPanelPresenter method selectDevMachine.
/**
* Selects dev machine.
*/
public void selectDevMachine() {
for (final ProcessTreeNode processTreeNode : machineNodes.values()) {
if (processTreeNode.getData() instanceof MachineEntity) {
if (((MachineEntity) processTreeNode.getData()).isDev()) {
view.selectNode(processTreeNode);
notifyTreeNodeSelected(processTreeNode);
}
}
}
}
Aggregations