/** * Adds new terminal to the processes panel * * @param machineId id of machine in which the terminal will be added */ @Override public void onAddTerminal(@NotNull final String machineId) { machineService .getMachine(machineId) .then( new Operation<MachineDto>() { @Override public void apply(MachineDto arg) throws OperationException { Machine machine = entityFactory.createMachine(arg); final ProcessTreeNode machineTreeNode = findProcessTreeNodeById(machineId); if (machineTreeNode == null) { notificationManager.notify( localizationConstant.failedToConnectTheTerminal(), localizationConstant.machineNotFound(machineId), FAIL, FLOAT_MODE); Log.error(getClass(), localizationConstant.machineNotFound(machineId)); return; } final TerminalPresenter newTerminal = terminalFactory.create(machine); 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); view.addProcessWidget(terminalId, terminalWidget); resfreshStopButtonState(terminalId); newTerminal.setVisible(true); newTerminal.connect(); newTerminal.setListener( new TerminalStateListener() { @Override public void onExit() { onStopProcess(terminalNode); terminals.remove(terminalId); } }); } }) .catchError( new Operation<PromiseError>() { @Override public void apply(PromiseError arg) throws OperationException { notificationManager.notify(localizationConstant.failedToFindMachine(machineId)); } }); }
@Override public void onMachineRunning(MachineStateEvent event) { workspaceAgent.setActivePart(this); machineService .getMachine(event.getMachineId()) .then( new Operation<MachineDto>() { @Override public void apply(MachineDto machine) throws OperationException { addMachineToConsoles(machine); } }); }