Search in sources :

Example 26 with ProcessTreeNode

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;
    }
}
Also used : Focusable(com.google.gwt.user.client.ui.Focusable) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 27 with ProcessTreeNode

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());
}
Also used : ArrayList(java.util.ArrayList) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 28 with ProcessTreeNode

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;
}
Also used : CommandOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole) OutputConsole(org.eclipse.che.ide.api.outputconsole.OutputConsole) DefaultOutputConsole(org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 29 with ProcessTreeNode

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);
        }
    }
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)

Example 30 with ProcessTreeNode

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);
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) ProcessTreeNode(org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode) AcceptsOneWidget(com.google.gwt.user.client.ui.AcceptsOneWidget)

Aggregations

ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)36 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)12 IsWidget (com.google.gwt.user.client.ui.IsWidget)8 MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)8 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)5 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)3 OutputConsole (org.eclipse.che.ide.api.outputconsole.OutputConsole)3 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)3 SubPanel (org.eclipse.che.ide.ui.multisplitpanel.SubPanel)3 Machine (org.eclipse.che.api.core.model.machine.Machine)2 ExtendedMachine (org.eclipse.che.api.core.model.workspace.ExtendedMachine)2 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 CommandOutputConsolePresenter (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsolePresenter)2 DefaultOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.DefaultOutputConsole)2 WidgetToShow (org.eclipse.che.ide.ui.multisplitpanel.WidgetToShow)2 AcceptsOneWidget (com.google.gwt.user.client.ui.AcceptsOneWidget)1 Focusable (com.google.gwt.user.client.ui.Focusable)1 Date (java.util.Date)1