mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-122562 - Warning from SettingsEditor#applyEditorTo prevents runconfig editor from closing
This commit is contained in:
+19
-3
@@ -145,8 +145,9 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
private ValidationResult getValidationResult() {
|
||||
if (!myValidationResultValid) {
|
||||
myLastValidationResult = null;
|
||||
RunnerAndConfigurationSettings snapshot = null;
|
||||
try {
|
||||
RunnerAndConfigurationSettings snapshot = getSnapshot();
|
||||
snapshot = getSnapshot();
|
||||
if (snapshot != null) {
|
||||
snapshot.setName(getNameText());
|
||||
snapshot.checkSettings(myExecutor);
|
||||
@@ -161,8 +162,23 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
}
|
||||
}
|
||||
catch (RuntimeConfigurationException exception) {
|
||||
myLastValidationResult =
|
||||
exception != null ? new ValidationResult(exception.getLocalizedMessage(), exception.getTitle(), exception.getQuickFix()) : null;
|
||||
final Runnable quickFix = exception.getQuickFix();
|
||||
Runnable resultQuickFix;
|
||||
if (quickFix != null && snapshot != null) {
|
||||
final RunnerAndConfigurationSettings fixedSettings = snapshot;
|
||||
resultQuickFix = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
quickFix.run();
|
||||
getEditor().resetFrom(fixedSettings);
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
resultQuickFix = quickFix;
|
||||
}
|
||||
myLastValidationResult = new ValidationResult(exception.getLocalizedMessage(), exception.getTitle(), resultQuickFix);
|
||||
}
|
||||
catch (ConfigurationException e) {
|
||||
myLastValidationResult = new ValidationResult(e.getLocalizedMessage(), ExecutionBundle.message("invalid.data.dialog.title"), null);
|
||||
|
||||
+5
@@ -1,10 +1,15 @@
|
||||
package com.intellij.remoteServer.configuration.deployment;
|
||||
|
||||
import com.intellij.execution.configurations.RuntimeConfigurationException;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class DeploymentConfiguration {
|
||||
public abstract PersistentStateComponent<?> getSerializer();
|
||||
|
||||
public abstract void checkConfiguration(RemoteServer<?> server, DeploymentSource deploymentSource)
|
||||
throws RuntimeConfigurationException;
|
||||
}
|
||||
|
||||
+9
-1
@@ -1,13 +1,16 @@
|
||||
package com.intellij.remoteServer.configuration.deployment;
|
||||
|
||||
import com.intellij.execution.configurations.RuntimeConfigurationException;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class DeploymentConfigurationBase<Self extends DeploymentConfigurationBase> extends DeploymentConfiguration implements PersistentStateComponent<Self> {
|
||||
public class DeploymentConfigurationBase<Self extends DeploymentConfigurationBase> extends DeploymentConfiguration
|
||||
implements PersistentStateComponent<Self> {
|
||||
@Override
|
||||
public PersistentStateComponent<?> getSerializer() {
|
||||
return this;
|
||||
@@ -23,4 +26,9 @@ public class DeploymentConfigurationBase<Self extends DeploymentConfigurationBas
|
||||
public void loadState(Self state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(RemoteServer<?> server, DeploymentSource deploymentSource) throws RuntimeConfigurationException {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -1,6 +1,8 @@
|
||||
package com.intellij.remoteServer.configuration.deployment;
|
||||
|
||||
import com.intellij.execution.configurations.RuntimeConfigurationException;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.remoteServer.configuration.RemoteServer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -21,4 +23,9 @@ public class DummyDeploymentConfiguration extends DeploymentConfiguration implem
|
||||
@Override
|
||||
public void loadState(DummyDeploymentConfiguration state) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration(RemoteServer<?> server, DeploymentSource deploymentSource) throws RuntimeConfigurationException {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+24
-2
@@ -32,7 +32,10 @@ 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.*;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentConfigurator;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import com.intellij.remoteServer.configuration.deployment.DeploymentSourceType;
|
||||
import com.intellij.remoteServer.impl.runtime.DeployToServerState;
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
@@ -91,7 +94,7 @@ public class DeployToServerRunConfiguration<S extends ServerConfiguration, D ext
|
||||
throw new ExecutionException("Server is not specified");
|
||||
}
|
||||
|
||||
RemoteServer<S> server = RemoteServersManager.getInstance().findByName(serverName, myServerType);
|
||||
RemoteServer<S> server = findServer();
|
||||
if (server == null) {
|
||||
throw new ExecutionException("Server '" + serverName + " not found");
|
||||
}
|
||||
@@ -105,6 +108,25 @@ public class DeployToServerRunConfiguration<S extends ServerConfiguration, D ext
|
||||
|
||||
@Override
|
||||
public void checkConfiguration() throws RuntimeConfigurationException {
|
||||
RemoteServer<S> server = findServer();
|
||||
if (server == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myDeploymentSource == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
myDeploymentConfiguration.checkConfiguration(server, myDeploymentSource);
|
||||
}
|
||||
|
||||
private RemoteServer<S> findServer() {
|
||||
String serverName = getServerName();
|
||||
if (serverName == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return RemoteServersManager.getInstance().findByName(serverName, myServerType);
|
||||
}
|
||||
|
||||
public void setServerName(String serverName) {
|
||||
|
||||
+15
-31
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package com.intellij.remoteServer.util;
|
||||
|
||||
import com.intellij.execution.configurations.RuntimeConfigurationException;
|
||||
import com.intellij.execution.configurations.RuntimeConfigurationWarning;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -29,7 +29,6 @@ import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
|
||||
import com.intellij.remoteServer.configuration.deployment.ModuleDeploymentSource;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@@ -42,57 +41,44 @@ public class CloudGitDeploymentChecker<
|
||||
SC extends ServerConfigurationBase,
|
||||
SR extends CloudMultiSourceServerRuntimeInstance<T, ?, ?, ?>> {
|
||||
|
||||
private GitRepositoryManager myGitRepositoryManager;
|
||||
|
||||
private final DeploymentSource myDeploymentSource;
|
||||
private final RemoteServer<SC> myServer;
|
||||
private final CloudDeploymentNameEditor<T> mySettingsEditor;
|
||||
private final CloudGitDeploymentDetector myDetector;
|
||||
|
||||
public CloudGitDeploymentChecker(DeploymentSource deploymentSource,
|
||||
RemoteServer<SC> server,
|
||||
CloudDeploymentNameEditor<T> settingsEditor,
|
||||
CloudGitDeploymentDetector detector) {
|
||||
myDeploymentSource = deploymentSource;
|
||||
myServer = server;
|
||||
mySettingsEditor = settingsEditor;
|
||||
public CloudGitDeploymentChecker(CloudGitDeploymentDetector detector) {
|
||||
myDetector = detector;
|
||||
}
|
||||
|
||||
public void checkGitUrl(final T settings) throws ConfigurationException {
|
||||
if (!(myDeploymentSource instanceof ModuleDeploymentSource)) {
|
||||
public void checkGitUrl(final RemoteServer<SC> server,
|
||||
final DeploymentSource deploymentSource,
|
||||
final T settings) throws RuntimeConfigurationException {
|
||||
if (!(deploymentSource instanceof ModuleDeploymentSource)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ModuleDeploymentSource moduleSource = (ModuleDeploymentSource)myDeploymentSource;
|
||||
ModuleDeploymentSource moduleSource = (ModuleDeploymentSource)deploymentSource;
|
||||
Module module = moduleSource.getModule();
|
||||
if (module == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
File contentRootFile = myDeploymentSource.getFile();
|
||||
File contentRootFile = deploymentSource.getFile();
|
||||
if (contentRootFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Project project = module.getProject();
|
||||
|
||||
if (myGitRepositoryManager == null) {
|
||||
myGitRepositoryManager = GitUtil.getRepositoryManager(project);
|
||||
}
|
||||
|
||||
VirtualFile contentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(contentRootFile);
|
||||
if (contentRoot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GitRepository repository = myGitRepositoryManager.getRepositoryForRoot(contentRoot);
|
||||
GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(contentRoot);
|
||||
if (repository == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String expectedName = settings.getDeploymentSourceName(myDeploymentSource);
|
||||
String expectedName = settings.getDeploymentSourceName(deploymentSource);
|
||||
|
||||
List<String> appNames = myDetector.collectApplicationNames(repository);
|
||||
if (appNames.isEmpty() || appNames.contains(expectedName)) {
|
||||
@@ -107,24 +93,22 @@ public class CloudGitDeploymentChecker<
|
||||
@Override
|
||||
public void run() {
|
||||
CloudGitApplication application
|
||||
= new CloudConnectionTask<CloudGitApplication, SC, T, SR>(project, "Searching for application", myServer) {
|
||||
= new CloudConnectionTask<CloudGitApplication, SC, T, SR>(project, "Searching for application", server) {
|
||||
|
||||
@Override
|
||||
protected CloudGitApplication run(SR serverRuntime) throws ServerRuntimeException {
|
||||
CloudGitDeploymentRuntime deploymentRuntime
|
||||
= (CloudGitDeploymentRuntime)serverRuntime.createDeploymentRuntime(myDeploymentSource, settings, project);
|
||||
= (CloudGitDeploymentRuntime)serverRuntime.createDeploymentRuntime(deploymentSource, settings, project);
|
||||
return deploymentRuntime.findApplication4Repository();
|
||||
}
|
||||
}.performSync();
|
||||
|
||||
if (application == null) {
|
||||
Messages.showErrorDialog(mySettingsEditor.getComponent(), "No application matching repository URL(s) found in account");
|
||||
Messages.showErrorDialog(project, "No application matching repository URL(s) found in account", server.getName());
|
||||
}
|
||||
else {
|
||||
T fixedSettings = mySettingsEditor.getFactory().create();
|
||||
fixedSettings.setDefaultDeploymentName(false);
|
||||
fixedSettings.setDeploymentName(application.getName());
|
||||
mySettingsEditor.resetFrom(fixedSettings);
|
||||
settings.setDefaultDeploymentName(false);
|
||||
settings.setDeploymentName(application.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user