Search in sources :

Example 1 with MachineEntity

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));
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) MachineStateEvent(org.eclipse.che.ide.api.machine.events.MachineStateEvent)

Example 2 with MachineEntity

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

Example 3 with MachineEntity

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

Example 4 with MachineEntity

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

Example 5 with MachineEntity

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

Aggregations

MachineEntity (org.eclipse.che.ide.api.machine.MachineEntity)23 ArrayList (java.util.ArrayList)8 ProcessTreeNode (org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode)8 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)5 Test (org.junit.Test)5 Machine (org.eclipse.che.api.core.model.machine.Machine)3 WorkspaceRuntime (org.eclipse.che.api.core.model.workspace.WorkspaceRuntime)3 MachineStateEvent (org.eclipse.che.ide.api.machine.events.MachineStateEvent)3 TerminalPresenter (org.eclipse.che.ide.extension.machine.client.perspective.terminal.TerminalPresenter)3 MachineConfig (org.eclipse.che.api.core.model.machine.MachineConfig)2 DevMachine (org.eclipse.che.ide.api.machine.DevMachine)2 CommandOutputConsole (org.eclipse.che.ide.extension.machine.client.outputspanel.console.CommandOutputConsole)2 Element (elemental.dom.Element)1 Node (elemental.dom.Node)1 Event (elemental.events.Event)1 EventListener (elemental.events.EventListener)1 DivElement (elemental.html.DivElement)1 SpanElement (elemental.html.SpanElement)1