IDEA-131963 - Redesign application servers view actions

This commit is contained in:
Michael Golubev
2014-10-27 18:26:49 +01:00
parent 9e87820daa
commit fd9ead508c
27 changed files with 560 additions and 534 deletions
@@ -38,14 +38,16 @@
<actions>
<group id="RemoteServersViewToolbar">
<action id="RemoteServers.RunServer" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.RunServerAction"/>
<action id="RemoteServers.DebugServer" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.DebugServerAction"/>
<action id="RemoteServers.StopServer" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.StopServerAction"/>
<action id="RemoteServers.EditServer" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.EditConfigurationAction"/>
<separator/>
<action id="RemoteServers.DeployAll" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.DeployAllAction"/>
<action id="RemoteServers.ConnectServer" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.RemoteServerConnectAction"/>
<action id="RemoteServers.DisconnectServer" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.RemoteServerDisconnectAction"/>
<action id="RemoteServers.EditServerConfig" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.RemoteServerConfigAction"/>
<action id="RemoteServers.ChooseServerDeployment" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.ChooseDeploymentAction"/>
<action id="RemoteServers.ChooseServerDeploymentWithDebug" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.ChooseDeploymentWithDebugAction"/>
<action id="Servers.Deploy" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.DeployAction"/>
<action id="Servers.Undeploy" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.UndeployAction"/>
<action id="Servers.DeployWithDebug" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.DeployWithDebugAction"/>
<action id="RemoteServers.EditDeploymentConfig" class="com.intellij.remoteServer.impl.runtime.ui.tree.actions.DeploymentConfigAction"/>
</group>
</actions>
</idea-plugin>
@@ -6,18 +6,16 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.ide.util.treeView.NodeRenderer;
import com.intellij.ide.util.treeView.TreeVisitor;
import com.intellij.openapi.application.ModalityState;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Disposer;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.impl.runtime.log.LoggingHandlerImpl;
import com.intellij.remoteServer.impl.runtime.ui.tree.DeploymentNode;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServerNode;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
import com.intellij.remoteServer.impl.runtime.ui.tree.TreeBuilderBase;
import com.intellij.remoteServer.runtime.ConnectionStatus;
import com.intellij.remoteServer.runtime.ServerConnection;
@@ -108,13 +106,10 @@ public class ServersToolWindowContent extends JPanel implements Disposable {
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent event) {
Set<ServersTreeStructure.RemoteServerNode> nodes = getSelectedRemoteServerNodes();
if (nodes.size() == 1) {
RemoteServer<?> server = nodes.iterator().next().getValue();
ServerConnectionManager.getInstance().getOrCreateConnection(server);
return true;
}
return false;
AnAction connectAction = ActionManager.getInstance().getAction("RemoteServers.ConnectServer");
AnActionEvent actionEvent = AnActionEvent.createFromInputEvent(connectAction, event, ActionPlaces.UNKNOWN);
connectAction.actionPerformed(actionEvent);
return true;
}
}.installOn(myTree);
}
@@ -265,18 +260,6 @@ public class ServersToolWindowContent extends JPanel implements Disposable {
return this;
}
public Set<ServerNode> getSelectedServerNodes() {
return myBuilder.getSelectedElements(ServerNode.class);
}
public Set<DeploymentNode> getSelectedDeploymentNodes() {
return myBuilder.getSelectedElements(DeploymentNode.class);
}
public Set<ServersTreeStructure.RemoteServerNode> getSelectedRemoteServerNodes() {
return myBuilder.getSelectedElements(ServersTreeStructure.RemoteServerNode.class);
}
@Override
public void dispose() {
}
@@ -5,18 +5,24 @@ import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public interface DeploymentNode {
public interface DeploymentNode extends ServersTreeNode {
@NotNull
ServerNode getServerNode();
boolean isRedeployActionEnabled();
void redeploy();
boolean isDeployActionVisible();
boolean isDeployActionEnabled();
void deploy();
boolean isUndeployActionEnabled();
void undeploy();
boolean isEditConfigurationActionEnabled();
void editConfiguration();
boolean isDebugActionVisible();
void deployWithDebug();
boolean isDeployed();
@@ -1,26 +1,9 @@
package com.intellij.remoteServer.impl.runtime.ui.tree;
import com.intellij.execution.Executor;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public interface ServerNode {
boolean isConnected();
boolean isStopActionEnabled();
void stopServer();
public interface ServerNode extends ServersTreeNode {
boolean isStartActionEnabled(@NotNull Executor executor);
void startServer(@NotNull Executor executor);
boolean isDeployActionEnabled();
void deploy(AnActionEvent e);
boolean isDeployAllActionEnabled();
void deployAll();
void editConfiguration();
}
@@ -0,0 +1,20 @@
/*
* Copyright 2000-2014 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.tree;
public interface ServersTreeNode {
}
@@ -3,6 +3,7 @@ package com.intellij.remoteServer.impl.runtime.ui.tree;
import com.intellij.execution.Executor;
import com.intellij.execution.ProgramRunnerUtil;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.impl.RunDialog;
import com.intellij.execution.runners.ExecutionEnvironment;
@@ -18,13 +19,16 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
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.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.RemoteServersManager;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import com.intellij.remoteServer.configuration.deployment.DeploymentConfigurationManager;
import com.intellij.remoteServer.impl.configuration.SingleRemoteServerConfigurable;
import com.intellij.remoteServer.impl.configuration.deployment.DeployToServerRunConfiguration;
import com.intellij.remoteServer.impl.runtime.deployment.DeploymentTaskImpl;
import com.intellij.remoteServer.impl.runtime.log.DeploymentLogManagerImpl;
import com.intellij.remoteServer.impl.runtime.log.LoggingHandlerImpl;
@@ -38,6 +42,7 @@ import com.intellij.remoteServer.runtime.deployment.DeploymentStatus;
import com.intellij.remoteServer.runtime.deployment.DeploymentTask;
import com.intellij.ui.LayeredIcon;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.containers.ContainerUtil;
import icons.RemoteServersIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -160,50 +165,65 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
return ServerConnectionManager.getInstance().getConnection(getValue());
}
@Override
public boolean isConnected() {
ServerConnection<?> connection = getConnection();
return connection != null && connection.getStatus() == ConnectionStatus.CONNECTED;
}
@Override
public boolean isDeployActionEnabled() {
return true;
public void deploy(AnActionEvent e) {
doDeploy(e, DefaultRunExecutor.getRunExecutorInstance(), "Deploy Configuration", true);
}
@Override
public void deploy(AnActionEvent e) {
final ServerType<? extends ServerConfiguration> serverType = getValue().getType();
public void deployWithDebug(AnActionEvent e) {
doDeploy(e, DefaultDebugExecutor.getDebugExecutorInstance(), "Deploy and Debug Configuration", false);
}
public void doDeploy(AnActionEvent e, final Executor executor, String popupTitle, boolean canCreate) {
final RemoteServer<?> server = getValue();
final ServerType<? extends ServerConfiguration> serverType = server.getType();
final DeploymentConfigurationManager configurationManager = DeploymentConfigurationManager.getInstance(doGetProject());
List<RunnerAndConfigurationSettings> list = new ArrayList<RunnerAndConfigurationSettings>(configurationManager.getDeploymentConfigurations(serverType));
list.add(null);
ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<RunnerAndConfigurationSettings>("Deploy Configuration", list) {
@Override
public Icon getIconFor(RunnerAndConfigurationSettings value) {
return value != null ? serverType.getIcon() : null;
}
List<RunnerAndConfigurationSettings> list
= ContainerUtil.filter(configurationManager.getDeploymentConfigurations(serverType),
new Condition<RunnerAndConfigurationSettings>() {
@NotNull
@Override
public String getTextFor(RunnerAndConfigurationSettings value) {
return value != null ? value.getName() : "Create...";
}
@Override
public boolean value(RunnerAndConfigurationSettings settings) {
DeployToServerRunConfiguration configuration =
(DeployToServerRunConfiguration)settings.getConfiguration();
return StringUtil.equals(server.getName(), configuration.getServerName());
}
});
if (canCreate) {
list.add(null);
}
ListPopup popup =
JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<RunnerAndConfigurationSettings>(popupTitle, list) {
@Override
public Icon getIconFor(RunnerAndConfigurationSettings value) {
return value != null ? serverType.getIcon() : null;
}
@Override
public PopupStep onChosen(final RunnerAndConfigurationSettings selectedValue, boolean finalChoice) {
return doFinalStep(new Runnable() {
@Override
public void run() {
if (selectedValue != null) {
ProgramRunnerUtil.executeConfiguration(doGetProject(), selectedValue, DefaultRunExecutor.getRunExecutorInstance());
@NotNull
@Override
public String getTextFor(RunnerAndConfigurationSettings value) {
return value != null ? value.getName() : "Create...";
}
@Override
public PopupStep onChosen(final RunnerAndConfigurationSettings selectedValue, boolean finalChoice) {
return doFinalStep(new Runnable() {
@Override
public void run() {
if (selectedValue != null) {
ProgramRunnerUtil.executeConfiguration(doGetProject(), selectedValue, executor);
}
else {
configurationManager.createAndRunConfiguration(serverType, RemoteServerNode.this.getValue());
}
}
else {
configurationManager.createAndRunConfiguration(serverType, RemoteServerNode.this.getValue());
}
}
});
}
});
});
}
});
if (e.getInputEvent() instanceof MouseEvent) {
popup.show(new RelativePoint((MouseEvent)e.getInputEvent()));
}
@@ -212,45 +232,10 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
}
}
@Override
public boolean isStopActionEnabled() {
return isConnected();
}
@Override
public void stopServer() {
ServerConnection<?> connection = getConnection();
if (connection != null) {
connection.disconnect();
}
}
@Override
public void editConfiguration() {
ShowSettingsUtil.getInstance().editConfigurable(doGetProject(), new SingleRemoteServerConfigurable(getValue(), null, false));
}
@Override
public boolean isStartActionEnabled(@NotNull Executor executor) {
ServerConnection connection = getConnection();
return executor.equals(DefaultRunExecutor.getRunExecutorInstance()) &&
(connection == null || connection.getStatus() == ConnectionStatus.DISCONNECTED);
}
@Override
public void startServer(@NotNull Executor executor) {
ServerConnectionManager.getInstance().getOrCreateConnection(getValue());
}
@Override
public boolean isDeployAllActionEnabled() {
return false;
}
@Override
public void deployAll() {
}
@Nullable
private Icon getStatusIcon(final ConnectionStatus status) {
switch (status) {
@@ -278,23 +263,42 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
}
@Override
public boolean isRedeployActionEnabled() {
public boolean isDeployActionVisible() {
DeploymentTask<?> deploymentTask = getValue().getDeploymentTask();
return deploymentTask instanceof DeploymentTaskImpl<?> && ((DeploymentTaskImpl)deploymentTask).getExecutionEnvironment().getRunnerAndConfigurationSettings() != null;
}
@Override
public void redeploy() {
public boolean isDeployActionEnabled() {
return true;
}
@Override
public void deploy() {
doDeploy(DefaultRunExecutor.getRunExecutorInstance());
}
public void doDeploy(Executor executor) {
DeploymentTask<?> deploymentTask = getValue().getDeploymentTask();
if (deploymentTask != null) {
ExecutionEnvironment environment = ((DeploymentTaskImpl)deploymentTask).getExecutionEnvironment();
RunnerAndConfigurationSettings settings = environment.getRunnerAndConfigurationSettings();
if (settings != null) {
ProgramRunnerUtil.executeConfiguration(doGetProject(), settings, DefaultRunExecutor.getRunExecutorInstance());
ProgramRunnerUtil.executeConfiguration(doGetProject(), settings, executor);
}
}
}
@Override
public boolean isDebugActionVisible() {
return myParentNode.getValue().getType().createDebugConnector() != null;
}
@Override
public void deployWithDebug() {
doDeploy(DefaultDebugExecutor.getDebugExecutorInstance());
}
@Override
public boolean isUndeployActionEnabled() {
DeploymentRuntime runtime = getValue().getRuntime();
@@ -309,12 +313,10 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
}
}
@Override
public boolean isEditConfigurationActionEnabled() {
public boolean isEditConfigurationActionVisible() {
return getValue().getDeploymentTask() != null;
}
@Override
public void editConfiguration() {
DeploymentTask<?> task = getValue().getDeploymentTask();
if (task != null) {
@@ -396,7 +398,7 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
}
}
public class DeploymentLogNode extends AbstractTreeNode<Pair<LoggingHandlerImpl, String>> implements LogProvidingNode {
public class DeploymentLogNode extends AbstractTreeNode<Pair<LoggingHandlerImpl, String>> implements ServersTreeNode, LogProvidingNode {
@NotNull private final DeploymentNodeImpl myDeploymentNode;
public DeploymentLogNode(@NotNull Pair<LoggingHandlerImpl, String> value, @NotNull DeploymentNodeImpl deploymentNode) {
@@ -0,0 +1,39 @@
/*
* Copyright 2000-2014 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.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
import org.jetbrains.annotations.NotNull;
public class ChooseDeploymentAction extends ServersTreeAction<ServersTreeStructure.RemoteServerNode> {
public ChooseDeploymentAction() {
super("Deploy", "Deploy a chosen item to the selected remote server", AllIcons.Nodes.Deploy);
}
@Override
protected Class<ServersTreeStructure.RemoteServerNode> getTargetNodeClass() {
return ServersTreeStructure.RemoteServerNode.class;
}
@Override
protected void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e, ServersTreeStructure.RemoteServerNode node) {
node.deploy(e);
}
}
@@ -0,0 +1,39 @@
/*
* Copyright 2000-2014 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.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
import org.jetbrains.annotations.NotNull;
public class ChooseDeploymentWithDebugAction extends ServersTreeAction<ServersTreeStructure.RemoteServerNode> {
public ChooseDeploymentWithDebugAction() {
super("Debug", "Deploy and debug a chosen item on the selected remote server", AllIcons.Actions.StartDebugger);
}
@Override
protected Class<ServersTreeStructure.RemoteServerNode> getTargetNodeClass() {
return ServersTreeStructure.RemoteServerNode.class;
}
@Override
protected void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e, ServersTreeStructure.RemoteServerNode node) {
node.deployWithDebug(e);
}
}
@@ -1,19 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.execution.Executor;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.icons.AllIcons;
/**
* @author michael.golubev
*/
public class DebugServerAction extends RunServerActionBase {
public DebugServerAction() {
super("Debug", "Start the selected server in debug mode", AllIcons.Actions.StartDebugger);
}
@Override
protected Executor getExecutor() {
return DefaultDebugExecutor.getDebugExecutorInstance();
}
}
@@ -1,67 +1,50 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.remoteServer.impl.runtime.ui.tree.DeploymentNode;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServerNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
/**
* @author michael.golubev
*/
public class DeployAction extends ServersTreeActionBase {
public class DeployAction extends ServersTreeAction<DeploymentNode> {
public DeployAction() {
super("Deploy", "Deploy the selected item", AllIcons.Nodes.Deploy);
}
@Override
protected void updatePresentation(@NotNull Presentation presentation, @Nullable ServersToolWindowContent content) {
if (content != null) {
Set<DeploymentNode> nodes = content.getSelectedDeploymentNodes();
if (nodes.size() == 1) {
DeploymentNode node = nodes.iterator().next();
if (node.isDeployed()) {
presentation.setText("Redeploy");
presentation.setDescription("Redeploy '" + node.getDeploymentName() + "'");
return;
}
}
}
presentation.setText(getTemplatePresentation().getText());
presentation.setDescription(getTemplatePresentation().getDescription());
protected Class<DeploymentNode> getTargetNodeClass() {
return DeploymentNode.class;
}
@Override
protected boolean isEnabled(@NotNull ServersToolWindowContent content, AnActionEvent e) {
Set<DeploymentNode> deploymentNodes = content.getSelectedDeploymentNodes();
Set<ServerNode> serverNodes = content.getSelectedServerNodes();
if (deploymentNodes.size() + serverNodes.size() != 1) return false;
for (DeploymentNode node : deploymentNodes) {
if (!node.isRedeployActionEnabled()) {
return false;
}
protected void updatePresentation(@NotNull Presentation presentation, @Nullable DeploymentNode node) {
if (node != null && node.isDeployed()) {
presentation.setText("Redeploy");
presentation.setDescription("Redeploy '" + node.getDeploymentName() + "'");
}
for (ServerNode serverNode : serverNodes) {
if (!serverNode.isDeployActionEnabled()) {
return false;
}
else {
presentation.setText(getTemplatePresentation().getText());
presentation.setDescription(getTemplatePresentation().getDescription());
}
return true;
}
@Override
protected void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e) {
for (DeploymentNode node : content.getSelectedDeploymentNodes()) {
node.redeploy();
}
for (ServerNode node : content.getSelectedServerNodes()) {
node.deploy(e);
}
protected boolean isVisible4(DeploymentNode node) {
return node.isDeployActionVisible();
}
@Override
protected boolean isEnabled4(DeploymentNode node) {
return node.isDeployActionEnabled();
}
@Override
protected void doActionPerformed(DeploymentNode node) {
node.deploy();
}
}
@@ -1,27 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServerNode;
import org.jetbrains.annotations.NotNull;
/**
* @author michael.golubev
*/
public class DeployAllAction extends ServerActionBase {
public DeployAllAction() {
super("Deploy All", "Deploy all the artifacts of the selected server", AllIcons.Nodes.Deploy);
}
@Override
protected void performAction(@NotNull ServerNode serverNode) {
if (serverNode.isDeployAllActionEnabled()) {
serverNode.deployAll();
}
}
@Override
protected boolean isEnabledForServer(@NotNull ServerNode serverNode) {
return serverNode.isDeployAllActionEnabled();
}
}
@@ -0,0 +1,46 @@
/*
* Copyright 2000-2014 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.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.remoteServer.impl.runtime.ui.tree.DeploymentNode;
public class DeployWithDebugAction extends ServersTreeAction<DeploymentNode> {
public DeployWithDebugAction() {
super("Debug", "Deploy and debug the selected item", AllIcons.Actions.StartDebugger);
}
@Override
protected Class<DeploymentNode> getTargetNodeClass() {
return DeploymentNode.class;
}
@Override
protected boolean isVisible4(DeploymentNode node) {
return node.isDeployActionVisible() && node.isDebugActionVisible();
}
@Override
protected boolean isEnabled4(DeploymentNode node) {
return node.isDeployActionEnabled();
}
@Override
protected void doActionPerformed(DeploymentNode node) {
node.deployWithDebug();
}
}
@@ -1,52 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.remoteServer.impl.runtime.ui.tree.DeploymentNode;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author nik
*/
public abstract class DeploymentActionBase extends ServersTreeActionBase {
protected DeploymentActionBase(String text, String description, Icon icon) {
super(text, description, icon);
}
protected abstract void perform(@NotNull List<DeploymentNode> nodes, ServersToolWindowContent content, AnActionEvent e);
protected abstract boolean isApplicable(@NotNull DeploymentNode node);
@Override
public void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e) {
List<DeploymentNode> toPerform = new ArrayList<DeploymentNode>();
for (DeploymentNode node : content.getSelectedDeploymentNodes()) {
if (isApplicable(node)) {
toPerform.add(node);
}
}
if (!toPerform.isEmpty()) {
perform(toPerform, content, e);
}
}
@Override
protected boolean isEnabled(@NotNull ServersToolWindowContent content, AnActionEvent e) {
Set<?> selectedElements = content.getBuilder().getSelectedElements();
if (selectedElements.isEmpty() || selectedElements.size() != content.getSelectedDeploymentNodes().size()) {
return false;
}
for (DeploymentNode node : content.getSelectedDeploymentNodes()) {
if (!isApplicable(node)) {
return false;
}
}
return true;
}
}
@@ -0,0 +1,40 @@
/*
* Copyright 2000-2014 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.tree.actions;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
public class DeploymentConfigAction extends EditConfigurationActionBase<ServersTreeStructure.DeploymentNodeImpl> {
public DeploymentConfigAction() {
super("Edit the selected deployment run configuration");
}
@Override
protected Class<ServersTreeStructure.DeploymentNodeImpl> getTargetNodeClass() {
return ServersTreeStructure.DeploymentNodeImpl.class;
}
@Override
protected boolean isVisible4(ServersTreeStructure.DeploymentNodeImpl node) {
return node.isEditConfigurationActionVisible();
}
@Override
protected void doActionPerformed(ServersTreeStructure.DeploymentNodeImpl node) {
node.editConfiguration();
}
}
@@ -1,42 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.remoteServer.impl.runtime.ui.tree.DeploymentNode;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServerNode;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
/**
* @author michael.golubev
*/
public class EditConfigurationAction extends ServersTreeActionBase {
public EditConfigurationAction() {
super("Edit Configuration", "Edit configuration of the selected server", AllIcons.Actions.EditSource);
}
@Override
protected void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e) {
Set<DeploymentNode> deploymentNodes = content.getSelectedDeploymentNodes();
Set<ServerNode> serverNodes = content.getSelectedServerNodes();
if (deploymentNodes.size() == 1) {
deploymentNodes.iterator().next().editConfiguration();
}
else {
serverNodes.iterator().next().editConfiguration();
}
}
@Override
protected boolean isEnabled(@NotNull ServersToolWindowContent content, AnActionEvent e) {
Set<DeploymentNode> deploymentNodes = content.getSelectedDeploymentNodes();
Set<ServerNode> serverNodes = content.getSelectedServerNodes();
if (deploymentNodes.size() + serverNodes.size() != 1) return false;
if (deploymentNodes.size() == 1) {
return deploymentNodes.iterator().next().isEditConfigurationActionEnabled();
}
return true;
}
}
@@ -0,0 +1,26 @@
/*
* Copyright 2000-2014 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.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeNode;
public abstract class EditConfigurationActionBase<T extends ServersTreeNode> extends ServersTreeAction<T> {
public EditConfigurationActionBase(String description) {
super("Edit Configuration", description, AllIcons.Actions.EditSource);
}
}
@@ -0,0 +1,35 @@
/*
* Copyright 2000-2014 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.tree.actions;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
public class RemoteServerConfigAction extends EditConfigurationActionBase<ServersTreeStructure.RemoteServerNode> {
public RemoteServerConfigAction() {
super("Edit the selected remote server configuration");
}
@Override
protected Class<ServersTreeStructure.RemoteServerNode> getTargetNodeClass() {
return ServersTreeStructure.RemoteServerNode.class;
}
@Override
protected void doActionPerformed(ServersTreeStructure.RemoteServerNode node) {
node.editConfiguration();
}
}
@@ -0,0 +1,42 @@
/*
* Copyright 2000-2014 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.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
import com.intellij.remoteServer.runtime.ServerConnectionManager;
public class RemoteServerConnectAction extends ServersTreeAction<ServersTreeStructure.RemoteServerNode> {
public RemoteServerConnectAction() {
super("Connect", "Connect to the selected remote server", AllIcons.Actions.Execute);
}
@Override
protected Class<ServersTreeStructure.RemoteServerNode> getTargetNodeClass() {
return ServersTreeStructure.RemoteServerNode.class;
}
@Override
protected boolean isEnabled4(ServersTreeStructure.RemoteServerNode node) {
return !node.isConnected();
}
@Override
protected void doActionPerformed(ServersTreeStructure.RemoteServerNode node) {
ServerConnectionManager.getInstance().getOrCreateConnection(node.getValue());
}
}
@@ -0,0 +1,46 @@
/*
* Copyright 2000-2014 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.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure;
import com.intellij.remoteServer.runtime.ServerConnection;
import com.intellij.remoteServer.runtime.ServerConnectionManager;
public class RemoteServerDisconnectAction extends ServersTreeAction<ServersTreeStructure.RemoteServerNode> {
public RemoteServerDisconnectAction() {
super("Disconnect", "Disconnect from the selected remote server", AllIcons.Actions.Suspend);
}
@Override
protected Class<ServersTreeStructure.RemoteServerNode> getTargetNodeClass() {
return ServersTreeStructure.RemoteServerNode.class;
}
@Override
protected boolean isEnabled4(ServersTreeStructure.RemoteServerNode node) {
return node.isConnected();
}
@Override
protected void doActionPerformed(ServersTreeStructure.RemoteServerNode node) {
ServerConnection<?> connection = ServerConnectionManager.getInstance().getConnection(node.getValue());
if (connection != null) {
connection.disconnect();
}
}
}
@@ -1,20 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.execution.Executor;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.icons.AllIcons;
/**
* @author michael.golubev
*/
public class RunServerAction extends RunServerActionBase {
public RunServerAction() {
super("Run/Connect", "Run/Connect to the selected server", AllIcons.Actions.Execute);
}
@Override
protected Executor getExecutor() {
return DefaultRunExecutor.getRunExecutorInstance();
}
}
@@ -1,31 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.execution.Executor;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServerNode;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
/**
* @author michael.golubev
*/
public abstract class RunServerActionBase extends ServerActionBase {
protected RunServerActionBase(String text, String description, Icon icon) {
super(text, description, icon);
}
protected void performAction(@NotNull ServerNode serverNode) {
if (serverNode.isStartActionEnabled(getExecutor())) {
serverNode.startServer(getExecutor());
}
}
@Override
protected boolean isEnabledForServer(@NotNull ServerNode serverNode) {
return serverNode.isStartActionEnabled(getExecutor());
}
protected abstract Executor getExecutor();
}
@@ -1,46 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServerNode;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Set;
/**
* @author michael.golubev
*/
public abstract class ServerActionBase extends ServersTreeActionBase {
protected ServerActionBase(String text, String description, Icon icon) {
super(text, description, icon);
}
@Override
protected final boolean isEnabled(@NotNull ServersToolWindowContent content, AnActionEvent e) {
Set<ServerNode> selectedServerNodes = content.getSelectedServerNodes();
Set<?> selectedElements = content.getBuilder().getSelectedElements();
if (selectedElements.size() != selectedServerNodes.size() || selectedElements.isEmpty()) {
return false;
}
for (ServerNode selectedServer : selectedServerNodes) {
if (!isEnabledForServer(selectedServer)) {
return false;
}
}
return true;
}
@Override
protected void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e) {
for (ServerNode node : content.getSelectedServerNodes()) {
performAction(node);
}
}
protected abstract void performAction(@NotNull ServerNode serverNode);
protected abstract boolean isEnabledForServer(@NotNull ServerNode serverNode);
}
@@ -0,0 +1,91 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Set;
public abstract class ServersTreeAction<T extends ServersTreeNode> extends AnAction {
protected ServersTreeAction(String text, String description, Icon icon) {
super(text, description, icon);
}
@Override
public void update(@NotNull AnActionEvent e) {
Presentation presentation = e.getPresentation();
T targetNode = getTargetNode(e);
boolean visible = false;
boolean enabled = false;
if (targetNode != null) {
visible = isVisible4(targetNode);
if (visible) {
enabled = isEnabled4(targetNode);
}
}
presentation.setVisible(visible);
presentation.setEnabled(enabled);
updatePresentation(presentation, targetNode);
}
private T getTargetNode(AnActionEvent e) {
ServersToolWindowContent content = getContent(e);
if (content == null) {
return null;
}
Set<Object> selectedElements = content.getBuilder().getSelectedElements();
if (selectedElements.size() != 1) {
return null;
}
ServersTreeNode node = (ServersTreeNode)selectedElements.iterator().next();
Class<T> targetNodeClass = getTargetNodeClass();
if (!targetNodeClass.isInstance(node)) {
return null;
}
return targetNodeClass.cast(node);
}
private static ServersToolWindowContent getContent(AnActionEvent e) {
return e.getData(ServersToolWindowContent.KEY);
}
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
T targetNode = getTargetNode(e);
if (targetNode != null && isVisible4(targetNode) && isEnabled4(targetNode)) {
doActionPerformed(getContent(e), e, targetNode);
}
}
protected boolean isVisible4(T node) {
return true;
}
protected boolean isEnabled4(T node) {
return true;
}
protected void updatePresentation(@NotNull Presentation presentation, @Nullable T node) {
}
protected void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e, T node) {
doActionPerformed(node);
}
protected void doActionPerformed(T node) {
throw new UnsupportedOperationException();
}
protected abstract Class<T> getTargetNodeClass();
}
@@ -1,44 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* @author michael.golubev
*/
public abstract class ServersTreeActionBase extends AnAction {
protected ServersTreeActionBase(String text, String description, Icon icon) {
super(text, description, icon);
}
@Override
public void update(AnActionEvent e) {
ServersToolWindowContent content = e.getData(ServersToolWindowContent.KEY);
Presentation presentation = e.getPresentation();
presentation.setEnabled(content != null && isEnabled(content, e));
updatePresentation(presentation, content);
}
protected void updatePresentation(@NotNull Presentation presentation, @Nullable ServersToolWindowContent content) {
}
@Override
public void actionPerformed(AnActionEvent e) {
ServersToolWindowContent content = e.getData(ServersToolWindowContent.KEY);
if (content == null) {
return;
}
doActionPerformed(content, e);
}
protected abstract boolean isEnabled(@NotNull ServersToolWindowContent content, AnActionEvent e);
protected abstract void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e);
}
@@ -1,49 +0,0 @@
/*
* Copyright 2000-2013 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.tree.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServerNode;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Set;
/**
* @author michael.golubev
*/
public abstract class SingleServerActionBase extends ServersTreeActionBase {
protected SingleServerActionBase(String text, String description, Icon icon) {
super(text, description, icon);
}
@Override
protected void doActionPerformed(@NotNull ServersToolWindowContent content, AnActionEvent e) {
doActionPerformed(content, content.getSelectedServerNodes().iterator().next());
}
@Override
protected boolean isEnabled(@NotNull ServersToolWindowContent content, AnActionEvent e) {
Set<ServerNode> serverNodes = content.getSelectedServerNodes();
return content.getBuilder().getSelectedElements().size() == serverNodes.size() && serverNodes.size() == 1 &&
isEnabledForServer(serverNodes.iterator().next());
}
protected abstract boolean isEnabledForServer(ServerNode serverNode);
protected abstract void doActionPerformed(@NotNull ServersToolWindowContent content, @NotNull ServerNode server);
}
@@ -1,26 +0,0 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.remoteServer.impl.runtime.ui.tree.ServerNode;
import org.jetbrains.annotations.NotNull;
/**
* @author michael.golubev
*/
public class StopServerAction extends ServerActionBase {
public StopServerAction() {
super("Stop/Disconnect", "Stop/disconnect from the selected server", AllIcons.Actions.Suspend);
}
protected void performAction(@NotNull ServerNode serverNode) {
if (serverNode.isStopActionEnabled()) {
serverNode.stopServer();
}
}
@Override
protected boolean isEnabledForServer(@NotNull ServerNode serverNode) {
return serverNode.isStopActionEnabled();
}
}
@@ -1,30 +1,29 @@
package com.intellij.remoteServer.impl.runtime.ui.tree.actions;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.remoteServer.impl.runtime.ui.ServersToolWindowContent;
import com.intellij.remoteServer.impl.runtime.ui.tree.DeploymentNode;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author michael.golubev
*/
public class UndeployAction extends DeploymentActionBase {
public class UndeployAction extends ServersTreeAction<DeploymentNode> {
public UndeployAction() {
super("Undeploy", "Undeploy the selected item", AllIcons.Nodes.Undeploy);
}
@Override
protected boolean isApplicable(@NotNull DeploymentNode node) {
protected Class<DeploymentNode> getTargetNodeClass() {
return DeploymentNode.class;
}
@Override
protected boolean isEnabled4(DeploymentNode node) {
return node.isUndeployActionEnabled();
}
@Override
protected void perform(@NotNull List<DeploymentNode> nodes, ServersToolWindowContent content, AnActionEvent e) {
for (DeploymentNode node : nodes) {
node.undeploy();
}
protected void doActionPerformed(DeploymentNode node) {
node.undeploy();
}
}