use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class MachineStatusHandler method handleMachineRunning.
private void handleMachineRunning(final String machineId, final WorkspaceRuntimeDto workspaceRuntime) {
final MachineEntity machine = getMachine(machineId, workspaceRuntime);
if (machine == null) {
return;
}
eventBus.fireEvent(new MachineStateEvent(machine, RUNNING));
}
use of org.eclipse.che.ide.api.machine.MachineEntity in project che by eclipse.
the class ProcessesPanelPresenter method newTerminal.
/** Opens new terminal for the selected machine. */
public void newTerminal(Object source) {
final ProcessTreeNode selectedTreeNode = view.getSelectedTreeNode();
final MachineEntity devMachine = appContext.getDevMachine();
if (selectedTreeNode == null && devMachine != null) {
onAddTerminal(devMachine.getId(), source);
return;
}
if (selectedTreeNode == null) {
String notificationTitle = localizationConstant.failedToConnectTheTerminal();
String notificationContent = localizationConstant.machineNotFound("");
notificationManager.notify(notificationTitle, notificationContent, FAIL, FLOAT_MODE);
return;
}
if (selectedTreeNode.getType() == MACHINE_NODE) {
MachineEntity machine = (MachineEntity) selectedTreeNode.getData();
onAddTerminal(machine.getId(), source);
return;
}
ProcessTreeNode parent = selectedTreeNode.getParent();
if (parent != null && parent.getType() == MACHINE_NODE) {
MachineEntity machine = (MachineEntity) parent.getData();
onAddTerminal(machine.getId(), source);
}
}
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);
}
});
}
Aggregations