diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java index 1278f72e8c35..0a450e5454b8 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java @@ -32,8 +32,10 @@ import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.wm.IdeFocusManager; +import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.impl.actions.EditBreakpointActionHandler; import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil; +import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory; import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import org.jetbrains.annotations.NotNull; @@ -49,7 +51,7 @@ import java.awt.*; */ public class JavaEditBreakpointActionHandler extends EditBreakpointActionHandler { @Override - protected void doShowPopup(Project project, final EditorGutterComponentEx gutterComponent, final Point whereToShow, Object breakpoint) { + protected void doShowPopup(final Project project, final EditorGutterComponentEx gutterComponent, final Point whereToShow, Object breakpoint) { if (!(breakpoint instanceof BreakpointWithHighlighter)) return; final BreakpointWithHighlighter javaBreakpoint = (BreakpointWithHighlighter)breakpoint; @@ -88,13 +90,16 @@ public class JavaEditBreakpointActionHandler extends EditBreakpointActionHandler final Runnable showMoreOptions = new Runnable() { @Override public void run() { - propertiesPanel.setMoreOptionsVisible(true); - final Balloon newBalloon = DebuggerUIUtil.showBreakpointEditor(mainPanel, displayName, whereToShow, gutterComponent, null); - newBalloon.addListener(saveOnClose); + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + BreakpointsMasterDetailPopupFactory. + getInstance(project).createPopup(javaBreakpoint).showCenteredInCurrentWindow(project); + } + }); } }; - final Balloon balloon = DebuggerUIUtil.showBreakpointEditor(mainPanel, displayName, whereToShow, gutterComponent, - propertiesPanel.isMoreOptionsVisible() ? null : showMoreOptions); + final Balloon balloon = DebuggerUIUtil.showBreakpointEditor(project, mainPanel, displayName, whereToShow, gutterComponent, showMoreOptions); balloon.addListener(saveOnClose); propertiesPanel.setDelegate(new BreakpointPropertiesPanel.Delegate() { @@ -103,7 +108,7 @@ public class JavaEditBreakpointActionHandler extends EditBreakpointActionHandler propertiesPanel.setActionsPanelVisible(true); balloon.hide(); final Balloon newBalloon = - DebuggerUIUtil.showBreakpointEditor(mainPanel, displayName, whereToShow, gutterComponent, showMoreOptions); + DebuggerUIUtil.showBreakpointEditor(project, mainPanel, displayName, whereToShow, gutterComponent, showMoreOptions); newBalloon.addListener(saveOnClose); } }); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java index 2e52109b5ae4..7ef5417ca915 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java @@ -522,6 +522,7 @@ public abstract class BreakpointWithHighlighter extends Breakpoint { if (!highlighter.isValid()) { return null; } + highlighter.putUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY, Boolean.TRUE); highlighter.setErrorStripeTooltip(DebuggerBundle.message("breakpoint.tooltip.text", lineIndex + 1)); return highlighter; } diff --git a/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java b/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java index b230f482cad1..4327addc74c9 100644 --- a/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/popup/util/DetailViewImpl.java @@ -52,12 +52,6 @@ public class DetailViewImpl extends JPanel implements DetailView { private JLabel myNothingToShowInEditor = new JLabel("Nothing to show"); private RangeHighlighter myHighlighter; - public void setScheme(EditorColorsScheme scheme) { - myScheme = scheme; - } - - private EditorColorsScheme myScheme = EditorColorsManager.getInstance().getGlobalScheme(); - public DetailViewImpl(Project project) { super(new BorderLayout()); myProject = project; @@ -120,7 +114,7 @@ public class DetailViewImpl extends JPanel implements DetailView { remove(myNothingToShowInEditor); setEditor(EditorFactory.getInstance().createViewer(document, project)); - final EditorColorsScheme scheme = getScheme(); + final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); @@ -155,11 +149,6 @@ public class DetailViewImpl extends JPanel implements DetailView { } } - public EditorColorsScheme getScheme() { - return myScheme; - } - - private void clearHightlighting() { if (myHighlighter != null) { diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index 95f715bd7854..22bcbf4715be 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java @@ -43,7 +43,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; import com.intellij.util.*; @@ -72,10 +72,12 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.jar.JarFile; +import static org.junit.Assert.assertNotNull; /** * @author yole */ +@SuppressWarnings("UseOfSystemOutOrSystemErr") public class PlatformTestUtil { public static final boolean COVERAGE_ENABLED_BUILD = "true".equals(System.getProperty("idea.coverage.enabled.build")); public static final CvsVirtualFileFilter CVS_FILE_FILTER = new CvsVirtualFileFilter(); @@ -616,11 +618,15 @@ public class PlatformTestUtil { public static void assertDirectoriesEqual(VirtualFile dirAfter, VirtualFile dirBefore, @Nullable VirtualFileFilter fileFilter) throws IOException { FileDocumentManager.getInstance().saveAllDocuments(); + + dirAfter.getChildren(); + dirAfter.refresh(false, false); VirtualFile[] childrenAfter = dirAfter.getChildren(); if (dirAfter.isInLocalFileSystem()) { File[] ioAfter = new File(dirAfter.getPath()).listFiles(); shallowCompare(childrenAfter, ioAfter); } + VirtualFile[] childrenBefore = dirBefore.getChildren(); if (dirBefore.isInLocalFileSystem()) { File[] ioBefore = new File(dirBefore.getPath()).listFiles(); @@ -672,16 +678,27 @@ public class PlatformTestUtil { public static void assertFilesEqual(VirtualFile fileAfter, VirtualFile fileBefore) throws IOException { try { - assertJarFilesEqual(VfsUtil.virtualToIoFile(fileAfter), VfsUtil.virtualToIoFile(fileBefore)); + assertJarFilesEqual(VfsUtilCore.virtualToIoFile(fileAfter), VfsUtilCore.virtualToIoFile(fileBefore)); } catch (IOException e) { FileDocumentManager manager = FileDocumentManager.getInstance(); + Document docBefore = manager.getDocument(fileBefore); boolean canLoadBeforeText = !fileBefore.getFileType().isBinary() || fileBefore.getFileType() == FileTypes.UNKNOWN; - String textB = docBefore == null ? !canLoadBeforeText ? null : LoadTextUtil.getTextByBinaryPresentation(fileBefore.contentsToByteArray(false), fileBefore).toString() : docBefore.getText(); + String textB = docBefore != null + ? docBefore.getText() + : !canLoadBeforeText + ? null + : LoadTextUtil.getTextByBinaryPresentation(fileBefore.contentsToByteArray(false), fileBefore).toString(); + Document docAfter = manager.getDocument(fileAfter); boolean canLoadAfterText = !fileBefore.getFileType().isBinary() || fileBefore.getFileType() == FileTypes.UNKNOWN; - String textA = docAfter == null ? !canLoadAfterText ? null : LoadTextUtil.getTextByBinaryPresentation(fileAfter.contentsToByteArray(false), fileAfter).toString() : docAfter.getText(); + String textA = docAfter != null + ? docAfter.getText() + : !canLoadAfterText + ? null + : LoadTextUtil.getTextByBinaryPresentation(fileAfter.contentsToByteArray(false), fileAfter).toString(); + if (textA != null && textB != null) { Assert.assertEquals(fileAfter.getPath(), textA, textB); } @@ -692,28 +709,30 @@ public class PlatformTestUtil { } public static void assertJarFilesEqual(File file1, File file2) throws IOException { - JarFile jarFile1 = null; - JarFile jarFile2 = null; final File tempDirectory1; final File tempDirectory2; + + final JarFile jarFile1 = new JarFile(file1); try { - jarFile2 = new JarFile(file2); - jarFile1 = new JarFile(file1); - tempDirectory1 = PlatformTestCase.createTempDir("tmp1"); - tempDirectory2 = PlatformTestCase.createTempDir("tmp2"); - ZipUtil.extract(jarFile1, tempDirectory1, CVS_FILE_FILTER); - ZipUtil.extract(jarFile2, tempDirectory2, CVS_FILE_FILTER); - } - finally { - if (jarFile1 != null) { - jarFile1.close(); + final JarFile jarFile2 = new JarFile(file2); + try { + tempDirectory1 = PlatformTestCase.createTempDir("tmp1"); + tempDirectory2 = PlatformTestCase.createTempDir("tmp2"); + ZipUtil.extract(jarFile1, tempDirectory1, CVS_FILE_FILTER); + ZipUtil.extract(jarFile2, tempDirectory2, CVS_FILE_FILTER); } - if (jarFile2 != null) { + finally { jarFile2.close(); } } + finally { + jarFile1.close(); + } + final VirtualFile dirAfter = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDirectory1); + assertNotNull(tempDirectory1.toString(), dirAfter); final VirtualFile dirBefore = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDirectory2); + assertNotNull(tempDirectory2.toString(), dirBefore); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java index 3dbc5b0541a4..82abf3ad6522 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/BreakpointItem.java @@ -15,8 +15,12 @@ */ package com.intellij.xdebugger.breakpoints.ui; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; 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.ui.popup.JBPopup; @@ -46,7 +50,28 @@ public abstract class BreakpointItem implements ItemWrapper { public abstract void setEnabled(boolean state); protected void showInEditor(DetailView panel, VirtualFile virtualFile, int line) { - panel.navigateInPreviewEditor(virtualFile, new LogicalPosition(line, 0), null); + TextAttributes attributes = + EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES); + + panel.navigateInPreviewEditor(virtualFile, new LogicalPosition(line, 0), attributes); + + 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 diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/ui/DebuggerColors.java b/platform/xdebugger-api/src/com/intellij/xdebugger/ui/DebuggerColors.java index 5c34a979f4f4..3ef5a2e88ee4 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/ui/DebuggerColors.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/ui/DebuggerColors.java @@ -22,6 +22,7 @@ package com.intellij.xdebugger.ui; import com.intellij.openapi.editor.colors.ColorKey; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.HighlighterLayer; +import com.intellij.openapi.util.Key; import java.awt.*; @@ -31,5 +32,7 @@ public interface DebuggerColors { ColorKey RECURSIVE_CALL_ATTRIBUTES = ColorKey.createColorKey("RECURSIVE_CALL_ATTRIBUTES", new Color(255, 255, 215)); int BREAKPOINT_HIGHLIGHTER_LAYER = HighlighterLayer.SYNTAX + 1; + + Key BREAKPOINT_HIGHLIGHTER_KEY = Key.create("BREAKPOINT_HIGHLIGHTER_KEY"); int EXECUTION_LINE_HIGHLIGHTERLAYER = HighlighterLayer.SELECTION - 1; } diff --git a/platform/xdebugger-api/xdebugger-api.iml b/platform/xdebugger-api/xdebugger-api.iml index 5e37d936a983..9b0209ca69aa 100644 --- a/platform/xdebugger-api/xdebugger-api.iml +++ b/platform/xdebugger-api/xdebugger-api.iml @@ -8,6 +8,7 @@ + diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java index dfe161a81663..0528037a01af 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XLineBreakpointImpl.java @@ -87,6 +87,7 @@ public class XLineBreakpointImpl

extends XBreak if (highlighter != null) { updateIcon(); highlighter.setGutterIconRenderer(createGutterIconRenderer()); + highlighter.putUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY, Boolean.TRUE); } myHighlighter = highlighter; } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointItemsTree.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointItemsTree.java index a06d9c859f09..13fe05927c62 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointItemsTree.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointItemsTree.java @@ -87,8 +87,8 @@ public class BreakpointItemsTree extends CheckboxTree { } //TreeUtil.sort(myRoot, myComparator); ((DefaultTreeModel)getModel()).nodeStructureChanged(myRoot); - expandPath(new TreePath(myRoot)); state.applyTo(this, myRoot); + TreeUtil.expandAll(this); } @@ -114,23 +114,25 @@ public class BreakpointItemsTree extends CheckboxTree { groups = Collections.emptyList(); } - - Collection filtered = new ArrayList(); - for (XBreakpointGroup group : groups) { - TreeNode parent = myGroupNodes.get(group).getParent(); - if ((parentGroup == null && parent == myRoot) || ((BreakpointsGroupNode)parent).getGroup() == parentGroup) { - filtered.add(group); - } - } - - - XBreakpointGroup group = groupingRule.getGroup(breakpoint.getBreakpoint(), filtered); + XBreakpointGroup group = groupingRule.getGroup(breakpoint.getBreakpoint(), filterByParent(parentGroup, groups)); if (group != null) { myGroups.put(groupingRule, group); } return group; } + private Collection filterByParent(XBreakpointGroup parentGroup, Collection groups) { + Collection filtered = new ArrayList(); + for (XBreakpointGroup group : groups) { + TreeNode parentNode = myGroupNodes.get(group).getParent(); + BreakpointsGroupNode parent = parentNode instanceof BreakpointsGroupNode ? (BreakpointsGroupNode)parentNode : null; + if ((parentGroup == null && parentNode == myRoot) || (parent != null && parent.getGroup() == parentGroup)) { + filtered.add(group); + } + } + return filtered; + } + private BreakpointsGroupNode getOrCreateGroupNode(CheckedTreeNode parent, final G group, final int level) { //noinspection unchecked diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointMasterDetailPopupBuilder.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointMasterDetailPopupBuilder.java index 1900c8c81c58..fce09fb83953 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointMasterDetailPopupBuilder.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointMasterDetailPopupBuilder.java @@ -18,7 +18,6 @@ package com.intellij.xdebugger.impl.breakpoints.ui; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.actionSystem.ex.CheckboxAction; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; @@ -32,7 +31,6 @@ import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.JBPopupListener; import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.ui.IdeBorderFactory; -import com.intellij.ui.ListUtil; import com.intellij.ui.popup.util.MasterDetailPopupBuilder; import com.intellij.util.IconUtil; import com.intellij.util.PlatformIcons; @@ -131,8 +129,6 @@ public class BreakpointMasterDetailPopupBuilder { myTree.setBorder(IdeBorderFactory.createBorder()); - myPopupBuilder.getDetailView().setScheme(createScheme()); - myTree.setDelegate(new BreakpointItemsTree.BreakpointItemsTreeDelegate() { @Override public void execute(BreakpointItem item) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java index 963bdcc01f19..e86c9cfbfa8c 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java @@ -15,23 +15,25 @@ */ package com.intellij.xdebugger.impl.breakpoints.ui; -import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.ui.popup.JBPopup; -import com.intellij.ui.popup.util.MasterDetailPopupBuilder; -import com.intellij.xdebugger.breakpoints.ui.BreakpointItem; +import com.intellij.openapi.ui.popup.JBPopupListener; +import com.intellij.openapi.ui.popup.LightweightWindowEvent; import com.intellij.xdebugger.impl.DebuggerSupport; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; public class BreakpointsMasterDetailPopupFactory { private final List myBreakpointPanelProviders; private Project myProject; + private Balloon myBalloonToHide; public BreakpointsMasterDetailPopupFactory(Project project) { myProject = project; @@ -47,6 +49,10 @@ public class BreakpointsMasterDetailPopupFactory { }); } + public void setBalloonToHide(Balloon balloonToHide) { + myBalloonToHide = balloonToHide; + } + public static BreakpointsMasterDetailPopupFactory getInstance(Project project) { return ServiceManager.getService(project, BreakpointsMasterDetailPopupFactory.class); } @@ -55,6 +61,18 @@ public class BreakpointsMasterDetailPopupFactory { BreakpointMasterDetailPopupBuilder builder = new BreakpointMasterDetailPopupBuilder(myProject); builder.setInitialBreakpoint(initialBreakpoint); builder.setBreakpointsPanelProviders(myBreakpointPanelProviders); - return builder.createPopup(); + final JBPopup popup = builder.createPopup(); + popup.addListener(new JBPopupListener() { + @Override + public void beforeShown(LightweightWindowEvent event) { + myBalloonToHide.hide(); + } + + @Override + public void onClosed(LightweightWindowEvent event) { + //To change body of implemented methods use File | Settings | File Templates. + } + }); + return popup; } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java index a7ff22409457..58812079ef1a 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/BreakpointEditor.java @@ -40,7 +40,7 @@ public class BreakpointEditor { } private void createUIComponents() { - myShowMoreOptionsLink = new LinkLabel("More Options", null, new LinkListener() { + myShowMoreOptionsLink = new LinkLabel("View Breakpoints...", null, new LinkListener() { @Override public void linkSelected(LinkLabel aSource, Object aLinkData) { if (myDelegate != null) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java index 11b58784b313..76a869e6813e 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java @@ -24,6 +24,7 @@ import com.intellij.openapi.ui.popup.*; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.DimensionService; +import com.intellij.openapi.util.Ref; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.WindowManager; import com.intellij.ui.ScrollPaneFactory; @@ -33,6 +34,7 @@ import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpointListener; import com.intellij.xdebugger.breakpoints.XBreakpointManager; import com.intellij.xdebugger.frame.XFullValueEvaluator; +import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory; import com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -168,17 +170,44 @@ public class DebuggerUIUtil { final XLightBreakpointPropertiesPanel propertiesPanel = new XLightBreakpointPropertiesPanel(project, breakpointManager, breakpoint, showAllOptions); + + final Ref balloonRef = Ref.create(null); + final Ref isLoading = Ref.create(Boolean.FALSE); + + propertiesPanel.setDelegate(new XLightBreakpointPropertiesPanel.Delegate() { + @Override + public void showMoreOptions() { + if (!isLoading.get()) { + propertiesPanel.saveProperties(); + } + if (!balloonRef.isNull()) { + balloonRef.get().hide(); + } + showXBreakpointEditorBalloon(project, point, component, true, breakpoint); + } + }); + + + isLoading.set(Boolean.TRUE); propertiesPanel.loadProperties(); + isLoading.set(Boolean.FALSE); + final JComponent mainPanel = propertiesPanel.getMainPanel(); - final Runnable showMoreOptions = new Runnable() { + final Runnable viewBreakpoints = new Runnable() { @Override public void run() { propertiesPanel.saveProperties(); - showXBreakpointEditorBalloon(project, point, component, true, breakpoint); + //showXBreakpointEditorBalloon(project, point, component, true, breakpoint); + BreakpointsMasterDetailPopupFactory. + getInstance(project).createPopup(breakpoint).showCenteredInCurrentWindow(project); } }; - final Balloon balloon = showBreakpointEditor(mainPanel, breakpoint.getType().getDisplayText(breakpoint), point, component, propertiesPanel.showMoreOptions() ? showMoreOptions : null); + + final Balloon balloon = showBreakpointEditor(project, mainPanel, breakpoint.getType().getDisplayText(breakpoint), point, component, viewBreakpoints); + balloonRef.set(balloon); + + final XBreakpointListener> breakpointListener = new XBreakpointListener>() { @Override public void breakpointAdded(@NotNull XBreakpoint breakpoint1) { @@ -208,14 +237,7 @@ public class DebuggerUIUtil { } }); - propertiesPanel.setDelegate(new XLightBreakpointPropertiesPanel.Delegate() { - @Override - public void showMoreOptions() { - propertiesPanel.saveProperties(); - balloon.hide(); - showXBreakpointEditorBalloon(project, point, component, true, breakpoint); - } - }); + if (point == null) { @@ -233,14 +255,14 @@ public class DebuggerUIUtil { }); } - public static Balloon showBreakpointEditor(final JComponent mainPanel, + public static Balloon showBreakpointEditor(Project project, final JComponent mainPanel, final String displayName, final Point whereToShow, final JComponent component, @Nullable final Runnable showMoreOptions) { final BreakpointEditor editor = new BreakpointEditor(); editor.setPropertiesPanel(mainPanel); - editor.setShowMoreOptionsLink(showMoreOptions != null); + editor.setShowMoreOptionsLink(true); final Balloon balloon = JBPopupFactory.getInstance() .createDialogBalloonBuilder(editor.getMainPanel(), null) @@ -250,6 +272,7 @@ public class DebuggerUIUtil { .setBlockClicksThroughBalloon(true) .createBalloon(); + editor.setDelegate(new BreakpointEditor.Delegate() { @Override public void done() { @@ -271,6 +294,8 @@ public class DebuggerUIUtil { balloon.show(new RelativePoint(component, whereToShow), Balloon.Position.below); } + BreakpointsMasterDetailPopupFactory.getInstance(project).setBalloonToHide(balloon); + return balloon; } diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index 4c4879a483ab..2dcc24f0c017 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -508,7 +508,7 @@ public class GitUtil { if ((!firstStep) && lineIsAStart) { final StringScanner innerScanner = new StringScanner(sb.toString()); sb.setLength(0); - consumer.consume(GitChangeUtils.parseChangeList(project, root, innerScanner, skipDiffsForMerge, h)); + consumer.consume(GitChangeUtils.parseChangeList(project, root, innerScanner, skipDiffsForMerge, h, false)); } sb.append(lineIsAStart ? line.substring(2) : line).append('\n'); firstStep = false; @@ -516,7 +516,7 @@ public class GitUtil { if (sb.length() > 0) { final StringScanner innerScanner = new StringScanner(sb.toString()); sb.setLength(0); - consumer.consume(GitChangeUtils.parseChangeList(project, root, innerScanner, skipDiffsForMerge, h)); + consumer.consume(GitChangeUtils.parseChangeList(project, root, innerScanner, skipDiffsForMerge, h, false)); } if (s.hasMoreData()) { throw new IllegalStateException("More input is avaialble: " + s.line()); diff --git a/plugins/git4idea/src/git4idea/actions/GitShowAllSubmittedFilesAction.java b/plugins/git4idea/src/git4idea/actions/GitShowAllSubmittedFilesAction.java index a97f569e70b8..b0f760edd2c8 100644 --- a/plugins/git4idea/src/git4idea/actions/GitShowAllSubmittedFilesAction.java +++ b/plugins/git4idea/src/git4idea/actions/GitShowAllSubmittedFilesAction.java @@ -86,7 +86,7 @@ public class GitShowAllSubmittedFilesAction extends AnAction implements DumbAwar * @param file file affected by the revision */ public static void showSubmittedFiles(final Project project, final VcsFileRevision revision, final VirtualFile file) { - showSubmittedFiles(project, revision.getRevisionNumber().asString(), file); + showSubmittedFiles(project, revision.getRevisionNumber().asString(), file, false); } /** @@ -95,14 +95,15 @@ public class GitShowAllSubmittedFilesAction extends AnAction implements DumbAwar * @param project a project * @param revision a revision number * @param file file affected by the revision + * @param local */ - public static void showSubmittedFiles(final Project project, final String revision, final VirtualFile file) { + public static void showSubmittedFiles(final Project project, final String revision, final VirtualFile file, final boolean local) { new Task.Backgroundable(project, GitBundle.message("changes.retrieving", revision)) { public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); try { VirtualFile vcsRoot = GitUtil.getGitRoot(file); - final CommittedChangeList changeList = GitChangeUtils.getRevisionChanges(project, vcsRoot, revision, true); + final CommittedChangeList changeList = GitChangeUtils.getRevisionChanges(project, vcsRoot, revision, true, local); if (changeList != null) { UIUtil.invokeLaterIfNeeded(new Runnable() { public void run() { diff --git a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java index 4e5f4af077cc..c0080c347893 100644 --- a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java +++ b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java @@ -122,7 +122,7 @@ public class GitChangeUtils { public static void parseChanges(Project project, VirtualFile vcsRoot, @Nullable GitRevisionNumber thisRevision, - GitRevisionNumber parentRevision, + @Nullable GitRevisionNumber parentRevision, StringScanner s, Collection changes, final Set ignoreNames) throws VcsException { @@ -230,14 +230,20 @@ public class GitChangeUtils { * of the merge, so changes are reported as difference with the first revision * listed on the the merge that has at least some changes. * + * * @param project the project file * @param root the git root * @param revisionName the name of revision (might be tag) * @param skipDiffsForMerge + * @param local * @return change list for the respective revision * @throws VcsException in case of problem with running git */ - public static GitCommittedChangeList getRevisionChanges(Project project, VirtualFile root, String revisionName, boolean skipDiffsForMerge) throws VcsException { + public static GitCommittedChangeList getRevisionChanges(Project project, + VirtualFile root, + String revisionName, + boolean skipDiffsForMerge, + boolean local) throws VcsException { GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW); h.setNoSSH(true); h.setSilent(true); @@ -245,7 +251,7 @@ public class GitChangeUtils { revisionName, "--"); String output = h.run(); StringScanner s = new StringScanner(output); - return parseChangeList(project, root, s, skipDiffsForMerge, h); + return parseChangeList(project, root, s, skipDiffsForMerge, h, local); } @Nullable @@ -328,15 +334,24 @@ public class GitChangeUtils { /** * Parse changelist * + * * @param project the project * @param root the git root * @param s the scanner for log or show command output * @param skipDiffsForMerge * @param handler the handler that produced the output to parse. - for debugging purposes. + * @param local pass {@code true} to indicate that this revision should be an editable + * {@link com.intellij.openapi.vcs.changes.CurrentContentRevision}. + * Pass {@code false} for * @return the parsed changelist * @throws VcsException if there is a problem with running git */ - public static GitCommittedChangeList parseChangeList(Project project, VirtualFile root, StringScanner s, boolean skipDiffsForMerge, GitHandler handler) throws VcsException { + public static GitCommittedChangeList parseChangeList(Project project, + VirtualFile root, + StringScanner s, + boolean skipDiffsForMerge, + GitHandler handler, + boolean local) throws VcsException { ArrayList changes = new ArrayList(); // parse commit information final Date commitDate = GitUtil.parseTimestampWithNFEReport(s.line(), handler, s.getAllText()); @@ -367,7 +382,7 @@ public class GitChangeUtils { final GitRevisionNumber parentRevision = parents.length > 0 ? loadRevision(project, root, parents[0]) : null; // This is the first or normal commit with the single parent. // Just parse changes in this commit as returned by the show command. - parseChanges(project, root, thisRevision, parentRevision, s, changes, null); + parseChanges(project, root, thisRevision, local ? null : parentRevision, s, changes, null); } else { // This is the merge commit. It has multiple parent commits. @@ -376,10 +391,6 @@ public class GitChangeUtils { for (String parent : parents) { final GitRevisionNumber parentRevision = loadRevision(project, root, parent); - if (parentRevision == null) { - // the repository was cloned with --depth parameter - continue; - } GitSimpleHandler diffHandler = new GitSimpleHandler(project, root, GitCommand.DIFF); diffHandler.setNoSSH(true); diffHandler.setSilent(true); diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java b/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java index e1332d5ba92b..a0225ad98d98 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java @@ -133,7 +133,7 @@ public class GitRebaseEditor extends DialogWrapper { return; } GitRebaseEntry entry = myTableModel.myEntries.get(row); - GitShowAllSubmittedFilesAction.showSubmittedFiles(project, entry.getCommit(), gitRoot); + GitShowAllSubmittedFilesAction.showSubmittedFiles(project, entry.getCommit(), gitRoot, false); } }); diff --git a/plugins/git4idea/src/git4idea/ui/GitReferenceValidator.java b/plugins/git4idea/src/git4idea/ui/GitReferenceValidator.java index eb652deb8702..125992f17c6e 100644 --- a/plugins/git4idea/src/git4idea/ui/GitReferenceValidator.java +++ b/plugins/git4idea/src/git4idea/ui/GitReferenceValidator.java @@ -94,7 +94,7 @@ public class GitReferenceValidator { myLastResult = false; try { GitRevisionNumber revision = GitRevisionNumber.resolve(myProject, gitRoot(), revisionExpression); - GitShowAllSubmittedFilesAction.showSubmittedFiles(myProject, revision.asString(), gitRoot()); + GitShowAllSubmittedFilesAction.showSubmittedFiles(myProject, revision.asString(), gitRoot(), false); myLastResult = true; } catch (VcsException ex) { diff --git a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java index 61ce16bfe79a..bf3d7793306b 100644 --- a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java @@ -124,6 +124,7 @@ public class GitUnstashDialog extends DialogWrapper { */ public GitUnstashDialog(final Project project, final List roots, final VirtualFile defaultRoot) { super(project, true); + setModal(false); myProject = project; myVcs = GitVcs.getInstance(project); setTitle(GitBundle.getString("unstash.title")); @@ -223,7 +224,7 @@ public class GitUnstashDialog extends DialogWrapper { GitUIUtil.showOperationError(myProject, ex, "resolving revision"); return; } - GitShowAllSubmittedFilesAction.showSubmittedFiles(myProject, resolvedStash, root); + GitShowAllSubmittedFilesAction.showSubmittedFiles(myProject, resolvedStash, root, true); } }); init();