mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-54188 add a configuration option to preselect/automate disconnection and process termination on termination of a debugging session - replace checkbox with a button, freeing space for "do not ask again" option
This commit is contained in:
@@ -18,59 +18,28 @@ package com.intellij.execution;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TerminateRemoteProcessDialog {
|
||||
public static int show(final Project project,
|
||||
final String sessionName,
|
||||
final TerminateOption option) {
|
||||
final String message = option.myAlwaysUseDefault && !option.myDetach ?
|
||||
ExecutionBundle.message("terminate.process.confirmation.text", sessionName) :
|
||||
ExecutionBundle.message("disconnect.process.confirmation.text", sessionName);
|
||||
final String okButtonText = option.myAlwaysUseDefault && !option.myDetach ?
|
||||
ExecutionBundle.message("button.terminate") :
|
||||
ExecutionBundle.message("button.disconnect");
|
||||
final String[] options = new String[] {okButtonText, CommonBundle.getCancelButtonText()};
|
||||
return Messages.showDialog(project, message, ExecutionBundle.message("process.is.running.dialog.title", sessionName),
|
||||
options, 0, Messages.getWarningIcon(),
|
||||
option);
|
||||
}
|
||||
|
||||
public static class TerminateOption implements DialogWrapper.DoNotAskOption {
|
||||
private boolean myDetach;
|
||||
private final boolean myAlwaysUseDefault;
|
||||
|
||||
public TerminateOption(boolean detachIsDefault, boolean alwaysUseDefault) {
|
||||
myDetach = detachIsDefault;
|
||||
myAlwaysUseDefault = alwaysUseDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isToBeShown() {
|
||||
return myDetach;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToBeShown(boolean value, int exitCode) {
|
||||
myDetach = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
return !myAlwaysUseDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSaveOptionsOnCancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDoNotShowMessage() {
|
||||
return ExecutionBundle.message("terminate.after.disconnect.checkbox");
|
||||
boolean canDisconnect,
|
||||
boolean defaultDisconnect) {
|
||||
List<String> options = new ArrayList<>(3);
|
||||
options.add(ExecutionBundle.message("button.terminate"));
|
||||
if (canDisconnect) {
|
||||
options.add(ExecutionBundle.message("button.disconnect"));
|
||||
}
|
||||
options.add(CommonBundle.getCancelButtonText());
|
||||
return Messages.showDialog(project,
|
||||
ExecutionBundle.message("terminate.process.confirmation.text", sessionName),
|
||||
ExecutionBundle.message("process.is.running.dialog.title", sessionName),
|
||||
ArrayUtil.toStringArray(options),
|
||||
canDisconnect && defaultDisconnect ? 1 : 0,
|
||||
Messages.getWarningIcon());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -35,7 +35,6 @@ import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerListener;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -621,11 +620,20 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
|
||||
}
|
||||
else {
|
||||
//todo[nik] this is a temporary solution for the following problem: some configurations should not allow user to choose between 'terminating' and 'detaching'
|
||||
final boolean useDefault = Boolean.TRUE.equals(processHandler.getUserData(ALWAYS_USE_DEFAULT_STOPPING_BEHAVIOUR_KEY));
|
||||
final TerminateRemoteProcessDialog.TerminateOption option = new TerminateRemoteProcessDialog.TerminateOption(processHandler.detachIsDefault(), useDefault);
|
||||
final int rc = TerminateRemoteProcessDialog.show(myProject, descriptor.getDisplayName(), option);
|
||||
if (rc != DialogWrapper.OK_EXIT_CODE) return false;
|
||||
destroyProcess = !option.isToBeShown();
|
||||
boolean canDisconnect = !Boolean.TRUE.equals(processHandler.getUserData(ALWAYS_USE_DEFAULT_STOPPING_BEHAVIOUR_KEY));
|
||||
int rc = TerminateRemoteProcessDialog.show(myProject, descriptor.getDisplayName(), canDisconnect, processHandler.detachIsDefault());
|
||||
switch (rc) {
|
||||
case 0: // terminate
|
||||
destroyProcess = true;
|
||||
break;
|
||||
case 1:
|
||||
if (canDisconnect) { // detach
|
||||
destroyProcess = false;
|
||||
break;
|
||||
}
|
||||
default: // cancel
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (destroyProcess) {
|
||||
processHandler.destroyProcess();
|
||||
|
||||
Reference in New Issue
Block a user