Search in sources :

Example 1 with XBreakpointManagerImpl

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

the class XSuspendPolicyPanel method init.

@Override
public void init(Project project, final XBreakpointManager breakpointManager, @NotNull XBreakpointBase breakpoint) {
    super.init(project, breakpointManager, breakpoint);
    mySuspendCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            boolean selected = mySuspendCheckBox.isSelected();
            if (myBreakpoint.getType().isSuspendThreadSupported()) {
                changeEnableState(selected);
            }
            if (myDelegate != null && !selected) {
                myDelegate.showMoreOptionsIfNeeded();
            }
        }
    });
    if (!myBreakpoint.getType().isSuspendThreadSupported()) {
        return;
    }
    updateSuspendPolicyFont();
    ItemListener suspendPolicyChangeListener = new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            updateMakeDefaultEnableState();
        }
    };
    updateMakeDefaultEnableState();
    mySuspendAll.addItemListener(suspendPolicyChangeListener);
    mySuspendThread.addItemListener(suspendPolicyChangeListener);
    myMakeDefaultButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SuspendPolicy suspendPolicy = getSelectedSuspendPolicy();
            ((XBreakpointManagerImpl) myBreakpointManager).getBreakpointDefaults(myBreakpointType).setSuspendPolicy(suspendPolicy);
            updateSuspendPolicyFont();
            if (SuspendPolicy.THREAD == suspendPolicy) {
                IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                    IdeFocusManager.getGlobalInstance().requestFocus(mySuspendThread, true);
                });
            } else {
                IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                    IdeFocusManager.getGlobalInstance().requestFocus(mySuspendAll, true);
                });
            }
            myMakeDefaultButton.setEnabled(false);
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) SuspendPolicy(com.intellij.xdebugger.breakpoints.SuspendPolicy) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ItemListener(java.awt.event.ItemListener) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)

Example 2 with XBreakpointManagerImpl

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

the class ToggleBreakpointEnabledAction method findLineBreakpoints.

@NotNull
private static Set<XLineBreakpoint> findLineBreakpoints(AnActionEvent e) {
    Project project = e.getProject();
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (project == null || editor == null)
        return Collections.emptySet();
    XBreakpointManagerImpl breakpointManager = (XBreakpointManagerImpl) XDebuggerManager.getInstance(project).getBreakpointManager();
    XLineBreakpointManager lineBreakpointManager = breakpointManager.getLineBreakpointManager();
    Document document = editor.getDocument();
    Collection<Range<Integer>> lineRanges = new ArrayList<>();
    for (Caret caret : editor.getCaretModel().getAllCarets()) {
        lineRanges.add(new Range<>(document.getLineNumber(caret.getSelectionStart()), document.getLineNumber(caret.getSelectionEnd())));
    }
    Collection<XLineBreakpointImpl> breakpoints = lineBreakpointManager.getDocumentBreakpoints(document);
    HashSet<XLineBreakpoint> res = new HashSet<>();
    for (XLineBreakpointImpl breakpoint : breakpoints) {
        int line = breakpoint.getLine();
        for (Range<Integer> range : lineRanges) {
            if (range.isWithin(line)) {
                res.add(breakpoint);
            }
        }
    }
    return res;
}
Also used : XLineBreakpointImpl(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl) XLineBreakpointManager(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointManager) Document(com.intellij.openapi.editor.Document) Range(com.intellij.util.Range) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl) Project(com.intellij.openapi.project.Project) Editor(com.intellij.openapi.editor.Editor) Caret(com.intellij.openapi.editor.Caret) HashSet(com.intellij.util.containers.HashSet) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with XBreakpointManagerImpl

use of com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl 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)

Aggregations

XBreakpointManagerImpl (com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)3 Caret (com.intellij.openapi.editor.Caret)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1 Range (com.intellij.util.Range)1 HashSet (com.intellij.util.containers.HashSet)1 SuspendPolicy (com.intellij.xdebugger.breakpoints.SuspendPolicy)1 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 XDependentBreakpointManager (com.intellij.xdebugger.impl.breakpoints.XDependentBreakpointManager)1 XLineBreakpointImpl (com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl)1 XLineBreakpointManager (com.intellij.xdebugger.impl.breakpoints.XLineBreakpointManager)1 THashMap (gnu.trove.THashMap)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 List (java.util.List)1 Element (org.jdom.Element)1