breakpoints ui. navigation

This commit is contained in:
andrey.zaytsev
2012-06-09 17:15:32 +04:00
parent ec0689888b
commit 5e7457fa75
7 changed files with 61 additions and 20 deletions
@@ -98,6 +98,15 @@ class JavaBreakpointItem extends BreakpointItem {
}
}
@Override
public boolean navigate() {
if (myBreakpoint instanceof BreakpointWithHighlighter) {
((BreakpointWithHighlighter)myBreakpoint).getSourcePosition().navigate(true);
return true;
}
return false;
}
@Override
public boolean allowedToRemove() {
return myBreakpointFactory != null && myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint);
@@ -33,7 +33,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.ui.components.JBList;
import com.intellij.ui.popup.util.DetailViewImpl;
import com.intellij.ui.popup.util.ItemWrapper;
import com.intellij.ui.popup.util.MasterDetailPopupBuilder;
import com.intellij.ui.speedSearch.FilteringListModel;
@@ -125,7 +124,7 @@ public class BookmarksAction extends AnAction implements DumbAware, MasterDetail
}
@Override
public void itemChosen(ItemWrapper item, Project project, JBPopup popup) {
public void itemChosen(ItemWrapper item, Project project, JBPopup popup, boolean withEnterOrDoubleClick) {
if (item instanceof BookmarkItem) {
Bookmark bookmark = ((BookmarkItem)item).getBookmark();
popup.cancel();
@@ -15,9 +15,7 @@
*/
package com.intellij.ui.popup.util;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupListener;
@@ -148,12 +146,12 @@ public class MasterDetailPopupBuilder {
public void run() {
Object[] values = getSelectedItems();
if (values.length == 1) {
myDelegate.itemChosen((ItemWrapper)values[0], myProject, myPopup);
myDelegate.itemChosen((ItemWrapper)values[0], myProject, myPopup, false);
}
else {
for (Object value : values) {
if (value instanceof ItemWrapper) {
myDelegate.itemChosen((ItemWrapper)value, myProject, myPopup);
myDelegate.itemChosen((ItemWrapper)value, myProject, myPopup, false);
}
}
}
@@ -235,14 +233,20 @@ public class MasterDetailPopupBuilder {
return null;
}
public Object[] getSelectedItems() {
public ItemWrapper[] getSelectedItems() {
Object[] values = new Object[0];
if (myChooserComponent instanceof JList) {
return ((JList)myChooserComponent).getSelectedValues();
values = ((JList)myChooserComponent).getSelectedValues();
}
else if (myChooserComponent instanceof JTree) {
return myDelegate.getSelectedItemsInTree();
values = myDelegate.getSelectedItemsInTree();
}
return new Object[0];
ItemWrapper[] items = new ItemWrapper[values.length];
for (int i = 0; i < values.length; i++) {
items[i] = (ItemWrapper)values[i];
}
return items;
}
private void updateDetailViewLater() {
@@ -357,6 +361,16 @@ public class MasterDetailPopupBuilder {
}
}
});
new AnAction(){
@Override
public void actionPerformed(AnActionEvent e) {
ItemWrapper[] items = getSelectedItems();
if (items.length > 0) {
myDelegate.itemChosen(items[0], myProject, myPopup, true);
}
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), list);
}
public MasterDetailPopupBuilder setDelegate(Delegate delegate) {
@@ -380,7 +394,7 @@ public class MasterDetailPopupBuilder {
Object[] getSelectedItemsInTree();
void itemChosen(ItemWrapper item, Project project, JBPopup popup);
void itemChosen(ItemWrapper item, Project project, JBPopup popup, boolean withEnterOrDoubleClick);
}
public static class ListItemRenderer extends JPanel implements ListCellRenderer {
@@ -135,4 +135,6 @@ public abstract class BreakpointItem implements ItemWrapper {
public int hashCode() {
return getBreakpoint() != null ? getBreakpoint().hashCode() : 0;
}
public abstract boolean navigate();
}
@@ -18,6 +18,7 @@ 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;
@@ -99,6 +100,16 @@ class XBreakpointItem extends BreakpointItem {
panel.setDetailPanel(propertiesPanel.getMainPanel());
}
@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();
}
@@ -21,6 +21,7 @@ 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;
@@ -66,6 +67,14 @@ public class BreakpointsMasterDetailPopupFactory {
BreakpointMasterDetailPopupBuilder builder = new BreakpointMasterDetailPopupBuilder(myProject);
builder.setInitialBreakpoint(initialBreakpoint);
builder.setBreakpointsPanelProviders(collectPanelProviders());
builder.setCallback(new BreakpointMasterDetailPopupBuilder.BreakpointChosenCallback() {
@Override
public void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup) {
if (breakpointItem.navigate()) {
popup.cancel();
}
}
});
final JBPopup popup = builder.createPopup();
popup.addListener(new JBPopupListener() {
@Override
@@ -163,7 +163,7 @@ public class BreakpointMasterDetailPopupBuilder {
@Nullable
@Override
public String getTitle() {
return myIsViewer ? null : "Breakpoints";
return "";
}
@Override
@@ -182,12 +182,9 @@ public class BreakpointMasterDetailPopupBuilder {
}
@Override
public void itemChosen(ItemWrapper item, Project project, JBPopup popup) {
if (!(item instanceof BreakpointItem)) {
return;
}
if (myCallback != null){
myCallback.breakpointChosen(project, (BreakpointItem)item, popup);
public void itemChosen(ItemWrapper item, Project project, JBPopup popup, boolean withEnterOrDoubleClick) {
if (myCallback != null && item instanceof BreakpointItem && withEnterOrDoubleClick) {
myCallback.breakpointChosen(myProject, (BreakpointItem)item, popup);
}
}
};
@@ -203,7 +200,7 @@ public class BreakpointMasterDetailPopupBuilder {
myTreeController.setDelegate(new BreakpointItemsTreeController.BreakpointItemsTreeDelegate() {
@Override
public void execute(BreakpointItem item) {
delegate.itemChosen(item, myProject, popup);
myCallback.breakpointChosen(myProject, item, popup);
}
});