use of com.google.cloud.tools.intellij.debugger.ui.CloudAttachDialog in project google-cloud-intellij by GoogleCloudPlatform.
the class CloudDebuggerRunner method createContentDescriptor.
private static RunContentDescriptor createContentDescriptor(@Nullable final CloudDebugProcessState processState, @NotNull final ExecutionEnvironment environment) throws ExecutionException {
final XDebugSession debugSession = XDebuggerManager.getInstance(environment.getProject()).startSession(environment, new XDebugProcessStarter() {
@NotNull
@Override
public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
// Clear out the stash state which is queried on debug exit.
if (processState != null) {
ProjectRepositoryState.fromProcessState(processState).clearForNextSession();
}
CloudDebugProcessState state = processState;
CloudAttachDialog attachDialog = new CloudAttachDialog(session.getProject(), null);
attachDialog.setInputState(state);
DialogManager.show(attachDialog);
state = attachDialog.getResultState();
ProjectRepositoryValidator validator = null;
if (state != null) {
validator = new ProjectRepositoryValidator(state);
}
if (!attachDialog.isOK() || state == null || !validator.isValidDebuggee()) {
throw new RunCanceledByUserException();
}
if (environment.getRunnerAndConfigurationSettings() != null && environment.getRunnerAndConfigurationSettings().getConfiguration() instanceof CloudDebugRunConfiguration) {
CloudDebugRunConfiguration config = (CloudDebugRunConfiguration) environment.getRunnerAndConfigurationSettings().getConfiguration();
// State is only stored in the run config between active sessions.
// Otherwise, the background watcher may hit a check during debug session
// startup.
config.setProcessState(null);
}
CloudDebugProcess process = new CloudDebugProcess(session);
process.initialize(state);
return process;
}
});
RunnerLayoutUi ui = debugSession.getUI();
if (ui instanceof DataProvider) {
final RunnerContentUi contentUi = (RunnerContentUi) ((DataProvider) ui).getData(RunnerContentUi.KEY.getName());
final Project project = debugSession.getProject();
if (contentUi != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (project.isOpen() && !project.isDisposed()) {
contentUi.restoreLayout();
}
}
});
}
}
return debugSession.getRunContentDescriptor();
}
Aggregations