[debugger] do not allow exceptions in breakpoints text customizers break the breakpoints dialog

GitOrigin-RevId: 16350880fe91570220a4a72019d86cb39c418b2b
This commit is contained in:
Egor Ushakov
2024-08-20 17:59:49 +02:00
committed by intellij-monorepo-bot
parent f4a917f47e
commit bdab28563f
2 changed files with 27 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xdebugger.impl.breakpoints.ui;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
@@ -20,6 +21,7 @@ import java.awt.event.ItemListener;
import java.util.List;
public class BreakpointChooser {
private static final Logger LOG = Logger.getInstance(BreakpointChooser.class);
private DetailView myDetailViewDelegate;
@@ -108,13 +110,20 @@ public class BreakpointChooser {
myComboBox.setRenderer(new ItemWrapperListRenderer(project, null) {
@Override
protected void customizeCellRenderer(@NotNull JList list, Object value, int index, boolean selected, boolean hasFocus) {
super.customizeCellRenderer(list, value, index, selected, hasFocus);
if (selected) {
if (hackedSelection.get() != value) {
hackedSelection.set(value);
myDetailController.updateDetailView();
try {
super.customizeCellRenderer(list, value, index, selected, hasFocus);
if (selected) {
if (hackedSelection.get() != value) {
hackedSelection.set(value);
myDetailController.updateDetailView();
}
}
}
catch (Exception e) {
LOG.error(e);
clear();
append(e.getMessage());
}
}
});

View File

@@ -1,20 +1,7 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.xdebugger.impl.breakpoints.ui.tree;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.ui.CheckboxTree;
import com.intellij.ui.ColoredTreeCellRenderer;
@@ -27,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
class BreakpointsTreeCellRenderer {
private static final Logger LOG = Logger.getInstance(BreakpointsTreeCellRenderer.class);
private static final SimpleTextAttributes SIMPLE_CELL_ATTRIBUTES_BOLD = SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES.derive(SimpleTextAttributes.STYLE_BOLD, null, null, null);
private static void customizeRenderer(Project project,
@@ -59,7 +47,15 @@ class BreakpointsTreeCellRenderer {
@Override
public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
BreakpointsTreeCellRenderer.customizeRenderer(myProject, value, selected, expanded, getTextRenderer());
ColoredTreeCellRenderer textRenderer = getTextRenderer();
try {
BreakpointsTreeCellRenderer.customizeRenderer(myProject, value, selected, expanded, textRenderer);
}
catch (Exception e) {
LOG.error(e);
textRenderer.clear();
textRenderer.append(e.getMessage());
}
}
}