Search in sources :

Example 1 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint 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 XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.

the class XBreakpointActionsPanel method saveProperties.

@Override
void saveProperties() {
    myBreakpoint.setLogMessage(myLogMessageCheckBox.isSelected());
    if (myBreakpoint instanceof XLineBreakpoint) {
        ((XLineBreakpoint) myBreakpoint).setTemporary(myTemporaryCheckBox.isSelected());
    }
    if (myLogExpressionComboBox != null) {
        XExpression expression = myLogExpressionComboBox.getExpression();
        XExpression logExpression = !XDebuggerUtilImpl.isEmptyExpression(expression) ? expression : null;
        myBreakpoint.setLogExpressionEnabled(logExpression == null || myLogExpressionCheckBox.isSelected());
        myBreakpoint.setLogExpressionObject(logExpression);
        myLogExpressionComboBox.saveTextInHistory();
    }
}
Also used : XExpression(com.intellij.xdebugger.XExpression) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Example 3 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.

the class XBreakpointActionsPanel method init.

public void init(Project project, XBreakpointManager breakpointManager, @NotNull XBreakpointBase breakpoint, @Nullable XDebuggerEditorsProvider debuggerEditorsProvider) {
    init(project, breakpointManager, breakpoint);
    if (debuggerEditorsProvider != null) {
        ActionListener listener = new ActionListener() {

            public void actionPerformed(final ActionEvent e) {
                onCheckboxChanged();
            }
        };
        myLogExpressionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, LOG_EXPRESSION_HISTORY_ID, myBreakpoint.getSourcePosition(), true);
        JComponent logExpressionComponent = myLogExpressionComboBox.getComponent();
        myLogExpressionPanel.add(logExpressionComponent, BorderLayout.CENTER);
        myLogExpressionComboBox.setEnabled(false);
        boolean isLineBreakpoint = breakpoint instanceof XLineBreakpoint;
        myTemporaryCheckBox.setVisible(isLineBreakpoint);
        if (isLineBreakpoint) {
            myTemporaryCheckBox.addActionListener(e -> ((XLineBreakpoint) myBreakpoint).setTemporary(myTemporaryCheckBox.isSelected()));
        }
        myLogExpressionCheckBox.addActionListener(listener);
        DebuggerUIUtil.focusEditorOnCheck(myLogExpressionCheckBox, myLogExpressionComboBox.getEditorComponent());
    } else {
        myExpressionPanel.getParent().remove(myExpressionPanel);
    }
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) XDebuggerExpressionComboBox(com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Example 4 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.

the class XBreakpointActionsPanel method loadProperties.

@Override
void loadProperties() {
    myLogMessageCheckBox.setSelected(myBreakpoint.isLogMessage());
    if (myBreakpoint instanceof XLineBreakpoint) {
        myTemporaryCheckBox.setSelected(((XLineBreakpoint) myBreakpoint).isTemporary());
    }
    if (myLogExpressionComboBox != null) {
        XExpression logExpression = myBreakpoint.getLogExpressionObjectInt();
        myLogExpressionComboBox.setExpression(logExpression);
        myLogExpressionCheckBox.setSelected(myBreakpoint.isLogExpressionEnabled() && logExpression != null);
    }
    onCheckboxChanged();
}
Also used : XExpression(com.intellij.xdebugger.XExpression) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Example 5 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.

the class XBreakpointFileGroupingRule method getGroup.

public XBreakpointFileGroup getGroup(@NotNull final B breakpoint, @NotNull final Collection<XBreakpointFileGroup> groups) {
    if (!(breakpoint instanceof XLineBreakpoint)) {
        return null;
    }
    XSourcePosition position = ((XLineBreakpoint) breakpoint).getSourcePosition();
    if (position == null)
        return null;
    VirtualFile file = position.getFile();
    for (XBreakpointFileGroup group : groups) {
        if (group.getFile().equals(file)) {
            return group;
        }
    }
    return new XBreakpointFileGroup(file);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XSourcePosition(com.intellij.xdebugger.XSourcePosition) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Aggregations

XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)12 Project (com.intellij.openapi.project.Project)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 XSourcePosition (com.intellij.xdebugger.XSourcePosition)3 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)3 Document (com.intellij.openapi.editor.Document)2 XExpression (com.intellij.xdebugger.XExpression)2 XBreakpointProperties (com.intellij.xdebugger.breakpoints.XBreakpointProperties)2 VMPausedException (org.intellij.plugins.xsltDebugger.VMPausedException)2 Breakpoint (org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint)2 BreakpointManager (org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager)2 DebuggerStoppedException (org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)2 Caret (com.intellij.openapi.editor.Caret)1 Editor (com.intellij.openapi.editor.Editor)1 Range (com.intellij.util.Range)1 HashSet (com.intellij.util.containers.HashSet)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 XBreakpointHandler (com.intellij.xdebugger.breakpoints.XBreakpointHandler)1 XBreakpointManagerImpl (com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)1 XLineBreakpointImpl (com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl)1