Docker integration - separate tool window - tabs instead of subnodes

This commit is contained in:
Michael Golubev
2016-01-25 14:56:48 +01:00
parent 912e9907f8
commit 477faee287
4 changed files with 67 additions and 17 deletions
@@ -15,8 +15,11 @@
*/
package com.intellij.remoteServer.impl.runtime.ui;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.openapi.project.Project;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
import com.intellij.remoteServer.runtime.ServerConnection;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -29,4 +32,29 @@ public abstract class RemoteServersViewContribution extends RemoteServersViewCon
public boolean canContribute(@NotNull Project project) {
return !getRemoteServers().isEmpty();
}
public ServersTreeStructure createTreeStructure(@NotNull final Project project) {
return new ServersTreeStructure(project, this);
}
public TreeNodeSelector createLogNodeSelector(final ServerConnection<?> connection,
final String deploymentName,
final String logName) {
return new TreeNodeSelector<ServersTreeStructure.DeploymentLogNode>() {
@Override
public boolean visit(@NotNull ServersTreeStructure.DeploymentLogNode node) {
AbstractTreeNode parent = node.getParent();
return parent instanceof ServersTreeStructure.DeploymentNodeImpl
&&
ServersToolWindowContent.isDeploymentNodeMatch((ServersTreeStructure.DeploymentNodeImpl)parent, connection, deploymentName)
&&
node.getValue().getPresentableName().equals(logName);
}
@Override
public Class<ServersTreeStructure.DeploymentLogNode> getNodeClass() {
return ServersTreeStructure.DeploymentLogNode.class;
}
};
}
}
@@ -210,7 +210,7 @@ public class ServersToolWindowContent extends JPanel implements Disposable {
}
private void setupBuilder(final @NotNull Project project) {
ServersTreeStructure structure = new ServersTreeStructure(project, myContribution);
ServersTreeStructure structure = myContribution.createTreeStructure(project);
myBuilder = new TreeBuilderBase(myTree, structure, myTreeModel) {
@Override
protected boolean isAutoExpandNode(NodeDescriptor nodeDescriptor) {
@@ -338,15 +338,8 @@ public class ServersToolWindowContent extends JPanel implements Disposable {
myBuilder.getUi().queueUpdate(connection).doWhenDone(new Runnable() {
@Override
public void run() {
myBuilder.select(ServersTreeStructure.DeploymentLogNode.class, new TreeVisitor<ServersTreeStructure.DeploymentLogNode>() {
@Override
public boolean visit(@NotNull ServersTreeStructure.DeploymentLogNode node) {
AbstractTreeNode parent = node.getParent();
return parent instanceof ServersTreeStructure.DeploymentNodeImpl
&& isDeploymentNodeMatch((ServersTreeStructure.DeploymentNodeImpl)parent, connection, deploymentName)
&& node.getValue().getPresentableName().equals(logName);
}
}, null, false);
TreeNodeSelector nodeSelector = myContribution.createLogNodeSelector(connection, deploymentName, logName);
myBuilder.select(nodeSelector.getNodeClass(), nodeSelector, null, false);
}
});
}
@@ -356,8 +349,8 @@ public class ServersToolWindowContent extends JPanel implements Disposable {
return node.getServer().equals(connection.getServer());
}
private static boolean isDeploymentNodeMatch(@NotNull ServersTreeStructure.DeploymentNodeImpl node,
@NotNull final ServerConnection<?> connection, @NotNull final String deploymentName) {
public static boolean isDeploymentNodeMatch(@NotNull ServersTreeStructure.DeploymentNodeImpl node,
@NotNull final ServerConnection<?> connection, @NotNull final String deploymentName) {
ServersTreeStructure.RemoteServerNode serverNode = node.getServerNode();
return isServerNodeMatch(serverNode, connection)
&& node.getDeployment().getName().equals(deploymentName);
@@ -0,0 +1,25 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.remoteServer.impl.runtime.ui;
import com.intellij.ide.util.treeView.TreeVisitor;
import org.jetbrains.annotations.NotNull;
public interface TreeNodeSelector<T> extends TreeVisitor<T> {
boolean visit(@NotNull T node);
Class<T> getNodeClass();
}
@@ -89,7 +89,7 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
}
@NotNull
Project doGetProject() {
protected Project doGetProject() {
return myProject;
}
@@ -107,6 +107,10 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
return false;
}
protected AbstractTreeNode createDeploymentNode(ServerConnection<?> connection, RemoteServerNode serverNode, Deployment deployment) {
return new DeploymentNodeImpl(connection, serverNode, deployment);
}
public interface LogProvidingNode {
@Nullable
JComponent getComponent();
@@ -162,7 +166,7 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
for (Deployment deployment : connection.getDeployments()) {
final String groupName = deployment.getGroup();
if (groupName == null) {
children.add(new DeploymentNodeImpl(connection, this, deployment));
children.add(createDeploymentNode(connection, this, deployment));
}
else {
Map<String, DeploymentGroup> groups
@@ -293,7 +297,7 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
private final ServerConnection<?> myConnection;
private final RemoteServerNode myServerNode;
private DeploymentNodeImpl(@NotNull ServerConnection<?> connection, @NotNull RemoteServerNode serverNode, @NotNull Deployment value) {
protected DeploymentNodeImpl(@NotNull ServerConnection<?> connection, @NotNull RemoteServerNode serverNode, @NotNull Deployment value) {
super(doGetProject(), value);
myConnection = connection;
myServerNode = serverNode;
@@ -399,7 +403,7 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
}
@Nullable
private DeploymentLogManagerImpl getLogManager() {
protected DeploymentLogManagerImpl getLogManager() {
return (DeploymentLogManagerImpl)myConnection.getLogManager(getDeployment());
}
@@ -508,7 +512,7 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
for (Deployment deployment : myConnection.getDeployments()) {
if (StringUtil.equals(getGroup().getName(), deployment.getGroup())) {
children.add(new DeploymentNodeImpl(myConnection, myServerNode, deployment));
children.add(createDeploymentNode(myConnection, myServerNode, deployment));
}
}
return children;