mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
breakpoints ui. small cosmetic fixes
This commit is contained in:
+3
-10
@@ -17,7 +17,6 @@ package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.SourcePosition;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -34,7 +33,7 @@ import javax.swing.*;
|
||||
* Time: 3:16
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
class JavaBreakpointItem implements BreakpointItem {
|
||||
class JavaBreakpointItem extends BreakpointItem {
|
||||
private final Breakpoint myBreakpoint;
|
||||
private BreakpointFactory myBreakpointFactory;
|
||||
|
||||
@@ -56,13 +55,7 @@ class JavaBreakpointItem implements BreakpointItem {
|
||||
|
||||
@Override
|
||||
public void execute(Project project, JBPopup popup) {
|
||||
if (myBreakpoint instanceof BreakpointWithHighlighter) {
|
||||
final SourcePosition position = ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition();
|
||||
if (position != null) {
|
||||
position.navigate(true);
|
||||
popup.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,7 +88,7 @@ class JavaBreakpointItem implements BreakpointItem {
|
||||
if (myBreakpoint instanceof BreakpointWithHighlighter) {
|
||||
SourcePosition sourcePosition = ((BreakpointWithHighlighter)myBreakpoint).getSourcePosition();
|
||||
VirtualFile virtualFile = sourcePosition.getFile().getVirtualFile();
|
||||
panel.navigateInPreviewEditor(virtualFile, new LogicalPosition(sourcePosition.getLine(), 0));
|
||||
showInEditor(panel, virtualFile, sourcePosition.getLine());
|
||||
} else {
|
||||
panel.clearEditor();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.ui.popup.util;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -34,7 +35,7 @@ public interface DetailView {
|
||||
|
||||
Editor getEditor();
|
||||
|
||||
void navigateInPreviewEditor(VirtualFile file, LogicalPosition positionToNavigate);
|
||||
void navigateInPreviewEditor(VirtualFile file, LogicalPosition positionToNavigate, TextAttributes lineAttributes);
|
||||
|
||||
JPanel getDetailPanel();
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class BookmarkItem implements ItemWrapper {
|
||||
VirtualFile file = myBookmark.getFile();
|
||||
LogicalPosition positionToNavigate = new LogicalPosition(myBookmark.getLine(), 0);
|
||||
|
||||
panel.navigateInPreviewEditor(file, positionToNavigate);
|
||||
panel.navigateInPreviewEditor(file, positionToNavigate, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,9 @@ import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighter;
|
||||
import com.intellij.openapi.editor.highlighter.EditorHighlighterFactory;
|
||||
import com.intellij.openapi.editor.markup.HighlighterLayer;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -46,6 +49,7 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
private JPanel myDetailPanelWrapper;
|
||||
private JLabel myNothingToShow = new JLabel("Nothing to show");
|
||||
private JLabel myNothingToShowInEditor = new JLabel("Nothing to show");
|
||||
private RangeHighlighter myHighlighter;
|
||||
|
||||
public DetailViewImpl(Project project) {
|
||||
super(new BorderLayout());
|
||||
@@ -74,6 +78,7 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
@Override
|
||||
public void clearEditor() {
|
||||
if (getEditor() != null) {
|
||||
clearHightlighting();
|
||||
remove(getEditor().getComponent());
|
||||
EditorFactory.getInstance().releaseEditor(getEditor());
|
||||
setEditor(null);
|
||||
@@ -98,7 +103,7 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateInPreviewEditor(VirtualFile file, LogicalPosition positionToNavigate) {
|
||||
public void navigateInPreviewEditor(VirtualFile file, LogicalPosition positionToNavigate, @Nullable TextAttributes lineAttributes) {
|
||||
Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
Project project = myProject;
|
||||
|
||||
@@ -123,6 +128,13 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
getEditor().getCaretModel().moveToLogicalPosition(positionToNavigate);
|
||||
validate();
|
||||
getEditor().getScrollingModel().scrollToCaret(ScrollType.CENTER);
|
||||
|
||||
clearHightlighting();
|
||||
if (lineAttributes != null){
|
||||
myHighlighter = getEditor().getMarkupModel().addLineHighlighter(positionToNavigate.line, HighlighterLayer.SELECTION - 1,
|
||||
lineAttributes);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
clearEditor();
|
||||
@@ -133,6 +145,13 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
}
|
||||
}
|
||||
|
||||
private void clearHightlighting() {
|
||||
if (myHighlighter != null) {
|
||||
getEditor().getMarkupModel().removeHighlighter(myHighlighter);
|
||||
myHighlighter = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getDetailPanel() {
|
||||
return myDetailPanel;
|
||||
@@ -145,7 +164,7 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
if (panel != null) {
|
||||
if (myDetailScrollPanel == null) {
|
||||
myDetailPanelWrapper = new JPanel(new GridLayout(1, 1));
|
||||
myDetailPanelWrapper.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
|
||||
myDetailPanelWrapper.setBorder(BorderFactory.createEmptyBorder(5, 30, 5, 10));
|
||||
myDetailPanelWrapper.add(panel);
|
||||
|
||||
myDetailScrollPanel =
|
||||
@@ -156,6 +175,7 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
return new Dimension(size.width, size.height + 10);
|
||||
}
|
||||
};
|
||||
myDetailScrollPanel.setBorder(null);
|
||||
add(myDetailScrollPanel, BorderLayout.SOUTH);
|
||||
} else {
|
||||
myDetailPanelWrapper.removeAll();
|
||||
|
||||
+20
-4
@@ -15,7 +15,15 @@
|
||||
*/
|
||||
package com.intellij.xdebugger.breakpoints.ui;
|
||||
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.ui.popup.util.ItemWrapper;
|
||||
import com.intellij.xdebugger.ui.DebuggerColors;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
@@ -24,10 +32,18 @@ import com.intellij.ui.popup.util.ItemWrapper;
|
||||
* Time: 4:48 AM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface BreakpointItem extends ItemWrapper {
|
||||
Object getBreakpoint();
|
||||
public abstract class BreakpointItem implements ItemWrapper {
|
||||
public abstract Object getBreakpoint();
|
||||
|
||||
boolean isEnabled();
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
void setEnabled(boolean state);
|
||||
public abstract void setEnabled(boolean state);
|
||||
|
||||
protected void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
|
||||
final TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(
|
||||
DebuggerColors.BREAKPOINT_ATTRIBUTES).clone();
|
||||
final Color color = attributes.getBackgroundColor();
|
||||
attributes.setBackgroundColor(new Color(color.getRed(), color.getGreen()-100, color.getBlue()-100));
|
||||
panel.navigateInPreviewEditor(virtualFile, new LogicalPosition(line, 0), attributes);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-8
@@ -17,7 +17,6 @@ package com.intellij.xdebugger.impl.breakpoints;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
@@ -36,7 +35,7 @@ import javax.swing.*;
|
||||
* Time: 1:14
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
class XBreakpointItem implements BreakpointItem {
|
||||
class XBreakpointItem extends BreakpointItem {
|
||||
private final XBreakpoint<?> myBreakpoint;
|
||||
|
||||
public XBreakpointItem(XBreakpoint<?> breakpoint) {
|
||||
@@ -60,11 +59,6 @@ class XBreakpointItem implements BreakpointItem {
|
||||
|
||||
@Override
|
||||
public void execute(Project project, JBPopup popup) {
|
||||
final XSourcePosition position = myBreakpoint.getSourcePosition();
|
||||
if (position != null) {
|
||||
position.createNavigatable(project).navigate(true);
|
||||
popup.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +82,7 @@ class XBreakpointItem implements BreakpointItem {
|
||||
|
||||
XSourcePosition sourcePosition = myBreakpoint.getSourcePosition();
|
||||
if (sourcePosition != null) {
|
||||
panel.navigateInPreviewEditor(sourcePosition.getFile(), new LogicalPosition(sourcePosition.getLine(), sourcePosition.getOffset()));
|
||||
showInEditor(panel, sourcePosition.getFile(), sourcePosition.getLine());
|
||||
} else {
|
||||
panel.clearEditor();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user