From 5cb6f617f912656b09e4a1d26be628ba174530de Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Thu, 5 Feb 2015 00:16:32 +0100 Subject: [PATCH] Docker integration - browser panel and action --- .../runtime/deployment/DeploymentTask.java | 4 +++ ...CloudMultiSourceServerRuntimeInstance.java | 7 +++++ .../intellij/ide/browsers/BrowserStarter.java | 29 ++++++++++++++----- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentTask.java b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentTask.java index 585c74b1ff0a..5e4810e100df 100644 --- a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentTask.java +++ b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentTask.java @@ -1,5 +1,6 @@ package com.intellij.remoteServer.runtime.deployment; +import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.openapi.project.Project; import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration; import com.intellij.remoteServer.configuration.deployment.DeploymentSource; @@ -19,4 +20,7 @@ public interface DeploymentTask { Project getProject(); boolean isDebugMode(); + + @NotNull + ExecutionEnvironment getExecutionEnvironment(); } diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudMultiSourceServerRuntimeInstance.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudMultiSourceServerRuntimeInstance.java index dbaeca7e0dd7..55a2a2ad50a2 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudMultiSourceServerRuntimeInstance.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/CloudMultiSourceServerRuntimeInstance.java @@ -1,5 +1,6 @@ package com.intellij.remoteServer.util; +import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; @@ -160,6 +161,12 @@ public abstract class CloudMultiSourceServerRuntimeInstance< public boolean isDebugMode() { return false; } + + @NotNull + @Override + public ExecutionEnvironment getExecutionEnvironment() { + throw new UnsupportedOperationException(); + } }, null); } diff --git a/xml/impl/src/com/intellij/ide/browsers/BrowserStarter.java b/xml/impl/src/com/intellij/ide/browsers/BrowserStarter.java index ca6726926d6f..6968dcb251fb 100644 --- a/xml/impl/src/com/intellij/ide/browsers/BrowserStarter.java +++ b/xml/impl/src/com/intellij/ide/browsers/BrowserStarter.java @@ -5,6 +5,7 @@ import com.intellij.concurrency.JobScheduler; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.process.ProcessHandler; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.Urls; import com.intellij.util.net.NetUtils; @@ -22,12 +23,26 @@ public class BrowserStarter { private final StartBrowserSettings mySettings; private final RunConfiguration myRunConfiguration; - private final ProcessHandler myServerProcessHandler; + private final Computable myOutdated; - public BrowserStarter(@NotNull RunConfiguration runConfiguration, @NotNull StartBrowserSettings settings, @NotNull ProcessHandler serverProcessHandler) { + public BrowserStarter(@NotNull RunConfiguration runConfiguration, + @NotNull StartBrowserSettings settings, + @NotNull Computable outdated) { mySettings = settings; myRunConfiguration = runConfiguration; - myServerProcessHandler = serverProcessHandler; + myOutdated = outdated; + } + + public BrowserStarter(@NotNull RunConfiguration runConfiguration, + @NotNull StartBrowserSettings settings, + @NotNull final ProcessHandler serverProcessHandler) { + this(runConfiguration, settings, new Computable() { + + @Override + public Boolean compute() { + return serverProcessHandler.isProcessTerminating() || serverProcessHandler.isProcessTerminated(); + } + }); } public void start() { @@ -74,7 +89,7 @@ public class BrowserStarter { } else { LOG.info("[attempt#" + attemptNumber + "] Checking " + hostAndPort + " failed"); - if (!isProcessTerminated()) { + if (!isOutdated()) { int delayMillis = getDelayMillis(attemptNumber); checkAndOpenPageLater(hostAndPort, attemptNumber + 1, delayMillis); } @@ -101,12 +116,12 @@ public class BrowserStarter { } private void openPageNow() { - if (!isProcessTerminated()) { + if (!isOutdated()) { JavaScriptDebuggerStarter.Util.startDebugOrLaunchBrowser(myRunConfiguration, mySettings); } } - private boolean isProcessTerminated() { - return myServerProcessHandler.isProcessTerminating() || myServerProcessHandler.isProcessTerminated(); + private boolean isOutdated() { + return myOutdated.compute(); } }