Search in sources :

Example 1 with JavaExceptionBreakpointProperties

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

the class JavaExceptionBreakpointType method addBreakpoint.

//public Key<ExceptionBreakpoint> getBreakpointCategory() {
//  return ExceptionBreakpoint.CATEGORY;
//}
@Nullable
@Override
public XBreakpoint<JavaExceptionBreakpointProperties> addBreakpoint(final Project project, JComponent parentComponent) {
    final PsiClass throwableClass = JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_THROWABLE, GlobalSearchScope.allScope(project));
    TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project).createInheritanceClassChooser(DebuggerBundle.message("add.exception.breakpoint.classchooser.title"), GlobalSearchScope.allScope(project), throwableClass, true, true, null);
    chooser.showDialog();
    final PsiClass selectedClass = chooser.getSelected();
    final String qName = selectedClass == null ? null : JVMNameUtil.getNonAnonymousClassName(selectedClass);
    if (qName != null && qName.length() > 0) {
        return ApplicationManager.getApplication().runWriteAction(new Computable<XBreakpoint<JavaExceptionBreakpointProperties>>() {

            @Override
            public XBreakpoint<JavaExceptionBreakpointProperties> compute() {
                return XDebuggerManager.getInstance(project).getBreakpointManager().addBreakpoint(JavaExceptionBreakpointType.this, new JavaExceptionBreakpointProperties(qName, ((PsiClassOwner) selectedClass.getContainingFile()).getPackageName()));
            }
        });
    }
    return null;
}
Also used : TreeClassChooser(com.intellij.ide.util.TreeClassChooser) JavaExceptionBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) PsiClass(com.intellij.psi.PsiClass) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with JavaExceptionBreakpointProperties

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

the class JavaBreakpointFiltersPanel method loadFrom.

@Override
public void loadFrom(@NotNull B breakpoint) {
    myCatchFiltersPanel.setVisible(false);
    JavaBreakpointProperties properties = breakpoint.getProperties();
    if (properties != null) {
        if (properties.getCOUNT_FILTER() > 0) {
            myPassCountField.setText(Integer.toString(properties.getCOUNT_FILTER()));
        } else {
            myPassCountField.setText("");
        }
        myPassCountCheckbox.setSelected(properties.isCOUNT_FILTER_ENABLED());
        myInstanceFiltersCheckBox.setSelected(properties.isINSTANCE_FILTERS_ENABLED());
        myInstanceFilters = properties.getInstanceFilters();
        updateInstanceFilterEditor(true);
        myClassFiltersCheckBox.setSelected(properties.isCLASS_FILTERS_ENABLED());
        myClassFiltersField.setClassFilters(properties.getClassFilters(), properties.getClassExclusionFilters());
        if (properties instanceof JavaExceptionBreakpointProperties) {
            myCatchFiltersPanel.setVisible(true);
            JavaExceptionBreakpointProperties exceptionBreakpointProperties = (JavaExceptionBreakpointProperties) properties;
            myCatchCheckBox.setSelected(exceptionBreakpointProperties.isCatchFiltersEnabled());
            myCatchClassFilters.setClassFilters(exceptionBreakpointProperties.getCatchClassFilters(), exceptionBreakpointProperties.getCatchClassExclusionFilters());
        }
        XSourcePosition position = breakpoint.getSourcePosition();
    // TODO: need to calculate psi class
    //myBreakpointPsiClass = breakpoint.getPsiClass();
    }
    updateCheckboxes();
}
Also used : JavaExceptionBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties) JavaBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties) XSourcePosition(com.intellij.xdebugger.XSourcePosition)

Example 3 with JavaExceptionBreakpointProperties

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

the class BreakpointManager method doRead.

private void doRead(@NotNull final Element parentNode) {
    ApplicationManager.getApplication().runReadAction(() -> {
        final Map<String, Breakpoint> nameToBreakpointMap = new THashMap<>();
        try {
            final List groups = parentNode.getChildren();
            for (final Object group1 : groups) {
                final Element group = (Element) group1;
                if (group.getName().equals(RULES_GROUP_NAME)) {
                    continue;
                }
                // skip already converted
                if (group.getAttribute(CONVERTED_PARAM) != null) {
                    continue;
                }
                final String categoryName = group.getName();
                final Key<Breakpoint> breakpointCategory = BreakpointCategory.lookup(categoryName);
                final String defaultPolicy = group.getAttributeValue(DEFAULT_SUSPEND_POLICY_ATTRIBUTE_NAME);
                final boolean conditionEnabled = Boolean.parseBoolean(group.getAttributeValue(DEFAULT_CONDITION_STATE_ATTRIBUTE_NAME, "true"));
                setBreakpointDefaults(breakpointCategory, new BreakpointDefaults(defaultPolicy, conditionEnabled));
                Element anyExceptionBreakpointGroup;
                if (!AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.equals(breakpointCategory)) {
                    // for compatibility with previous format
                    anyExceptionBreakpointGroup = group.getChild(AnyExceptionBreakpoint.ANY_EXCEPTION_BREAKPOINT.toString());
                    //if (factory != null) {
                    for (Element breakpointNode : group.getChildren("breakpoint")) {
                        //Breakpoint breakpoint = factory.createBreakpoint(myProject, breakpointNode);
                        Breakpoint breakpoint = createBreakpoint(categoryName, breakpointNode);
                        breakpoint.readExternal(breakpointNode);
                        nameToBreakpointMap.put(breakpoint.getDisplayName(), breakpoint);
                    }
                //}
                } else {
                    anyExceptionBreakpointGroup = group;
                }
                if (anyExceptionBreakpointGroup != null) {
                    final Element breakpointElement = group.getChild("breakpoint");
                    if (breakpointElement != null) {
                        XBreakpointManager manager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
                        JavaExceptionBreakpointType type = XDebuggerUtil.getInstance().findBreakpointType(JavaExceptionBreakpointType.class);
                        XBreakpoint<JavaExceptionBreakpointProperties> xBreakpoint = manager.getDefaultBreakpoint(type);
                        Breakpoint breakpoint = getJavaBreakpoint(xBreakpoint);
                        if (breakpoint != null) {
                            breakpoint.readExternal(breakpointElement);
                            addBreakpoint(breakpoint);
                        }
                    }
                }
            }
        } catch (InvalidDataException ignored) {
        }
        final Element rulesGroup = parentNode.getChild(RULES_GROUP_NAME);
        if (rulesGroup != null) {
            final List<Element> rules = rulesGroup.getChildren("rule");
            for (Element rule : rules) {
                // skip already converted
                if (rule.getAttribute(CONVERTED_PARAM) != null) {
                    continue;
                }
                final Element master = rule.getChild(MASTER_BREAKPOINT_TAG_NAME);
                if (master == null) {
                    continue;
                }
                final Element slave = rule.getChild(SLAVE_BREAKPOINT_TAG_NAME);
                if (slave == null) {
                    continue;
                }
                final Breakpoint masterBreakpoint = nameToBreakpointMap.get(master.getAttributeValue("name"));
                if (masterBreakpoint == null) {
                    continue;
                }
                final Breakpoint slaveBreakpoint = nameToBreakpointMap.get(slave.getAttributeValue("name"));
                if (slaveBreakpoint == null) {
                    continue;
                }
                boolean leaveEnabled = "true".equalsIgnoreCase(rule.getAttributeValue("leaveEnabled"));
                XDependentBreakpointManager dependentBreakpointManager = ((XBreakpointManagerImpl) getXBreakpointManager()).getDependentBreakpointManager();
                dependentBreakpointManager.setMasterBreakpoint(slaveBreakpoint.myXBreakpoint, masterBreakpoint.myXBreakpoint, leaveEnabled);
            //addBreakpointRule(new EnableBreakpointRule(BreakpointManager.this, masterBreakpoint, slaveBreakpoint, leaveEnabled));
            }
        }
        DebuggerInvocationUtil.invokeLater(myProject, this::updateBreakpointsUI);
    });
    myUIProperties.clear();
    final Element props = parentNode.getChild("ui_properties");
    if (props != null) {
        final List children = props.getChildren("property");
        for (Object child : children) {
            Element property = (Element) child;
            final String name = property.getAttributeValue("name");
            final String value = property.getAttributeValue("value");
            if (name != null && value != null) {
                myUIProperties.put(name, value);
            }
        }
    }
}
Also used : XDependentBreakpointManager(com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager) JavaExceptionBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties) Element(org.jdom.Element) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl) THashMap(gnu.trove.THashMap) InvalidDataException(com.intellij.openapi.util.InvalidDataException) List(java.util.List)

Example 4 with JavaExceptionBreakpointProperties

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

the class JavaBreakpointFiltersPanel method saveTo.

@Override
public void saveTo(@NotNull B breakpoint) {
    JavaBreakpointProperties properties = breakpoint.getProperties();
    if (properties == null) {
        return;
    }
    boolean changed = false;
    try {
        String text = myPassCountField.getText().trim();
        int filter = !text.isEmpty() ? Integer.parseInt(text) : 0;
        if (filter < 0)
            filter = 0;
        changed = properties.setCOUNT_FILTER(filter);
    } catch (Exception ignored) {
    }
    changed = properties.setCOUNT_FILTER_ENABLED(properties.getCOUNT_FILTER() > 0 && myPassCountCheckbox.isSelected()) || changed;
    reloadInstanceFilters();
    updateInstanceFilterEditor(true);
    if (properties instanceof JavaExceptionBreakpointProperties) {
        JavaExceptionBreakpointProperties exceptionBreakpointProperties = (JavaExceptionBreakpointProperties) properties;
        changed = exceptionBreakpointProperties.setCatchFiltersEnabled(!myCatchClassFilters.getText().isEmpty() && myCatchCheckBox.isSelected()) || changed;
        changed = exceptionBreakpointProperties.setCatchClassFilters(myCatchClassFilters.getClassFilters()) || changed;
        changed = exceptionBreakpointProperties.setCatchClassExclusionFilters(myCatchClassFilters.getClassExclusionFilters()) || changed;
    }
    changed = properties.setCLASS_FILTERS_ENABLED(!myClassFiltersField.getText().isEmpty() && myClassFiltersCheckBox.isSelected()) || changed;
    changed = properties.setClassFilters(myClassFiltersField.getClassFilters()) || changed;
    changed = properties.setClassExclusionFilters(myClassFiltersField.getClassExclusionFilters()) || changed;
    changed = properties.setINSTANCE_FILTERS_ENABLED(!myInstanceFiltersField.getText().isEmpty() && myInstanceFiltersCheckBox.isSelected()) || changed;
    changed = properties.setInstanceFilters(myInstanceFilters) || changed;
    if (changed) {
        ((XBreakpointBase) breakpoint).fireBreakpointChanged();
    }
}
Also used : JavaExceptionBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties) XBreakpointBase(com.intellij.xdebugger.impl.breakpoints.XBreakpointBase) JavaBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint)

Aggregations

JavaExceptionBreakpointProperties (org.jetbrains.java.debugger.breakpoints.properties.JavaExceptionBreakpointProperties)4 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)2 JavaBreakpointProperties (org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties)2 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1 PsiClass (com.intellij.psi.PsiClass)1 XSourcePosition (com.intellij.xdebugger.XSourcePosition)1 XBreakpointBase (com.intellij.xdebugger.impl.breakpoints.XBreakpointBase)1 XBreakpointManagerImpl (com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)1 XDependentBreakpointManager (com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager)1 THashMap (gnu.trove.THashMap)1 List (java.util.List)1 Element (org.jdom.Element)1 Nullable (org.jetbrains.annotations.Nullable)1