use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelViewImpl method focusGained.
@Override
public void focusGained(SubPanel subPanel, IsWidget widget) {
focusedSubPanel = subPanel;
final ProcessTreeNode processTreeNode = widget2TreeNodes.get(widget);
if (processTreeNode != null) {
selectNode(processTreeNode);
}
if (lastFosuced != null && !lastFosuced.equals(widget)) {
lastFosuced.setFocus(false);
}
if (widget instanceof Focusable) {
((Focusable) widget).setFocus(true);
lastFosuced = (Focusable) widget;
}
}
use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelPresenter method onMachineDestroyed.
@Override
public void onMachineDestroyed(MachineStateEvent event) {
machines.remove(event.getMachineId());
ProcessTreeNode destroyedMachineNode = machineNodes.get(event.getMachineId());
if (destroyedMachineNode == null) {
return;
}
rootNode.getChildren().remove(destroyedMachineNode);
view.setProcessesData(rootNode);
final Collection<ProcessTreeNode> children = new ArrayList<>();
children.addAll(destroyedMachineNode.getChildren());
for (ProcessTreeNode child : children) {
if (TERMINAL_NODE.equals(child.getType()) && terminals.containsKey(child.getId())) {
onCloseTerminal(child);
} else if (COMMAND_NODE.equals(child.getType()) && consoles.containsKey(child.getId())) {
onStopCommandProcess(child);
view.hideProcessOutput(child.getId());
}
}
view.hideProcessOutput(destroyedMachineNode.getId());
}
use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelPresenter method provideMachineNode.
/**
* Provides machine node:
* <li>creates new machine node when this one not exist or {@code replace} is {@code true}</li>
* <li>returns old machine node when this one exist and {@code replace} is {@code false}</li>
*
* @param machine
* machine to creating node
* @param replace
* existed node will be replaced when {@code replace} is {@code true}
* @return machine node
*/
private ProcessTreeNode provideMachineNode(@NotNull MachineEntity machine, boolean replace) {
final String machineId = machine.getId();
final ProcessTreeNode existedMachineNode = findProcessTreeNodeById(machineId);
if (!replace && existedMachineNode != null) {
return existedMachineNode;
}
// remove existed node
for (ProcessTreeNode node : rootNode.getChildren()) {
if (machine.getConfig().getName().equals(node.getName())) {
rootNode.getChildren().remove(node);
break;
}
}
// create new node
final ProcessTreeNode newMachineNode = new ProcessTreeNode(MACHINE_NODE, rootNode, machine, null, new ArrayList<ProcessTreeNode>());
newMachineNode.setRunning(true);
newMachineNode.setHasTerminalAgent(hasAgent(machine.getDisplayName(), TERMINAL_AGENT) || hasTerminal(machineId));
newMachineNode.setHasSSHAgent(hasAgent(machine.getDisplayName(), SSH_AGENT));
machineNodes.put(machineId, newMachineNode);
// add to children
rootNode.getChildren().add(newMachineNode);
// update the view
view.setProcessesData(rootNode);
// add output for the machine if it is not exist
if (!consoles.containsKey(machine.getConfig().getName())) {
OutputConsole outputConsole = commandConsoleFactory.create(machine.getConfig().getName());
addOutputConsole(machine.getConfig().getName(), newMachineNode, outputConsole, true);
}
return newMachineNode;
}
use of org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode 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.extension.machine.client.processes.ProcessTreeNode in project che by eclipse.
the class ProcessesPanelPresenter method addOutputConsole.
private void addOutputConsole(final String id, final ProcessTreeNode processNode, final OutputConsole outputConsole, final boolean machineConsole) {
consoles.put(id, outputConsole);
consoleCommands.put(outputConsole, id);
outputConsole.go(new AcceptsOneWidget() {
@Override
public void setWidget(final IsWidget widget) {
view.addProcessNode(processNode);
view.addWidget(id, outputConsole.getTitle(), outputConsole.getTitleIcon(), widget, machineConsole);
if (!MACHINE_NODE.equals(processNode.getType())) {
ProcessTreeNode node = view.getNodeById(id);
view.selectNode(node);
notifyTreeNodeSelected(node);
}
}
});
outputConsole.addActionDelegate(this);
}
Aggregations