Search in sources :

Example 1 with XBreakpointAdapter

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

the class DebuggerUIUtil method showXBreakpointEditorBalloon.

public static void showXBreakpointEditorBalloon(final Project project, @Nullable final Point point, final JComponent component, final boolean showAllOptions, final XBreakpoint breakpoint) {
    final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
    final XLightBreakpointPropertiesPanel propertiesPanel = new XLightBreakpointPropertiesPanel(project, breakpointManager, (XBreakpointBase) breakpoint, showAllOptions);
    final Ref<Balloon> balloonRef = Ref.create(null);
    final Ref<Boolean> isLoading = Ref.create(Boolean.FALSE);
    final Ref<Boolean> moreOptionsRequested = Ref.create(Boolean.FALSE);
    propertiesPanel.setDelegate(() -> {
        if (!isLoading.get()) {
            propertiesPanel.saveProperties();
        }
        if (!balloonRef.isNull()) {
            balloonRef.get().hide();
        }
        showXBreakpointEditorBalloon(project, point, component, true, breakpoint);
        moreOptionsRequested.set(true);
    });
    isLoading.set(Boolean.TRUE);
    propertiesPanel.loadProperties();
    isLoading.set(Boolean.FALSE);
    if (moreOptionsRequested.get()) {
        return;
    }
    Runnable showMoreOptions = () -> {
        propertiesPanel.saveProperties();
        propertiesPanel.dispose();
        BreakpointsDialogFactory.getInstance(project).showDialog(breakpoint);
    };
    final JComponent mainPanel = propertiesPanel.getMainPanel();
    final Balloon balloon = showBreakpointEditor(project, mainPanel, point, component, showMoreOptions, breakpoint);
    balloonRef.set(balloon);
    final XBreakpointListener<XBreakpoint<?>> breakpointListener = new XBreakpointAdapter<XBreakpoint<?>>() {

        @Override
        public void breakpointRemoved(@NotNull XBreakpoint<?> removedBreakpoint) {
            if (removedBreakpoint.equals(breakpoint)) {
                balloon.hide();
            }
        }
    };
    balloon.addListener(new JBPopupListener.Adapter() {

        @Override
        public void onClosed(LightweightWindowEvent event) {
            propertiesPanel.saveProperties();
            propertiesPanel.dispose();
            breakpointManager.removeBreakpointListener(breakpointListener);
        }
    });
    breakpointManager.addBreakpointListener(breakpointListener);
    ApplicationManager.getApplication().invokeLater(() -> IdeFocusManager.findInstance().requestFocus(mainPanel, true));
}
Also used : XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) XLightBreakpointPropertiesPanel(com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel) NotNull(org.jetbrains.annotations.NotNull) XBreakpointManager(com.intellij.xdebugger.breakpoints.XBreakpointManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) XBreakpointAdapter(com.intellij.xdebugger.breakpoints.XBreakpointAdapter)

Aggregations

XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)1 XBreakpointAdapter (com.intellij.xdebugger.breakpoints.XBreakpointAdapter)1 XBreakpointManager (com.intellij.xdebugger.breakpoints.XBreakpointManager)1 XLightBreakpointPropertiesPanel (com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 NotNull (org.jetbrains.annotations.NotNull)1