CODENVY-106: remove widgets from Process panel when the machine was destroyed
Signed-off-by: Valeriy Svydenko <vsvydenko@codenvy.com>6.19.x
parent
1746c12a39
commit
bb04c6604a
|
|
@ -59,6 +59,7 @@ import org.eclipse.che.ide.util.loging.Log;
|
|||
import org.vectomatic.dom.svg.ui.SVGResource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -210,10 +211,20 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
}
|
||||
|
||||
rootNodes.remove(destroyedMachineNode);
|
||||
onCloseTerminal(destroyedMachineNode);
|
||||
onStopCommandProcess(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());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -394,10 +405,9 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
outputConsole.getTitleIcon(),
|
||||
null);
|
||||
commandId = commandNode.getId();
|
||||
view.addProcessNode(commandNode);
|
||||
addChildToMachineNode(commandNode, machineTreeNode);
|
||||
|
||||
addOutputConsole(commandId, outputConsole, false);
|
||||
addOutputConsole(commandId, commandNode, outputConsole, false);
|
||||
|
||||
refreshStopButtonState(commandId);
|
||||
workspaceAgent.setActivePart(this);
|
||||
|
|
@ -417,15 +427,21 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
return consoles.containsKey(commandId) && consoles.get(commandId).isFinished();
|
||||
}
|
||||
|
||||
private void addOutputConsole(final String id, final OutputConsole outputConsole, final boolean machineConsole) {
|
||||
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);
|
||||
view.selectNode(view.getNodeById(id));
|
||||
if (!MACHINE_NODE.equals(processNode.getType())) {
|
||||
view.selectNode(view.getNodeById(id));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -593,7 +609,8 @@ public class ProcessesPanelPresenter extends BasePresenter implements ProcessesP
|
|||
rootNodes.add(machineNode);
|
||||
|
||||
OutputConsole outputConsole = commandConsoleFactory.create(machine.getConfig().getName());
|
||||
addOutputConsole(machine.getId(), outputConsole, true);
|
||||
|
||||
addOutputConsole(machine.getId(), machineNode, outputConsole, true);
|
||||
|
||||
view.setProcessesData(rootNode);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.eclipse.che.ide.extension.machine.client.processes.ProcessTreeNode.ProcessNodeType.MACHINE_NODE;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ProcessesPanelView}.
|
||||
*
|
||||
|
|
@ -282,6 +284,10 @@ public class ProcessesPanelViewImpl extends BaseView<ProcessesPanelView.ActionDe
|
|||
public void onWidgetRemoving(SubPanel.RemoveCallback removeCallback) {
|
||||
final ProcessTreeNode treeNode = widget2TreeNodes.get(widgetToShow.getWidget());
|
||||
|
||||
if (treeNode == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (treeNode.getType()) {
|
||||
case COMMAND_NODE:
|
||||
delegate.onCommandTabClosing(treeNode, removeCallback);
|
||||
|
|
@ -290,6 +296,10 @@ public class ProcessesPanelViewImpl extends BaseView<ProcessesPanelView.ActionDe
|
|||
delegate.onTerminalTabClosing(treeNode);
|
||||
removeCallback.remove();
|
||||
break;
|
||||
case MACHINE_NODE:
|
||||
removeCallback.remove();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -408,7 +418,7 @@ public class ProcessesPanelViewImpl extends BaseView<ProcessesPanelView.ActionDe
|
|||
activeProcessId = processId;
|
||||
|
||||
final ProcessTreeNode treeNode = processTreeNodes.get(processId);
|
||||
if (treeNode != null) {
|
||||
if (treeNode != null && !MACHINE_NODE.equals(treeNode.getType())) {
|
||||
treeNode.setHasUnreadContent(false);
|
||||
treeNode.getTreeNodeElement().getClassList().remove(machineResources.getCss().badgeVisible());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,7 +221,6 @@ public class ProcessesPanelPresenterTest {
|
|||
verify(workspaceAgent).setActivePart(anyObject());
|
||||
verify(commandConsoleFactory).create(eq("machine_name"));
|
||||
verify(view).addWidget(anyString(), anyString(), anyObject(), anyObject(), anyBoolean());
|
||||
verify(view).selectNode(anyObject());
|
||||
verify(view).setProcessesData(eq(presenter.rootNode));
|
||||
}
|
||||
|
||||
|
|
@ -247,13 +246,13 @@ public class ProcessesPanelPresenterTest {
|
|||
|
||||
presenter.addCommandOutput(MACHINE_ID, outputConsole);
|
||||
|
||||
verify(view).addProcessNode(anyObject());
|
||||
verify(view, never()).hideProcessOutput(anyString());
|
||||
|
||||
verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
|
||||
IsWidget widget = mock(IsWidget.class);
|
||||
acceptsOneWidgetCaptor.getValue().setWidget(widget);
|
||||
|
||||
verify(view).addProcessNode(anyObject());
|
||||
verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
|
||||
verify(view, times(2)).selectNode(anyObject());
|
||||
verify(view).setProcessesData(anyObject());
|
||||
|
|
@ -278,13 +277,13 @@ public class ProcessesPanelPresenterTest {
|
|||
|
||||
presenter.addCommandOutput(MACHINE_ID, outputConsole);
|
||||
|
||||
verify(view).addProcessNode(anyObject());
|
||||
verify(view, never()).hideProcessOutput(anyString());
|
||||
|
||||
verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
|
||||
IsWidget widget = mock(IsWidget.class);
|
||||
acceptsOneWidgetCaptor.getValue().setWidget(widget);
|
||||
|
||||
verify(view).addProcessNode(anyObject());
|
||||
verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
|
||||
verify(view, times(2)).selectNode(anyObject());
|
||||
verify(view).setProcessesData(anyObject());
|
||||
|
|
@ -309,12 +308,12 @@ public class ProcessesPanelPresenterTest {
|
|||
|
||||
presenter.addCommandOutput(MACHINE_ID, outputConsole);
|
||||
|
||||
verify(view).addProcessNode(anyObject());
|
||||
verify(view, never()).hideProcessOutput(anyString());
|
||||
|
||||
verify(outputConsole).go(acceptsOneWidgetCaptor.capture());
|
||||
IsWidget widget = mock(IsWidget.class);
|
||||
acceptsOneWidgetCaptor.getValue().setWidget(widget);
|
||||
verify(view).addProcessNode(anyObject());
|
||||
|
||||
verify(view).addWidget(anyString(), anyString(), anyObject(), eq(widget), anyBoolean());
|
||||
verify(view, times(2)).selectNode(anyObject());
|
||||
|
|
@ -356,7 +355,7 @@ public class ProcessesPanelPresenterTest {
|
|||
verify(view, times(2)).setProcessesData(anyObject());
|
||||
verify(view, times(2)).selectNode(anyObject());
|
||||
verify(view).addWidget(anyString(), anyString(), anyObject(), eq(terminalWidget), anyBoolean());
|
||||
verify(view, times(2)).addProcessNode(anyObject());
|
||||
verify(view, times(1)).addProcessNode(anyObject());
|
||||
verify(terminal).setVisible(eq(true));
|
||||
verify(terminal).connect();
|
||||
verify(terminal).setListener(anyObject());
|
||||
|
|
|
|||
Loading…
Reference in New Issue