mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
BreakpointItem class moved from api to impl
This commit is contained in:
@@ -35,7 +35,7 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xdebugger.AbstractDebuggerSession;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
import com.intellij.xdebugger.impl.actions.DebuggerActionHandler;
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.ui.popup.util.ItemWrapper;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointMasterDetailPopupBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
+156
-156
@@ -1,156 +1,156 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.breakpoints;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
class XBreakpointItem extends BreakpointItem {
|
||||
private final XBreakpoint<?> myBreakpoint;
|
||||
|
||||
public XBreakpointItem(XBreakpoint<?> breakpoint) {
|
||||
myBreakpoint = breakpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
|
||||
setupGenericRenderer(renderer, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredTreeCellRenderer renderer) {
|
||||
setupGenericRenderer(renderer, false);
|
||||
}
|
||||
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
|
||||
if (plainView) {
|
||||
renderer.setIcon(getIcon());
|
||||
}
|
||||
final SimpleTextAttributes attributes =
|
||||
myBreakpoint.isEnabled() ? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES;
|
||||
renderer.append(getDisplayText(), attributes);
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return XBreakpointUtil.getShortText(myBreakpoint);
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return ((XBreakpointBase)myBreakpoint).getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String speedSearchText() {
|
||||
return ((XBreakpointBase)myBreakpoint).getType().getDisplayText(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String footerText() {
|
||||
return ((XBreakpointBase)myBreakpoint).getType().getDisplayText(myBreakpoint);
|
||||
}
|
||||
|
||||
public void doUpdateDetailView(DetailView panel, boolean editorOnly) {
|
||||
Project project = ((XBreakpointBase)myBreakpoint).getProject();
|
||||
if (!editorOnly) {
|
||||
|
||||
XLightBreakpointPropertiesPanel<XBreakpoint<?>> propertiesPanel =
|
||||
new XLightBreakpointPropertiesPanel<XBreakpoint<?>>(project, getManager(), myBreakpoint, true);
|
||||
propertiesPanel.loadProperties();
|
||||
panel.setDetailPanel(propertiesPanel.getMainPanel());
|
||||
}
|
||||
|
||||
XSourcePosition sourcePosition = myBreakpoint.getSourcePosition();
|
||||
if (sourcePosition != null) {
|
||||
showInEditor(panel, sourcePosition.getFile(), sourcePosition.getLine());
|
||||
}
|
||||
else {
|
||||
panel.clearEditor();
|
||||
}
|
||||
panel.getDetailPanel().revalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean navigate() {
|
||||
Navigatable navigatable = myBreakpoint.getNavigatable();
|
||||
if (navigatable != null) {
|
||||
navigatable.navigate(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private XBreakpointManagerImpl getManager() {
|
||||
return ((XBreakpointBase)myBreakpoint).getBreakpointManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowedToRemove() {
|
||||
return !getManager().isDefaultBreakpoint(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(Project project) {
|
||||
final XBreakpointManagerImpl breakpointManager = getManager();
|
||||
new WriteAction() {
|
||||
protected void run(final Result result) {
|
||||
breakpointManager.removeBreakpoint(myBreakpoint);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBreakpoint() {
|
||||
return myBreakpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return myBreakpoint.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean state) {
|
||||
myBreakpoint.setEnabled(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBreakpoint() {
|
||||
return getManager().isDefaultBreakpoint(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(BreakpointItem breakpointItem) {
|
||||
if (breakpointItem.getBreakpoint() instanceof XBreakpointBase) {
|
||||
return ((XBreakpointBase)myBreakpoint).compareTo((XBreakpoint)breakpointItem.getBreakpoint());
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.breakpoints;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.xdebugger.XSourcePosition;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
class XBreakpointItem extends BreakpointItem {
|
||||
private final XBreakpoint<?> myBreakpoint;
|
||||
|
||||
public XBreakpointItem(XBreakpoint<?> breakpoint) {
|
||||
myBreakpoint = breakpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
|
||||
setupGenericRenderer(renderer, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredTreeCellRenderer renderer) {
|
||||
setupGenericRenderer(renderer, false);
|
||||
}
|
||||
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
|
||||
if (plainView) {
|
||||
renderer.setIcon(getIcon());
|
||||
}
|
||||
final SimpleTextAttributes attributes =
|
||||
myBreakpoint.isEnabled() ? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES;
|
||||
renderer.append(getDisplayText(), attributes);
|
||||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return XBreakpointUtil.getShortText(myBreakpoint);
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return ((XBreakpointBase)myBreakpoint).getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String speedSearchText() {
|
||||
return ((XBreakpointBase)myBreakpoint).getType().getDisplayText(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String footerText() {
|
||||
return ((XBreakpointBase)myBreakpoint).getType().getDisplayText(myBreakpoint);
|
||||
}
|
||||
|
||||
public void doUpdateDetailView(DetailView panel, boolean editorOnly) {
|
||||
Project project = ((XBreakpointBase)myBreakpoint).getProject();
|
||||
if (!editorOnly) {
|
||||
|
||||
XLightBreakpointPropertiesPanel<XBreakpoint<?>> propertiesPanel =
|
||||
new XLightBreakpointPropertiesPanel<XBreakpoint<?>>(project, getManager(), myBreakpoint, true);
|
||||
propertiesPanel.loadProperties();
|
||||
panel.setDetailPanel(propertiesPanel.getMainPanel());
|
||||
}
|
||||
|
||||
XSourcePosition sourcePosition = myBreakpoint.getSourcePosition();
|
||||
if (sourcePosition != null) {
|
||||
showInEditor(panel, sourcePosition.getFile(), sourcePosition.getLine());
|
||||
}
|
||||
else {
|
||||
panel.clearEditor();
|
||||
}
|
||||
panel.getDetailPanel().revalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean navigate() {
|
||||
Navigatable navigatable = myBreakpoint.getNavigatable();
|
||||
if (navigatable != null) {
|
||||
navigatable.navigate(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private XBreakpointManagerImpl getManager() {
|
||||
return ((XBreakpointBase)myBreakpoint).getBreakpointManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowedToRemove() {
|
||||
return !getManager().isDefaultBreakpoint(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(Project project) {
|
||||
final XBreakpointManagerImpl breakpointManager = getManager();
|
||||
new WriteAction() {
|
||||
protected void run(final Result result) {
|
||||
breakpointManager.removeBreakpoint(myBreakpoint);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBreakpoint() {
|
||||
return myBreakpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return myBreakpoint.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean state) {
|
||||
myBreakpoint.setEnabled(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultBreakpoint() {
|
||||
return getManager().isDefaultBreakpoint(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(BreakpointItem breakpointItem) {
|
||||
if (breakpointItem.getBreakpoint() instanceof XBreakpointBase) {
|
||||
return ((XBreakpointBase)myBreakpoint).compareTo((XBreakpoint)breakpointItem.getBreakpoint());
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xdebugger.XDebuggerManager;
|
||||
import com.intellij.xdebugger.XDebuggerUtil;
|
||||
import com.intellij.xdebugger.breakpoints.*;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.grouping.XBreakpointGroupingByTypeRule;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.AbstractBreakpointPanel;
|
||||
|
||||
+122
-122
@@ -1,122 +1,122 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
package com.intellij.xdebugger.breakpoints.ui;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
|
||||
import com.intellij.openapi.editor.markup.MarkupModel;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.ui.popup.util.ItemWrapper;
|
||||
import com.intellij.xdebugger.ui.DebuggerColors;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public abstract class BreakpointItem extends ItemWrapper implements Comparable<BreakpointItem> {
|
||||
public static final Key<Object> EDITOR_ONLY = Key.create("EditorOnly");
|
||||
|
||||
public abstract Object getBreakpoint();
|
||||
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
public abstract void setEnabled(boolean state);
|
||||
|
||||
public abstract boolean isDefaultBreakpoint();
|
||||
|
||||
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
|
||||
TextAttributes attributes =
|
||||
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
|
||||
|
||||
DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);
|
||||
|
||||
if (state.equals(panel.getEditorState())) {
|
||||
return;
|
||||
}
|
||||
|
||||
panel.navigateInPreviewEditor(state);
|
||||
|
||||
TextAttributes softerAttributes = attributes.clone();
|
||||
softerAttributes.setBackgroundColor(ColorUtil.softer(softerAttributes.getBackgroundColor()));
|
||||
|
||||
final Editor editor = panel.getEditor();
|
||||
final MarkupModel editorModel = editor.getMarkupModel();
|
||||
final MarkupModel documentModel =
|
||||
DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
|
||||
|
||||
for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) {
|
||||
if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) {
|
||||
final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line;
|
||||
if (line1 != line) {
|
||||
editorModel.addLineHighlighter(line1,
|
||||
DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAccessoryView(JComponent component) {
|
||||
final JCheckBox checkBox = (JCheckBox)component;
|
||||
checkBox.setSelected(isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
|
||||
setupGenericRenderer(renderer, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredTreeCellRenderer renderer) {
|
||||
boolean plainView = renderer.getTree().getClientProperty("plainView") != null;
|
||||
setupGenericRenderer(renderer, plainView);
|
||||
}
|
||||
|
||||
|
||||
protected abstract void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView);
|
||||
|
||||
public abstract Icon getIcon();
|
||||
|
||||
public abstract String getDisplayText();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BreakpointItem item = (BreakpointItem)o;
|
||||
|
||||
if (getBreakpoint() != null ? !getBreakpoint().equals(item.getBreakpoint()) : item.getBreakpoint() != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getBreakpoint() != null ? getBreakpoint().hashCode() : 0;
|
||||
}
|
||||
|
||||
public abstract boolean navigate();
|
||||
}
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.breakpoints.ui;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
|
||||
import com.intellij.openapi.editor.markup.MarkupModel;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.ui.popup.util.ItemWrapper;
|
||||
import com.intellij.xdebugger.ui.DebuggerColors;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public abstract class BreakpointItem extends ItemWrapper implements Comparable<BreakpointItem> {
|
||||
public static final Key<Object> EDITOR_ONLY = Key.create("EditorOnly");
|
||||
|
||||
public abstract Object getBreakpoint();
|
||||
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
public abstract void setEnabled(boolean state);
|
||||
|
||||
public abstract boolean isDefaultBreakpoint();
|
||||
|
||||
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
|
||||
TextAttributes attributes =
|
||||
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
|
||||
|
||||
DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);
|
||||
|
||||
if (state.equals(panel.getEditorState())) {
|
||||
return;
|
||||
}
|
||||
|
||||
panel.navigateInPreviewEditor(state);
|
||||
|
||||
TextAttributes softerAttributes = attributes.clone();
|
||||
softerAttributes.setBackgroundColor(ColorUtil.softer(softerAttributes.getBackgroundColor()));
|
||||
|
||||
final Editor editor = panel.getEditor();
|
||||
final MarkupModel editorModel = editor.getMarkupModel();
|
||||
final MarkupModel documentModel =
|
||||
DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
|
||||
|
||||
for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) {
|
||||
if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) {
|
||||
final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line;
|
||||
if (line1 != line) {
|
||||
editorModel.addLineHighlighter(line1,
|
||||
DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAccessoryView(JComponent component) {
|
||||
final JCheckBox checkBox = (JCheckBox)component;
|
||||
checkBox.setSelected(isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
|
||||
setupGenericRenderer(renderer, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredTreeCellRenderer renderer) {
|
||||
boolean plainView = renderer.getTree().getClientProperty("plainView") != null;
|
||||
setupGenericRenderer(renderer, plainView);
|
||||
}
|
||||
|
||||
|
||||
protected abstract void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView);
|
||||
|
||||
public abstract Icon getIcon();
|
||||
|
||||
public abstract String getDisplayText();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BreakpointItem item = (BreakpointItem)o;
|
||||
|
||||
if (getBreakpoint() != null ? !getBreakpoint().equals(item.getBreakpoint()) : item.getBreakpoint() != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getBreakpoint() != null ? getBreakpoint().hashCode() : 0;
|
||||
}
|
||||
|
||||
public abstract boolean navigate();
|
||||
}
|
||||
-1
@@ -20,7 +20,6 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
-1
@@ -21,7 +21,6 @@ import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointMasterDetailPopupBuilder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
package com.intellij.xdebugger.impl.breakpoints.ui.tree;
|
||||
|
||||
import com.intellij.ui.CheckedTreeNode;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
|
||||
class BreakpointItemNode extends CheckedTreeNode {
|
||||
private final BreakpointItem myBreakpoint;
|
||||
|
||||
+1
-4
@@ -19,10 +19,7 @@ import com.intellij.ide.util.treeView.TreeState;
|
||||
import com.intellij.openapi.util.MultiValuesMap;
|
||||
import com.intellij.ui.CheckedTreeNode;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpoint;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpointManager;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpointType;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ import com.intellij.ui.popup.util.MasterDetailPopupBuilder;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointPanelProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package com.intellij.xdebugger.impl.breakpoints.ui.tree;
|
||||
import com.intellij.ui.CheckboxTree;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroup;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
Reference in New Issue
Block a user