use of com.intellij.openapi.progress.util.ProgressWindowWithNotification in project intellij-community by JetBrains.
the class MethodBreakpoint method createRequestForSubClasses.
private static void createRequestForSubClasses(@NotNull MethodBreakpointBase breakpoint, @NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType baseType) {
DebuggerManagerThreadImpl.assertIsManagerThread();
RequestManagerImpl requestsManager = debugProcess.getRequestsManager();
ClassPrepareRequest request = requestsManager.createClassPrepareRequest((debuggerProcess, referenceType) -> {
if (instanceOf(referenceType, baseType)) {
createRequestForPreparedClassEmulated(breakpoint, debugProcess, referenceType, false);
}
}, null);
if (request != null) {
requestsManager.registerRequest(breakpoint, request);
request.enable();
// to force reload classes available so far
debugProcess.getVirtualMachineProxy().clearCaches();
}
AtomicReference<ProgressIndicator> indicatorRef = new AtomicReference<>();
ApplicationManager.getApplication().invokeAndWait(() -> indicatorRef.set(new ProgressWindowWithNotification(true, false, debugProcess.getProject(), "Cancel emulation")));
ProgressIndicator indicator = indicatorRef.get();
ProgressManager.getInstance().executeProcessUnderProgress(() -> processPreparedSubTypes(baseType, subType -> createRequestForPreparedClassEmulated(breakpoint, debugProcess, subType, false), indicator), indicator);
if (indicator.isCanceled()) {
breakpoint.disableEmulation();
}
}
use of com.intellij.openapi.progress.util.ProgressWindowWithNotification in project intellij-community by JetBrains.
the class JavaWithRuntimeCastSurrounder method surroundExpression.
public TextRange surroundExpression(Project project, Editor editor, PsiExpression expr) throws IncorrectOperationException {
DebuggerContextImpl debuggerContext = (DebuggerManagerEx.getInstanceEx(project)).getContext();
DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
if (debuggerSession != null) {
final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, expr.getProject());
SurroundWithCastWorker worker = new SurroundWithCastWorker(editor, expr, debuggerContext, progressWindow);
progressWindow.setTitle(DebuggerBundle.message("title.evaluating"));
debuggerContext.getDebugProcess().getManagerThread().startProgress(worker, progressWindow);
}
return null;
}
use of com.intellij.openapi.progress.util.ProgressWindowWithNotification in project intellij-community by JetBrains.
the class JavaValueModifier method set.
protected void set(@NotNull final String expression, final XModificationCallback callback, final DebuggerContextImpl debuggerContext, final SetValueRunnable setValueRunnable) {
final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, debuggerContext.getProject());
final EvaluationContextImpl evaluationContext = myJavaValue.getEvaluationContext();
SuspendContextCommandImpl askSetAction = new DebuggerContextCommandImpl(debuggerContext) {
public Priority getPriority() {
return Priority.HIGH;
}
public void threadAction(@NotNull SuspendContextImpl suspendContext) {
ExpressionEvaluator evaluator;
try {
Project project = evaluationContext.getProject();
SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
PsiElement context = ContextUtil.getContextElement(evaluationContext, position);
evaluator = DebuggerInvocationUtil.commitAndRunReadAction(project, new EvaluatingComputable<ExpressionEvaluator>() {
public ExpressionEvaluator compute() throws EvaluateException {
return EvaluatorBuilderImpl.build(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expression), context, position, project);
}
});
setValue(expression, evaluator, evaluationContext, new SetValueRunnable() {
public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException, IncompatibleThreadStateException {
if (!progressWindow.isCanceled()) {
setValueRunnable.setValue(evaluationContext, newValue);
//node.calcValue();
}
}
public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, EvaluateException, IncompatibleThreadStateException, InvalidTypeException {
return setValueRunnable.loadClass(evaluationContext, className);
}
});
callback.valueModified();
} catch (EvaluateException e) {
callback.errorOccurred(e.getMessage());
}
//String initialString = "";
//if (descriptor instanceof ValueDescriptorImpl) {
// Value currentValue = ((ValueDescriptorImpl) descriptor).getValue();
// if (currentValue instanceof StringReference) {
// initialString = DebuggerUtilsEx.getValueOrErrorAsString(debuggerContext.createEvaluationContext(), currentValue);
// initialString = initialString == null ? "" : "\"" + DebuggerUtilsEx.translateStringValue(initialString) + "\"";
// }
// else if (currentValue instanceof PrimitiveValue) {
// ValueLabelRenderer renderer = ((ValueDescriptorImpl) descriptor).getRenderer(debuggerContext.getDebugProcess());
// initialString = getDisplayableString((PrimitiveValue) currentValue, renderer instanceof NodeRenderer && HexRenderer.UNIQUE_ID.equals(renderer.getUniqueId()));
// }
//
// final String initialString1 = initialString;
// final Project project = debuggerContext.getProject();
// DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
// public void run() {
// showEditor(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, initialString1), node, debuggerContext, setValueRunnable);
// }
// });
//}
}
};
progressWindow.setTitle(DebuggerBundle.message("title.evaluating"));
evaluationContext.getDebugProcess().getManagerThread().startProgress(askSetAction, progressWindow);
}
Aggregations