Search in sources :

Example 1 with JavaFieldBreakpointProperties

use of org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties in project intellij-community by JetBrains.

the class JavaFieldBreakpointType method addBreakpoint.

@Nullable
@Override
public XLineBreakpoint<JavaFieldBreakpointProperties> addBreakpoint(final Project project, JComponent parentComponent) {
    final Ref<XLineBreakpoint<JavaFieldBreakpointProperties>> result = Ref.create(null);
    AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) {

        protected boolean validateData() {
            final String className = getClassName();
            if (className.length() == 0) {
                Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"), DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
                return false;
            }
            final String fieldName = getFieldName();
            if (fieldName.length() == 0) {
                Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"), DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
                return false;
            }
            PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.allScope(project));
            if (psiClass != null) {
                final PsiFile psiFile = psiClass.getContainingFile();
                Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
                if (document != null) {
                    PsiField field = psiClass.findFieldByName(fieldName, true);
                    if (field != null) {
                        final int line = document.getLineNumber(field.getTextOffset());
                        ApplicationManager.getApplication().runWriteAction(() -> {
                            XLineBreakpoint<JavaFieldBreakpointProperties> fieldBreakpoint = XDebuggerManager.getInstance(project).getBreakpointManager().addLineBreakpoint(JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(), line, new JavaFieldBreakpointProperties(fieldName, className));
                            result.set(fieldBreakpoint);
                        });
                        return true;
                    } else {
                        Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.field.not.found", className, fieldName, fieldName), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
                    }
                }
            } else {
                Messages.showMessageDialog(project, DebuggerBundle.message("error.field.breakpoint.class.sources.not.found", className, fieldName, className), CommonBundle.getErrorTitle(), Messages.getErrorIcon());
            }
            return false;
        }
    };
    dialog.show();
    return result.get();
}
Also used : JavaFieldBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties) Document(com.intellij.openapi.editor.Document) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with JavaFieldBreakpointProperties

use of org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties in project intellij-community by JetBrains.

the class JavaFieldBreakpointType method getText.

public String getText(XLineBreakpoint<JavaFieldBreakpointProperties> breakpoint) {
    //if(!isValid()) {
    //  return DebuggerBundle.message("status.breakpoint.invalid");
    //}
    JavaFieldBreakpointProperties properties = breakpoint.getProperties();
    final String className = properties.myClassName;
    return className != null && !className.isEmpty() ? className + "." + properties.myFieldName : properties.myFieldName;
}
Also used : JavaFieldBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties)

Aggregations

JavaFieldBreakpointProperties (org.jetbrains.java.debugger.breakpoints.properties.JavaFieldBreakpointProperties)2 Document (com.intellij.openapi.editor.Document)1 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)1 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 Nullable (org.jetbrains.annotations.Nullable)1