Search in sources :

Example 6 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 7 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 8 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)

Example 9 with MachineEntity

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;
}
Also used : MachineEntity(org.eclipse.che.ide.api.machine.MachineEntity) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) WorkspaceRuntime(org.eclipse.che.api.core.model.workspace.WorkspaceRuntime) ArrayList(java.util.ArrayList) ExtendedMachine(org.eclipse.che.api.core.model.workspace.ExtendedMachine) Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 10 with MachineEntity

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

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