mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-151921 - Docker Compose: show composed services / containers in separate subtree
This commit is contained in:
@@ -27,6 +27,9 @@ public interface Deployment {
|
||||
@Nullable
|
||||
DeploymentRuntime getRuntime();
|
||||
|
||||
@Nullable
|
||||
DeploymentRuntime getParentRuntime();
|
||||
|
||||
@Nullable
|
||||
DeploymentTask<?> getDeploymentTask();
|
||||
|
||||
@@ -37,7 +40,4 @@ public interface Deployment {
|
||||
|
||||
@NotNull
|
||||
ServerConnection<?> getConnection();
|
||||
|
||||
@Nullable
|
||||
String getGroup();
|
||||
}
|
||||
|
||||
+6
@@ -2,6 +2,7 @@ package com.intellij.remoteServer.runtime.deployment;
|
||||
|
||||
import com.intellij.remoteServer.runtime.RemoteOperationCallback;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -13,6 +14,11 @@ public abstract class DeploymentRuntime {
|
||||
|
||||
public abstract void undeploy(@NotNull UndeploymentTaskCallback callback);
|
||||
|
||||
@Nullable
|
||||
public DeploymentRuntime getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface UndeploymentTaskCallback extends RemoteOperationCallback {
|
||||
void succeeded();
|
||||
}
|
||||
|
||||
+1
-7
@@ -35,11 +35,6 @@ public abstract class ServerRuntimeInstance<D extends DeploymentConfiguration> {
|
||||
return getDeploymentName(source, configuration);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDeploymentGroup(@NotNull DeploymentSource source, D configuration) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void disconnect();
|
||||
|
||||
public interface DeploymentOperationCallback extends RemoteOperationCallback {
|
||||
@@ -54,8 +49,7 @@ public abstract class ServerRuntimeInstance<D extends DeploymentConfiguration> {
|
||||
Deployment addDeployment(@NotNull String deploymentName,
|
||||
@Nullable DeploymentRuntime deploymentRuntime,
|
||||
@Nullable DeploymentStatus deploymentStatus,
|
||||
@Nullable String deploymentStatusText,
|
||||
@Nullable String deploymentGroup);
|
||||
@Nullable String deploymentStatusText);
|
||||
|
||||
void succeeded();
|
||||
}
|
||||
|
||||
+3
-5
@@ -188,15 +188,14 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
|
||||
|
||||
@Override
|
||||
public void addDeployment(@NotNull String deploymentName, @Nullable DeploymentRuntime deploymentRuntime) {
|
||||
addDeployment(deploymentName, deploymentRuntime, null, null, null);
|
||||
addDeployment(deploymentName, deploymentRuntime, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Deployment addDeployment(@NotNull String deploymentName,
|
||||
@Nullable DeploymentRuntime deploymentRuntime,
|
||||
@Nullable DeploymentStatus deploymentStatus,
|
||||
@Nullable String deploymentStatusText,
|
||||
@Nullable String deploymentGroup) {
|
||||
@Nullable String deploymentStatusText) {
|
||||
DeploymentImpl result;
|
||||
if (deploymentStatus == null) {
|
||||
deploymentStatus = DeploymentStatus.DEPLOYED;
|
||||
@@ -209,8 +208,7 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
|
||||
deploymentStatus,
|
||||
deploymentStatusText,
|
||||
deploymentRuntime,
|
||||
null,
|
||||
deploymentGroup);
|
||||
null);
|
||||
}
|
||||
else if (!result.getStatus().isTransition()) {
|
||||
result.changeState(result.getStatus(), deploymentStatus, deploymentStatusText, deploymentRuntime);
|
||||
|
||||
+4
-6
@@ -19,7 +19,6 @@ public class DeploymentImpl<D extends DeploymentConfiguration> implements Deploy
|
||||
private final ServerConnectionImpl<D> myConnection;
|
||||
private final String myName;
|
||||
private final DeploymentTask<D> myDeploymentTask;
|
||||
private final String myGroup;
|
||||
private volatile DeploymentState myState;
|
||||
private String myPresentableName;
|
||||
|
||||
@@ -28,12 +27,10 @@ public class DeploymentImpl<D extends DeploymentConfiguration> implements Deploy
|
||||
@NotNull DeploymentStatus status,
|
||||
@Nullable String statusText,
|
||||
@Nullable DeploymentRuntime runtime,
|
||||
@Nullable DeploymentTask<D> deploymentTask,
|
||||
@Nullable String group) {
|
||||
@Nullable DeploymentTask<D> deploymentTask) {
|
||||
myConnection = connection;
|
||||
myName = name;
|
||||
myDeploymentTask = deploymentTask;
|
||||
myGroup = group;
|
||||
myState = new DeploymentState(status, statusText, runtime);
|
||||
}
|
||||
|
||||
@@ -89,8 +86,9 @@ public class DeploymentImpl<D extends DeploymentConfiguration> implements Deploy
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return myGroup;
|
||||
public DeploymentRuntime getParentRuntime() {
|
||||
DeploymentRuntime runtime = getRuntime();
|
||||
return runtime == null ? null : runtime.getParent();
|
||||
}
|
||||
|
||||
public boolean changeState(@NotNull DeploymentStatus oldStatus, @NotNull DeploymentStatus newStatus, @Nullable String statusText,
|
||||
|
||||
+1
-2
@@ -40,8 +40,7 @@ public class LocalDeploymentImpl<D extends DeploymentConfiguration> extends Depl
|
||||
status,
|
||||
statusText,
|
||||
runtime,
|
||||
deploymentTask,
|
||||
instance.getDeploymentGroup(deploymentTask.getSource(), deploymentTask.getConfiguration()));
|
||||
deploymentTask);
|
||||
myServerInstance = instance;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -216,8 +216,7 @@ public class ServersToolWindowContent extends JPanel implements Disposable, Serv
|
||||
@Override
|
||||
protected boolean isAutoExpandNode(NodeDescriptor nodeDescriptor) {
|
||||
return (nodeDescriptor instanceof ServersTreeStructure.RemoteServerNode
|
||||
|| nodeDescriptor instanceof ServersTreeStructure.DeploymentNodeImpl
|
||||
|| nodeDescriptor instanceof ServersTreeStructure.GroupNode)
|
||||
|| nodeDescriptor instanceof ServersTreeStructure.DeploymentNodeImpl)
|
||||
&& (!myCollapsedTreeNodeValues.contains(((AbstractTreeNode)nodeDescriptor).getValue()));
|
||||
}
|
||||
};
|
||||
|
||||
+31
-87
@@ -20,7 +20,6 @@ import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.remoteServer.ServerType;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
@@ -49,7 +48,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author michael.golubev
|
||||
@@ -63,9 +65,6 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
|
||||
private final RemoteServersViewContribution myContribution;
|
||||
private final ServersTreeNodeSelector myNodeSelector;
|
||||
|
||||
private final Map<RemoteServer, Map<String, DeploymentGroup>> myServer2DeploymentGroups
|
||||
= new HashMap<RemoteServer, Map<String, DeploymentGroup>>();
|
||||
|
||||
public ServersTreeStructure(@NotNull Project project,
|
||||
@NotNull RemoteServersViewContribution contribution,
|
||||
@NotNull ServersTreeNodeSelector nodeSelector) {
|
||||
@@ -169,39 +168,11 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Map<DeploymentGroup, GroupNode> group2node = new HashMap<DeploymentGroup, GroupNode>();
|
||||
final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
|
||||
for (Deployment deployment : connection.getDeployments()) {
|
||||
final String groupName = deployment.getGroup();
|
||||
if (groupName == null) {
|
||||
if (deployment.getParentRuntime() == null) {
|
||||
children.add(createDeploymentNode(connection, this, deployment));
|
||||
}
|
||||
else {
|
||||
Map<String, DeploymentGroup> groups
|
||||
= ContainerUtil.getOrCreate(myServer2DeploymentGroups, getServer(), new Factory<Map<String, DeploymentGroup>>() {
|
||||
@Override
|
||||
public Map<String, DeploymentGroup> create() {
|
||||
return new HashMap<String, DeploymentGroup>();
|
||||
}
|
||||
});
|
||||
|
||||
final DeploymentGroup group
|
||||
= ContainerUtil.getOrCreate(groups, groupName, new Factory<DeploymentGroup>() {
|
||||
@Override
|
||||
public DeploymentGroup create() {
|
||||
return new DeploymentGroup(groupName);
|
||||
}
|
||||
});
|
||||
|
||||
ContainerUtil.getOrCreate(group2node, group, new Factory<GroupNode>() {
|
||||
@Override
|
||||
public GroupNode create() {
|
||||
GroupNode result = new GroupNode(connection, RemoteServerNode.this, group);
|
||||
children.add(result);
|
||||
return result;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
@@ -428,15 +399,36 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<? extends AbstractTreeNode> getChildren() {
|
||||
DeploymentLogManagerImpl logManager = (DeploymentLogManagerImpl)getConnection().getLogManager(getDeployment());
|
||||
List<AbstractTreeNode> result = new ArrayList<AbstractTreeNode>();
|
||||
collectDeploymentChildren(result);
|
||||
collectLogChildren(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void collectDeploymentChildren(List<AbstractTreeNode> children) {
|
||||
ServerConnection<?> connection = getConnection();
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
for (Deployment deployment : connection.getDeployments()) {
|
||||
DeploymentRuntime parent = deployment.getParentRuntime();
|
||||
if (parent != null && parent == getDeployment().getRuntime()) {
|
||||
children.add(createDeploymentNode(connection, myServerNode, deployment));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void collectLogChildren(List<AbstractTreeNode> children) {
|
||||
ServerConnection<?> connection = getConnection();
|
||||
if (connection == null) {
|
||||
return;
|
||||
}
|
||||
DeploymentLogManagerImpl logManager = (DeploymentLogManagerImpl)connection.getLogManager(getDeployment());
|
||||
if (logManager != null) {
|
||||
List<AbstractTreeNode> nodes = new ArrayList<AbstractTreeNode>();
|
||||
for (LoggingHandlerBase loggingComponent : logManager.getAdditionalLoggingHandlers()) {
|
||||
nodes.add(new DeploymentLogNode(loggingComponent, this));
|
||||
children.add(new DeploymentLogNode(loggingComponent, this));
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -484,52 +476,4 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
|
||||
return myDeploymentNode.getId() + ";log:" + getLogName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeploymentGroup {
|
||||
|
||||
private final String myName;
|
||||
|
||||
private DeploymentGroup(String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
|
||||
public class GroupNode extends AbstractTreeNode<DeploymentGroup> implements ServersTreeNode {
|
||||
|
||||
@NotNull private final ServerConnection<?> myConnection;
|
||||
@NotNull private final RemoteServerNode myServerNode;
|
||||
|
||||
public GroupNode(@NotNull ServerConnection<?> connection, @NotNull RemoteServerNode serverNode, @NotNull DeploymentGroup group) {
|
||||
super(doGetProject(), group);
|
||||
myConnection = connection;
|
||||
myServerNode = serverNode;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DeploymentGroup getGroup() {
|
||||
return getValue();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<? extends AbstractTreeNode> getChildren() {
|
||||
List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
|
||||
for (Deployment deployment : myConnection.getDeployments()) {
|
||||
if (StringUtil.equals(getGroup().getName(), deployment.getGroup())) {
|
||||
children.add(createDeploymentNode(myConnection, myServerNode, deployment));
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update(PresentationData presentation) {
|
||||
presentation.setIcon(myServerNode.getServer().getType().getIcon());
|
||||
presentation.setPresentableText(getGroup().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-5
@@ -72,11 +72,6 @@ public abstract class CloudApplicationRuntime extends DeploymentRuntime {
|
||||
|
||||
protected abstract ServerType<?> getCloudType();
|
||||
|
||||
@Nullable
|
||||
public String getGroup() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract class LoggingTask {
|
||||
|
||||
public void perform(final Project project, final Runnable onDone) {
|
||||
|
||||
+2
-3
@@ -100,8 +100,7 @@ public abstract class CloudServerRuntimeInstance
|
||||
= callback.addDeployment(application.getApplicationName(),
|
||||
application,
|
||||
application.getStatus(),
|
||||
application.getStatusText(),
|
||||
application.getGroup());
|
||||
application.getStatusText());
|
||||
application.setDeploymentModel(deployment);
|
||||
}
|
||||
callback.succeeded();
|
||||
@@ -113,7 +112,7 @@ public abstract class CloudServerRuntimeInstance
|
||||
}, callback);
|
||||
}
|
||||
|
||||
private List<CloudApplicationRuntime> getApplications() throws ServerRuntimeException {
|
||||
protected List<CloudApplicationRuntime> getApplications() throws ServerRuntimeException {
|
||||
return getAgentTaskExecutor().execute(new Computable<List<CloudApplicationRuntime>>() {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user