This commit is contained in:
Vladimir Krivosheev
2016-02-22 12:51:37 +01:00
parent 8105b2ef61
commit b95ae2420d
40 changed files with 389 additions and 621 deletions
@@ -29,7 +29,6 @@ import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunnerLayoutUi;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationListener;
import com.intellij.openapi.Disposable;
@@ -48,7 +47,6 @@ import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.ui.AppUIUtil;
import com.intellij.util.Consumer;
import com.intellij.util.EventDispatcher;
import com.intellij.util.SmartList;
import com.intellij.util.containers.SmartHashSet;
@@ -76,7 +74,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -395,12 +392,7 @@ public class XDebugSessionImpl implements XDebugSession {
private <B extends XBreakpoint<?>> void handleBreakpoint(final XBreakpointHandler<B> handler, final B b, final boolean register,
final boolean temporary) {
if (register) {
boolean active = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return isBreakpointActive(b);
}
});
boolean active = ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> isBreakpointActive(b));
if (active) {
synchronized (myRegisteredBreakpoints) {
myRegisteredBreakpoints.put(b, new CustomizedBreakpointPresentation());
@@ -567,12 +559,9 @@ public class XDebugSessionImpl implements XDebugSession {
myTopFramePosition = null;
myActiveNonLineBreakpoint = null;
updateExecutionPosition();
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (mySessionTab != null) {
mySessionTab.getUi().clearAttractionBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
}
UIUtil.invokeLaterIfNeeded(() -> {
if (mySessionTab != null) {
mySessionTab.getUi().clearAttractionBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
}
});
myDispatcher.getMulticaster().sessionResumed();
@@ -716,20 +705,12 @@ public class XDebugSessionImpl implements XDebugSession {
positionReachedInternal(suspendContext);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (mySessionTab != null) {
if (XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isShowDebuggerOnBreakpoint()) {
mySessionTab.toFront(true, new Runnable() {
@Override
public void run() {
updateExecutionPosition();
}
});
}
mySessionTab.getUi().attractBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
UIUtil.invokeLaterIfNeeded(() -> {
if (mySessionTab != null) {
if (XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isShowDebuggerOnBreakpoint()) {
mySessionTab.toFront(true, this::updateExecutionPosition);
}
mySessionTab.getUi().attractBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
}
});
@@ -779,18 +760,15 @@ public class XDebugSessionImpl implements XDebugSession {
}
private void printMessage(final String message, final String hyperLinkText, @Nullable final HyperlinkInfo info) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
myConsoleView.print(message, ConsoleViewContentType.SYSTEM_OUTPUT);
if (info != null) {
myConsoleView.printHyperlink(hyperLinkText, info);
}
else if (hyperLinkText != null) {
myConsoleView.print(hyperLinkText, ConsoleViewContentType.SYSTEM_OUTPUT);
}
myConsoleView.print("\n", ConsoleViewContentType.SYSTEM_OUTPUT);
AppUIUtil.invokeOnEdt(() -> {
myConsoleView.print(message, ConsoleViewContentType.SYSTEM_OUTPUT);
if (info != null) {
myConsoleView.printHyperlink(hyperLinkText, info);
}
else if (hyperLinkText != null) {
myConsoleView.print(hyperLinkText, ConsoleViewContentType.SYSTEM_OUTPUT);
}
myConsoleView.print("\n", ConsoleViewContentType.SYSTEM_OUTPUT);
});
}
@@ -811,12 +789,9 @@ public class XDebugSessionImpl implements XDebugSession {
updateExecutionPosition();
if (myShowTabOnSuspend.compareAndSet(true, false)) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
initSessionTab(null);
showSessionTab();
}
UIUtil.invokeLaterIfNeeded(() -> {
initSessionTab(null);
showSessionTab();
});
}
@@ -869,46 +844,38 @@ public class XDebugSessionImpl implements XDebugSession {
}
finally {
//noinspection unchecked
myDebugProcess.stopAsync().done(new Consumer<Object>() {
@Override
public void consume(Object aVoid) {
if (!myProject.isDisposed()) {
myProject.getMessageBus().syncPublisher(XDebuggerManager.TOPIC).processStopped(myDebugProcess);
}
myDebugProcess.stopAsync().done(aVoid -> {
if (!myProject.isDisposed()) {
myProject.getMessageBus().syncPublisher(XDebuggerManager.TOPIC).processStopped(myDebugProcess);
}
if (mySessionTab != null) {
((XWatchesViewImpl)mySessionTab.getWatchesView()).updateSessionData();
mySessionTab.detachFromSession();
}
else if (myConsoleView != null) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
Disposer.dispose(myConsoleView);
}
});
}
if (mySessionTab != null) {
((XWatchesViewImpl)mySessionTab.getWatchesView()).updateSessionData();
mySessionTab.detachFromSession();
}
else if (myConsoleView != null) {
AppUIUtil.invokeOnEdt(() -> Disposer.dispose(myConsoleView));
}
myTopFramePosition = null;
myCurrentExecutionStack = null;
myCurrentStackFrame = null;
mySuspendContext = null;
myTopFramePosition = null;
myCurrentExecutionStack = null;
myCurrentStackFrame = null;
mySuspendContext = null;
updateExecutionPosition();
updateExecutionPosition();
if (myValueMarkers != null) {
myValueMarkers.clear();
}
if (XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isUnmuteOnStop()) {
mySessionData.setBreakpointsMuted(false);
}
myDebuggerManager.removeSession(XDebugSessionImpl.this);
myDispatcher.getMulticaster().sessionStopped();
myProject.putUserData(XDebuggerEditorLinePainter.CACHE, null);
if (myValueMarkers != null) {
myValueMarkers.clear();
}
if (XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isUnmuteOnStop()) {
mySessionData.setBreakpointsMuted(false);
}
myDebuggerManager.removeSession(this);
myDispatcher.getMulticaster().sessionStopped();
myProject.putUserData(XDebuggerEditorLinePainter.CACHE, null);
synchronized (myRegisteredBreakpoints) {
myRegisteredBreakpoints.clear();
}
synchronized (myRegisteredBreakpoints) {
myRegisteredBreakpoints.clear();
}
});
}
@@ -943,12 +910,7 @@ public class XDebugSessionImpl implements XDebugSession {
@Override
public void reportMessage(@NotNull final String message, @NotNull final MessageType type, @Nullable final HyperlinkListener listener) {
NotificationListener notificationListener = listener == null ? null : new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
listener.hyperlinkUpdate(event);
}
};
NotificationListener notificationListener = listener == null ? null : (NotificationListener)(notification, event) -> listener.hyperlinkUpdate(event);
NOTIFICATION_GROUP.createNotification("", message, type.toNotificationType(), notificationListener).notify(myProject);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -17,14 +17,17 @@ package com.intellij.xdebugger.impl;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* @author nik
@@ -58,7 +61,6 @@ public class XDebuggerHistoryManager {
}
public List<XExpression> getRecentExpressions(@NonNls String id) {
LinkedList<XExpression> list = myRecentExpressions.get(id);
return list != null ? list : Collections.<XExpression>emptyList();
return ContainerUtil.notNullize(myRecentExpressions.get(id));
}
}
@@ -27,7 +27,6 @@ import com.intellij.execution.ui.RunContentDescriptor;
import com.intellij.execution.ui.RunContentManager;
import com.intellij.execution.ui.RunContentWithExecutorListener;
import com.intellij.ide.DataManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.*;
import com.intellij.openapi.editor.Document;
@@ -41,6 +40,7 @@ import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.xmlb.annotations.Property;
@@ -59,7 +59,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.*;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
/**
@@ -247,12 +250,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager
if (descriptor != null) {
// in test-mode RunContentWithExecutorListener.contentRemoved events are not sent (see RunContentManagerImpl.showRunContent)
// so we make sure the mySessions and mySessionData are cleared correctly when session is disposed
Disposer.register(descriptor, new Disposable() {
@Override
public void dispose() {
mySessions.remove(session.getDebugProcess().getProcessHandler());
}
});
Disposer.register(descriptor, () -> mySessions.remove(session.getDebugProcess().getProcessHandler()));
}
if (!myProject.isDisposed() && !ApplicationManager.getApplication().isUnitTestMode() && XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isHideDebuggerOnProcessTermination()) {
@@ -312,7 +310,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager
list.add(processClass.cast(process));
}
}
return list == null ? Collections.<T>emptyList() : list;
return ContainerUtil.notNullize(list);
}
@Override
@@ -489,7 +489,7 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
@Override
public <B extends XLineBreakpoint<?>> List<XBreakpointGroupingRule<B, ?>> getGroupingByFileRuleAsList() {
return Collections.singletonList(this.getGroupingByFileRule());
return Collections.singletonList(getGroupingByFileRule());
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -16,7 +16,6 @@
package com.intellij.xdebugger.impl;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import com.intellij.util.xmlb.annotations.Attribute;
@@ -69,12 +68,7 @@ public class XDebuggerWatchesManager implements PersistentStateComponent<XDebugg
if (state != null) {
for (ConfigurationState expressionState : state.expressions) {
XExpression[] expressions = ContainerUtil.mapNotNull(expressionState.myExpressionStates,
new Function<WatchState, XExpression>() {
@Override
public XExpression fun(WatchState state) {
return state.toXExpression();
}
}, new XExpression[0]);
XExpressionState::toXExpression, new XExpression[0]);
watches.put(expressionState.myName, expressions);
}
}
@@ -100,7 +94,7 @@ public class XDebuggerWatchesManager implements PersistentStateComponent<XDebugg
}
public ConfigurationState(String name, XExpression[] expressions) {
this.myName = name;
myName = name;
myExpressionStates = new WatchState[expressions.length];
for (int i = 0; i < expressions.length; i++) {
myExpressionStates[i] = new WatchState(expressions[i]);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -33,7 +33,6 @@ import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.ui.popup.list.ListPopupImpl;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.containers.hash.LinkedHashMap;
@@ -50,7 +49,10 @@ import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.event.InputEvent;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class AttachToLocalProcessAction extends AnAction {
private static final Key<LinkedHashMap<String, HistoryItem>> HISTORY_KEY = Key.create("AttachToLocalProcessAction.HISTORY_KEY");
@@ -82,23 +84,20 @@ public class AttachToLocalProcessAction extends AnAction {
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(step);
final JList mainList = ((ListPopupImpl)popup).getList();
ListSelectionListener listener = new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting()) return;
ListSelectionListener listener = event -> {
if (event.getValueIsAdjusting()) return;
Object item = ((JList)event.getSource()).getSelectedValue();
Object item = ((JList)event.getSource()).getSelectedValue();
// if a sub-list is closed, fallback to the selected value from the main list
if (item == null) {
item = mainList.getSelectedValue();
}
// if a sub-list is closed, fallback to the selected value from the main list
if (item == null) {
item = mainList.getSelectedValue();
}
if (item instanceof AttachItem) {
String debuggerName = ((AttachItem)item).getSelectedDebugger().getDebuggerDisplayName();
debuggerName = StringUtil.shortenTextWithEllipsis(debuggerName, 50, 0);
((ListPopupImpl)popup).setCaption(XDebuggerBundle.message("xdebugger.attach.toLocal.popup.adText", debuggerName));
}
if (item instanceof AttachItem) {
String debuggerName = ((AttachItem)item).getSelectedDebugger().getDebuggerDisplayName();
debuggerName = StringUtil.shortenTextWithEllipsis(debuggerName, 50, 0);
((ListPopupImpl)popup).setCaption(XDebuggerBundle.message("xdebugger.attach.toLocal.popup.adText", debuggerName));
}
};
popup.addListSelectionListener(listener);
@@ -133,23 +132,13 @@ public class AttachToLocalProcessAction extends AnAction {
}
ArrayList<XLocalAttachGroup> sortedGroups = new ArrayList<XLocalAttachGroup>(groupWithItems.keySet());
Collections.sort(sortedGroups, new Comparator<XLocalAttachGroup>() {
@Override
public int compare(XLocalAttachGroup a, XLocalAttachGroup b) {
return a.getOrder() - b.getOrder();
}
});
Collections.sort(sortedGroups, (a, b) -> a.getOrder() - b.getOrder());
List<AttachItem> currentItems = new ArrayList<AttachItem>();
for (final XLocalAttachGroup eachGroup : sortedGroups) {
List<Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>>> sortedItems
= new ArrayList<Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>>>(groupWithItems.get(eachGroup));
Collections.sort(sortedItems, new Comparator<Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>>>() {
@Override
public int compare(Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>> a, Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>> b) {
return eachGroup.compare(project, a.first, b.first);
}
});
Collections.sort(sortedItems, (a, b) -> eachGroup.compare(project, a.first, b.first));
boolean first = true;
for (Pair<ProcessInfo, ArrayList<XLocalAttachDebugger>> eachItem : sortedItems) {
@@ -208,7 +197,7 @@ public class AttachToLocalProcessAction extends AnAction {
@NotNull
public static List<HistoryItem> getHistory(@NotNull Project project) {
LinkedHashMap<String, HistoryItem> history = project.getUserData(HISTORY_KEY);
return history == null ? Collections.<HistoryItem>emptyList()
return history == null ? Collections.emptyList()
: Collections.unmodifiableList(new ArrayList<HistoryItem>(history.values()));
}
@@ -296,11 +285,8 @@ public class AttachToLocalProcessAction extends AnAction {
mySelectedDebugger = selectedDebugger;
if (debuggers.size() > 1) {
mySubItems = ContainerUtil.map(debuggers, new Function<XLocalAttachDebugger, AttachItem>() {
@Override
public AttachItem fun(XLocalAttachDebugger debugger) {
return new AttachItem(myGroup, false, myProcessInfo, Collections.singletonList(debugger));
}
mySubItems = ContainerUtil.map(debuggers, debugger -> {
return new AttachItem(myGroup, false, myProcessInfo, Collections.singletonList(debugger));
});
}
else {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
* @author nik
*/
public class MuteBreakpointAction extends ToggleAction {
@Override
public boolean isSelected(final AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project != null) {
@@ -40,6 +41,7 @@ public class MuteBreakpointAction extends ToggleAction {
return false;
}
@Override
public void setSelected(final AnActionEvent e, final boolean state) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project != null) {
@@ -53,6 +55,7 @@ public class MuteBreakpointAction extends ToggleAction {
}
}
@Override
public void update(@NotNull final AnActionEvent e) {
super.update(e);
Project project = e.getData(CommonDataKeys.PROJECT);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -40,6 +40,7 @@ public class ViewBreakpointsAction extends AnAction implements AnAction.Transpar
myInitialBreakpoint = initialBreakpoint;
}
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Project project = CommonDataKeys.PROJECT.getData(dataContext);
@@ -56,6 +57,7 @@ public class ViewBreakpointsAction extends AnAction implements AnAction.Transpar
myInitialBreakpoint = null;
}
@Override
public void update(AnActionEvent event){
Presentation presentation = event.getPresentation();
Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -25,7 +25,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.AppUIUtil;
import com.intellij.util.Consumer;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.XSourcePosition;
@@ -76,17 +75,10 @@ public class XDebuggerEvaluateActionHandler extends XDebuggerActionHandler {
if (text == null) {
XValue value = XDebuggerTreeActionBase.getSelectedValue(dataContext);
if (value != null) {
value.calculateEvaluationExpression().done(new Consumer<XExpression>() {
@Override
public void consume(final XExpression expression) {
if (expression != null) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
showDialog(session, file, editorsProvider, stackFrame, evaluator, expression);
}
});
}
value.calculateEvaluationExpression()
.done(expression -> {
if (expression != null) {
AppUIUtil.invokeOnEdt(() -> showDialog(session, file, editorsProvider, stackFrame, evaluator, expression));
}
});
return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -15,8 +15,8 @@
*/
package com.intellij.xdebugger.impl.actions.handlers;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.impl.ui.XDebugSessionData;
import org.jetbrains.annotations.Nullable;
@@ -24,10 +24,12 @@ import org.jetbrains.annotations.Nullable;
* @author nik
*/
public class XDebuggerMuteBreakpointsHandler extends XDebuggerToggleActionHandler {
@Override
protected boolean isEnabled(@Nullable final XDebugSession session, final AnActionEvent event) {
return true;
}
@Override
protected boolean isSelected(@Nullable final XDebugSession session, final AnActionEvent event) {
if (session != null) {
return session.areBreakpointsMuted();
@@ -41,6 +43,7 @@ public class XDebuggerMuteBreakpointsHandler extends XDebuggerToggleActionHandle
return false;
}
@Override
protected void setSelected(@Nullable final XDebugSession session, final AnActionEvent event, final boolean state) {
if (session != null) {
session.setBreakpointMuted(state);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -15,11 +15,11 @@
*/
package com.intellij.xdebugger.impl.actions.handlers;
import com.intellij.xdebugger.impl.actions.XDebuggerSuspendedActionHandler;
import com.intellij.xdebugger.impl.XDebuggerUtilImpl;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.xdebugger.impl.XDebuggerUtilImpl;
import com.intellij.xdebugger.impl.actions.XDebuggerSuspendedActionHandler;
import org.jetbrains.annotations.NotNull;
/**
@@ -32,10 +32,12 @@ public class XDebuggerRunToCursorActionHandler extends XDebuggerSuspendedActionH
myIgnoreBreakpoints = ignoreBreakpoints;
}
@Override
protected boolean isEnabled(final @NotNull XDebugSession session, final DataContext dataContext) {
return super.isEnabled(session, dataContext) && XDebuggerUtilImpl.getCaretPosition(session.getProject(), dataContext) != null;
}
@Override
protected void perform(@NotNull final XDebugSession session, final DataContext dataContext) {
XSourcePosition position = XDebuggerUtilImpl.getCaretPosition(session.getProject(), dataContext);
if (position != null) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -15,11 +15,11 @@
*/
package com.intellij.xdebugger.impl.actions.handlers;
import com.intellij.xdebugger.impl.actions.DebuggerToggleActionHandler;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.impl.actions.DebuggerToggleActionHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,16 +27,19 @@ import org.jetbrains.annotations.Nullable;
* @author nik
*/
public abstract class XDebuggerToggleActionHandler extends DebuggerToggleActionHandler {
@Override
public final boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
return isEnabled(session, event);
}
@Override
public boolean isSelected(@NotNull final Project project, final AnActionEvent event) {
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
return isSelected(session, event);
}
@Override
public void setSelected(@NotNull final Project project, final AnActionEvent event, final boolean state) {
XDebugSession session = XDebuggerManager.getInstance(project).getCurrentSession();
setSelected(session, event, state);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -44,6 +44,7 @@ public class XToggleLineBreakpointActionHandler extends DebuggerActionHandler {
myTemporary = temporary;
}
@Override
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
XLineBreakpointType<?>[] breakpointTypes = XDebuggerUtil.getInstance().getLineBreakpointTypes();
final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
@@ -59,6 +60,7 @@ public class XToggleLineBreakpointActionHandler extends DebuggerActionHandler {
return false;
}
@Override
public void perform(@NotNull final Project project, final AnActionEvent event) {
Editor editor = event.getData(CommonDataKeys.EDITOR);
// do not toggle more than once on the same line
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -56,12 +56,7 @@ public class BreakpointsFavoriteListProvider extends AbstractFavoritesListProvid
private final Set<XBreakpointGroupingRule> myRulesEnabled = new TreeSet<XBreakpointGroupingRule>(XBreakpointGroupingRule.PRIORITY_COMPARATOR);
private final SingleAlarm myRebuildAlarm = new SingleAlarm(new Runnable() {
@Override
public void run() {
updateChildren();
}
}, 100);
private final SingleAlarm myRebuildAlarm = new SingleAlarm(this::updateChildren, 100);
private final FavoritesManager myFavoritesManager;
public BreakpointsFavoriteListProvider(Project project, FavoritesManager favoritesManager) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -32,6 +32,7 @@ class RemoveBreakpointGutterIconAction extends DumbAwareAction {
copyShortcutFrom(action);
}
@Override
public void actionPerformed(final AnActionEvent e) {
XDebuggerUtil.getInstance().removeBreakpoint(myBreakpoint.getProject(), myBreakpoint);
}
@@ -52,6 +52,7 @@ class XBreakpointItem extends BreakpointItem {
setupGenericRenderer(renderer, false);
}
@Override
public void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
if (plainView) {
renderer.setIcon(getIcon());
@@ -65,6 +66,7 @@ class XBreakpointItem extends BreakpointItem {
}
}
@Override
public String getDisplayText() {
return XBreakpointUtil.getShortText(myBreakpoint);
}
@@ -74,6 +76,7 @@ class XBreakpointItem extends BreakpointItem {
return ((XBreakpointBase)myBreakpoint).getUserDescription();
}
@Override
public Icon getIcon() {
return ((XBreakpointBase)myBreakpoint).getIcon();
}
@@ -95,6 +98,7 @@ class XBreakpointItem extends BreakpointItem {
}
}
@Override
public void doUpdateDetailView(DetailView panel, boolean editorOnly) {
XBreakpointBase breakpoint = (XBreakpointBase)myBreakpoint;
Project project = breakpoint.getProject();
@@ -159,6 +163,7 @@ class XBreakpointItem extends BreakpointItem {
public void removed(Project project) {
final XBreakpointManagerImpl breakpointManager = getManager();
new WriteAction() {
@Override
protected void run(@NotNull final Result result) {
breakpointManager.removeBreakpoint(myBreakpoint);
}
@@ -195,6 +200,7 @@ class XBreakpointItem extends BreakpointItem {
}
}
@Override
public void dispose() {
if (myPropertiesPanel != null) {
myPropertiesPanel.dispose();
@@ -73,12 +73,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
myLineBreakpointManager = new XLineBreakpointManager(project, myDependentBreakpointManager, startupManager);
if (!project.isDefault()) {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
HttpVirtualFileListener httpVirtualFileListener = new HttpVirtualFileListener() {
@Override
public void fileDownloaded(@NotNull final VirtualFile file) {
updateBreakpointInFile(file);
}
};
HttpVirtualFileListener httpVirtualFileListener = this::updateBreakpointInFile;
HttpFileSystem.getInstance().addFileListener(httpVirtualFileListener, project);
}
for (XBreakpointType<?, ?> type : XBreakpointUtil.getBreakpointTypes()) {
@@ -88,14 +83,11 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
}
private void updateBreakpointInFile(final VirtualFile file) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
for (XBreakpointBase breakpoint : getAllBreakpoints()) {
XSourcePosition position = breakpoint.getSourcePosition();
if (position != null && Comparing.equal(position.getFile(), file)) {
fireBreakpointChanged(breakpoint);
}
ApplicationManager.getApplication().invokeLater(() -> {
for (XBreakpointBase breakpoint : getAllBreakpoints()) {
XSourcePosition position = breakpoint.getSourcePosition();
if (position != null && Comparing.equal(position.getFile(), file)) {
fireBreakpointChanged(breakpoint);
}
}
});
@@ -249,7 +241,7 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
public <B extends XBreakpoint<?>> Collection<? extends B> getBreakpoints(@NotNull final XBreakpointType<B,?> type) {
ApplicationManager.getApplication().assertReadAccessAllowed();
Collection<? extends XBreakpointBase<?,?,?>> breakpoints = myBreakpoints.get(type);
Collection<? extends B> regular = breakpoints != null ? Collections.unmodifiableCollection((Collection<? extends B>)breakpoints) : Collections.<B>emptyList();
Collection<? extends B> regular = breakpoints != null ? Collections.unmodifiableCollection((Collection<? extends B>)breakpoints) : Collections.emptyList();
final XBreakpointBase<?, ?, ?> defaultBreakpoint = myDefaultBreakpoints.get(type);
if (defaultBreakpoint == null) return regular;
@@ -456,13 +448,9 @@ public class XBreakpointManagerImpl implements XBreakpointManager, PersistentSta
@Nullable
private <P extends XBreakpointProperties> XBreakpoint<P> createDefaultBreakpoint(final XBreakpointType<? extends XBreakpoint<P>, P> type) {
return type.createDefaultBreakpoint(new XBreakpointType.XBreakpointCreator<P>() {
@NotNull
@Override
public XBreakpoint<P> createBreakpoint(@Nullable P properties) {
//noinspection unchecked
return XBreakpointManagerImpl.this.createBreakpoint((XBreakpointType<XBreakpoint<P>, P>)type, properties, false, true);
}
return type.createDefaultBreakpoint(properties -> {
//noinspection unchecked
return createBreakpoint((XBreakpointType<XBreakpoint<P>, P>)type, properties, false, true);
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -81,10 +81,12 @@ public class XBreakpointPanelProvider extends BreakpointPanelProvider<XBreakpoin
}
}
@Override
public int getPriority() {
return 0;
}
@Override
@Nullable
public XBreakpoint<?> findBreakpoint(@NotNull final Project project, @NotNull final Document document, final int offset) {
XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
@@ -114,6 +116,7 @@ public class XBreakpointPanelProvider extends BreakpointPanelProvider<XBreakpoin
return null;
}
@Override
public void onDialogClosed(final Project project) {
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -17,7 +17,6 @@ package com.intellij.xdebugger.impl.breakpoints;
import com.intellij.execution.impl.ConsoleViewUtil;
import com.intellij.ide.startup.StartupManagerEx;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
import com.intellij.openapi.application.ApplicationManager;
@@ -36,7 +35,6 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.DumbAwareRunnable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.Disposer;
@@ -46,7 +44,6 @@ import com.intellij.openapi.vfs.VirtualFileEvent;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.VirtualFileUrlChangeAdapter;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.util.Consumer;
import com.intellij.util.SmartList;
import com.intellij.util.containers.BidirectionalMap;
import com.intellij.util.ui.update.MergingUpdateQueue;
@@ -54,7 +51,6 @@ import com.intellij.util.ui.update.Update;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.breakpoints.SuspendPolicy;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.impl.XSourcePositionImpl;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import gnu.trove.TIntHashSet;
@@ -88,12 +84,7 @@ public class XLineBreakpointManager {
final MyDependentBreakpointListener myDependentBreakpointListener = new MyDependentBreakpointListener();
myDependentBreakpointManager.addListener(myDependentBreakpointListener);
Disposer.register(project, new Disposable() {
@Override
public void dispose() {
myDependentBreakpointManager.removeListener(myDependentBreakpointListener);
}
});
Disposer.register(project, () -> myDependentBreakpointManager.removeListener(myDependentBreakpointListener));
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileUrlChangeAdapter() {
@Override
protected void fileUrlChanged(String oldUrl, String newUrl) {
@@ -129,12 +120,9 @@ public class XLineBreakpointManager {
public void updateBreakpointsUI() {
if (myProject.isDefault()) return;
Runnable runnable = new DumbAwareRunnable() {
@Override
public void run() {
for (XLineBreakpointImpl breakpoint : myBreakpoints.keySet()) {
breakpoint.updateUI();
}
Runnable runnable = () -> {
for (XLineBreakpointImpl breakpoint : myBreakpoints.keySet()) {
breakpoint.updateUI();
}
};
@@ -195,12 +183,9 @@ public class XLineBreakpointManager {
return;
}
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
for (XBreakpoint<?> breakpoint : toRemove) {
XDebuggerManager.getInstance(myProject).getBreakpointManager().removeBreakpoint(breakpoint);
}
ApplicationManager.getApplication().runWriteAction(() -> {
for (XBreakpoint<?> breakpoint : toRemove) {
XDebuggerManager.getInstance(myProject).getBreakpointManager().removeBreakpoint(breakpoint);
}
});
}
@@ -287,44 +272,35 @@ public class XLineBreakpointManager {
return;
}
PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Runnable() {
@Override
public void run() {
final int line = EditorUtil.yPositionToLogicalLine(editor, mouseEvent);
final Document document = editor.getDocument();
final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
if (line >= 0 && line < document.getLineCount() && file != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!myProject.isDisposed() && myProject.isInitialized() && file.isValid()) {
ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT, e.getMouseEvent());
PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(() -> {
final int line = EditorUtil.yPositionToLogicalLine(editor, mouseEvent);
final Document document = editor.getDocument();
final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
if (line >= 0 && line < document.getLineCount() && file != null) {
ApplicationManager.getApplication().invokeLater(() -> {
if (!myProject.isDisposed() && myProject.isInitialized() && file.isValid()) {
ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT, e.getMouseEvent());
XBreakpointUtil
.toggleLineBreakpoint(myProject, XSourcePositionImpl.create(file, line), editor, mouseEvent.isAltDown(), false)
.done(new Consumer<XLineBreakpoint>() {
@Override
public void consume(XLineBreakpoint breakpoint) {
if (!mouseEvent.isAltDown() && mouseEvent.isShiftDown() && breakpoint != null) {
breakpoint.setSuspendPolicy(SuspendPolicy.NONE);
String selection = editor.getSelectionModel().getSelectedText();
if (selection != null) {
breakpoint.setLogExpression(selection);
}
else {
breakpoint.setLogMessage(true);
}
// edit breakpoint
DebuggerUIUtil
.showXBreakpointEditorBalloon(myProject, mouseEvent.getPoint(), ((EditorEx)editor).getGutterComponentEx(),
false, breakpoint);
}
}
});
}
}
});
}
XBreakpointUtil
.toggleLineBreakpoint(myProject, XSourcePositionImpl.create(file, line), editor, mouseEvent.isAltDown(), false)
.done(breakpoint -> {
if (!mouseEvent.isAltDown() && mouseEvent.isShiftDown() && breakpoint != null) {
breakpoint.setSuspendPolicy(SuspendPolicy.NONE);
String selection = editor.getSelectionModel().getSelectedText();
if (selection != null) {
breakpoint.setLogExpression(selection);
}
else {
breakpoint.setLogMessage(true);
}
// edit breakpoint
DebuggerUIUtil
.showXBreakpointEditorBalloon(myProject, mouseEvent.getPoint(), ((EditorEx)editor).getGutterComponentEx(),
false, breakpoint);
}
});
}
});
}
});
}
@@ -64,6 +64,7 @@ public class CodeFragmentInputComponent extends EvaluationInputComponent {
mySplitterProportionKey = splitterProportionKey;
}
@Override
@NotNull
protected XDebuggerEditorBase getInputEditor() {
return myMultilineEditor;
@@ -26,7 +26,6 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.*;
import com.intellij.util.NotNullProducer;
import com.intellij.util.containers.ObjectLongHashMap;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerManager;
@@ -52,9 +51,9 @@ import java.util.List;
*/
public class XDebuggerEditorLinePainter extends EditorLinePainter {
public static final Key<Map<Variable, VariableValue>> CACHE = Key.create("debug.inline.variables.cache");
// we want to limit number of line extentions to avoid very slow painting
// we want to limit number of line extensions to avoid very slow painting
// the constant is rather random (feel free to adjust it upon getting a new information)
private static final int LINE_EXTENTIONS_MAX_COUNT = 200;
private static final int LINE_EXTENSIONS_MAX_COUNT = 200;
@Override
public Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber) {
@@ -145,7 +144,7 @@ public class XDebuggerEditorLinePainter extends EditorLinePainter {
for (VariableText text : result) {
infos.addAll(text.infos);
}
return infos.size() > LINE_EXTENTIONS_MAX_COUNT ? infos.subList(0, LINE_EXTENTIONS_MAX_COUNT) : infos;
return infos.size() > LINE_EXTENSIONS_MAX_COUNT ? infos.subList(0, LINE_EXTENSIONS_MAX_COUNT) : infos;
}
return null;
}
@@ -170,14 +169,7 @@ public class XDebuggerEditorLinePainter extends EditorLinePainter {
public static TextAttributes getNormalAttributes() {
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.INLINED_VALUES);
if (attributes == null || attributes.getForegroundColor() == null) {
return new TextAttributes(new JBColor(new NotNullProducer<Color>() {
@SuppressWarnings("UseJBColor")
@NotNull
@Override
public Color produce() {
return isDarkEditor() ? new Color(0x3d8065) : Gray._135;
}
}), null, null, null, Font.ITALIC);
return new TextAttributes(new JBColor(() -> isDarkEditor() ? new Color(0x3d8065) : Gray._135), null, null, null, Font.ITALIC);
}
return attributes;
}
@@ -185,14 +177,7 @@ public class XDebuggerEditorLinePainter extends EditorLinePainter {
public static TextAttributes getChangedAttributes() {
TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.INLINED_VALUES_MODIFIED);
if (attributes == null || attributes.getForegroundColor() == null) {
return new TextAttributes(new JBColor(new NotNullProducer<Color>() {
@SuppressWarnings("UseJBColor")
@NotNull
@Override
public Color produce() {
return isDarkEditor() ? new Color(0xa1830a) : new Color(0xca8021);
}
}), null, null, null, Font.ITALIC);
return new TextAttributes(new JBColor(() -> isDarkEditor() ? new Color(0xa1830a) : new Color(0xca8021)), null, null, null, Font.ITALIC);
}
return attributes;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -106,12 +106,7 @@ public class WatchInplaceEditor extends XDebuggerTreeInplaceEditor {
}
private void cancel() {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
cancelEditing();
}
});
AppUIUtil.invokeOnEdt(WatchInplaceEditor.this::cancelEditing);
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -30,12 +30,7 @@ public class XDebugViewSessionListener extends XDebugSessionAdapter {
}
private void onSessionEvent(final @NotNull XDebugView.SessionEvent event) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
myDebugView.processSessionEvent(event);
}
});
AppUIUtil.invokeOnEdt(() -> myDebugView.processSessionEvent(event));
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -34,12 +34,9 @@ public class XStandaloneVariablesView extends XVariablesViewBase {
}
public void rebuildView() {
AppUIUtil.invokeLaterIfProjectAlive(getTree().getProject(), new Runnable() {
@Override
public void run() {
saveCurrentTreeState(myStackFrame);
buildTreeAndRestoreState(myStackFrame);
}
AppUIUtil.invokeLaterIfProjectAlive(getTree().getProject(), () -> {
saveCurrentTreeState(myStackFrame);
buildTreeAndRestoreState(myStackFrame);
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -38,16 +38,19 @@ import java.util.Map;
* @author max
*/
public class DebuggerColorsPage implements ColorSettingsPage, DisplayPrioritySortable {
@Override
@NotNull
public String getDisplayName() {
return XDebuggerBundle.message("xdebugger.colors.page.name");
}
@Override
@Nullable
public Icon getIcon() {
return AllIcons.Actions.StartDebugger;
}
@Override
@NotNull
public AttributesDescriptor[] getAttributeDescriptors() {
return new AttributesDescriptor[] {
@@ -60,6 +63,7 @@ public class DebuggerColorsPage implements ColorSettingsPage, DisplayPrioritySor
};
}
@Override
@NotNull
public ColorDescriptor[] getColorDescriptors() {
return new ColorDescriptor[] {
@@ -67,17 +71,20 @@ public class DebuggerColorsPage implements ColorSettingsPage, DisplayPrioritySor
};
}
@Override
@NotNull
public SyntaxHighlighter getHighlighter() {
return new PlainSyntaxHighlighter();
}
@Override
@NonNls
@NotNull
public String getDemoText() {
return " ";
}
@Override
@Nullable
public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
return null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -44,8 +44,6 @@ import com.intellij.xdebugger.XDebuggerBundle;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
/**
* @author nik
*/
@@ -68,12 +66,9 @@ public abstract class DebuggerSessionTabBase extends RunTab {
protected void attachNotificationTo(final Content content) {
if (myConsole instanceof ObservableConsoleView) {
ObservableConsoleView observable = (ObservableConsoleView)myConsole;
observable.addChangeListener(new ObservableConsoleView.ChangeListener() {
@Override
public void contentAdded(final Collection<ConsoleViewContentType> types) {
if (types.contains(ConsoleViewContentType.ERROR_OUTPUT) || types.contains(ConsoleViewContentType.NORMAL_OUTPUT)) {
content.fireAlert();
}
observable.addChangeListener(types -> {
if (types.contains(ConsoleViewContentType.ERROR_OUTPUT) || types.contains(ConsoleViewContentType.NORMAL_OUTPUT)) {
content.fireAlert();
}
}, content);
RunProfile profile = getRunProfile();
@@ -97,18 +92,15 @@ public abstract class DebuggerSessionTabBase extends RunTab {
public void select() {
if (ApplicationManager.getApplication().isUnitTestMode()) return;
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (myRunContentDescriptor != null) {
ToolWindow toolWindow = ExecutionManager.getInstance(myProject).getContentManager()
.getToolWindowByDescriptor(myRunContentDescriptor);
Content content = myRunContentDescriptor.getAttachedContent();
if (toolWindow == null || content == null) return;
ContentManager manager = toolWindow.getContentManager();
if (ArrayUtil.contains(content, manager.getContents()) && !manager.isSelected(content)) {
manager.setSelectedContent(content);
}
UIUtil.invokeLaterIfNeeded(() -> {
if (myRunContentDescriptor != null) {
ToolWindow toolWindow = ExecutionManager.getInstance(myProject).getContentManager()
.getToolWindowByDescriptor(myRunContentDescriptor);
Content content = myRunContentDescriptor.getAttachedContent();
if (toolWindow == null || content == null) return;
ContentManager manager = toolWindow.getContentManager();
if (ArrayUtil.contains(content, manager.getContents()) && !manager.isSelected(content)) {
manager.setSelectedContent(content);
}
}
});
@@ -117,32 +109,26 @@ public abstract class DebuggerSessionTabBase extends RunTab {
public void toFront(boolean focus, @Nullable final Runnable onShowCallback) {
if (ApplicationManager.getApplication().isUnitTestMode()) return;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myRunContentDescriptor != null) {
ToolWindow toolWindow = ExecutionManager.getInstance(myProject).getContentManager()
.getToolWindowByDescriptor(myRunContentDescriptor);
if (toolWindow != null) {
if (!toolWindow.isVisible()) {
toolWindow.show(onShowCallback);
}
//noinspection ConstantConditions
toolWindow.getContentManager().setSelectedContent(myRunContentDescriptor.getAttachedContent());
ApplicationManager.getApplication().invokeLater(() -> {
if (myRunContentDescriptor != null) {
ToolWindow toolWindow = ExecutionManager.getInstance(myProject).getContentManager()
.getToolWindowByDescriptor(myRunContentDescriptor);
if (toolWindow != null) {
if (!toolWindow.isVisible()) {
toolWindow.show(onShowCallback);
}
//noinspection ConstantConditions
toolWindow.getContentManager().setSelectedContent(myRunContentDescriptor.getAttachedContent());
}
}
});
if (focus) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
boolean focusWnd = Registry.is("debugger.mayBringFrameToFrontOnBreakpoint");
ProjectUtil.focusProjectWindow(myProject, focusWnd);
if (!focusWnd) {
AppIcon.getInstance().requestAttention(myProject, true);
}
ApplicationManager.getApplication().invokeLater(() -> {
boolean focusWnd = Registry.is("debugger.mayBringFrameToFrontOnBreakpoint");
ProjectUtil.focusProjectWindow(myProject, focusWnd);
if (!focusWnd) {
AppIcon.getInstance().requestAttention(myProject, true);
}
});
}
@@ -16,7 +16,6 @@
package com.intellij.xdebugger.impl.ui;
import com.intellij.codeInsight.hint.HintUtil;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
@@ -26,7 +25,10 @@ import com.intellij.openapi.editor.colors.EditorColorsUtil;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.*;
import com.intellij.openapi.util.*;
import com.intellij.openapi.util.DimensionService;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Getter;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.ui.AppUIUtil;
@@ -55,7 +57,10 @@ import org.jetbrains.concurrency.Promise;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseEvent;
import java.util.concurrent.atomic.AtomicBoolean;
public class DebuggerUIUtil {
@@ -65,29 +70,18 @@ public class DebuggerUIUtil {
}
public static void enableEditorOnCheck(final JCheckBox checkbox, final JComponent textfield) {
checkbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean selected = checkbox.isSelected();
textfield.setEnabled(selected);
}
checkbox.addActionListener(e -> {
boolean selected = checkbox.isSelected();
textfield.setEnabled(selected);
});
textfield.setEnabled(checkbox.isSelected());
}
public static void focusEditorOnCheck(final JCheckBox checkbox, final JComponent component) {
final Runnable runnable = new Runnable() {
@Override
public void run() {
component.requestFocus();
}
};
checkbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (checkbox.isSelected()) {
SwingUtilities.invokeLater(runnable);
}
final Runnable runnable = () -> component.requestFocus();
checkbox.addActionListener(e -> {
if (checkbox.isSelected()) {
SwingUtilities.invokeLater(runnable);
}
});
}
@@ -168,12 +162,9 @@ public class DebuggerUIUtil {
.setDimensionServiceKey(project, FULL_VALUE_POPUP_DIMENSION_KEY, false)
.setRequestFocus(false);
if (callback != null) {
builder.setCancelCallback(new Computable<Boolean>() {
@Override
public Boolean compute() {
callback.setObsolete();
return true;
}
builder.setCancelCallback(() -> {
callback.setObsolete();
return true;
});
}
return builder.createPopup();
@@ -193,18 +184,15 @@ public class DebuggerUIUtil {
final Ref<Boolean> isLoading = Ref.create(Boolean.FALSE);
final Ref<Boolean> moreOptionsRequested = 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);
moreOptionsRequested.set(true);
propertiesPanel.setDelegate(() -> {
if (!isLoading.get()) {
propertiesPanel.saveProperties();
}
if (!balloonRef.isNull()) {
balloonRef.get().hide();
}
showXBreakpointEditorBalloon(project, point, component, true, breakpoint);
moreOptionsRequested.set(true);
});
isLoading.set(Boolean.TRUE);
@@ -215,13 +203,10 @@ public class DebuggerUIUtil {
return;
}
Runnable showMoreOptions = new Runnable() {
@Override
public void run() {
propertiesPanel.saveProperties();
propertiesPanel.dispose();
BreakpointsDialogFactory.getInstance(project).showDialog(breakpoint);
}
Runnable showMoreOptions = () -> {
propertiesPanel.saveProperties();
propertiesPanel.dispose();
BreakpointsDialogFactory.getInstance(project).showDialog(breakpoint);
};
final JComponent mainPanel = propertiesPanel.getMainPanel();
@@ -247,12 +232,7 @@ public class DebuggerUIUtil {
});
breakpointManager.addBreakpointListener(breakpointListener);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
IdeFocusManager.findInstance().requestFocus(mainPanel, true);
}
});
ApplicationManager.getApplication().invokeLater(() -> IdeFocusManager.findInstance().requestFocus(mainPanel, true));
}
public static Balloon showBreakpointEditor(Project project, final JComponent mainPanel,
@@ -294,12 +274,7 @@ public class DebuggerUIUtil {
}
};
component.addComponentListener(moveListener);
Disposer.register(balloon, new Disposable() {
@Override
public void dispose() {
component.removeComponentListener(moveListener);
}
});
Disposer.register(balloon, () -> component.removeComponentListener(moveListener));
if (whereToShow == null) {
balloon.showInCenterOf(component);
@@ -347,25 +322,19 @@ public class DebuggerUIUtil {
@Override
public void evaluated(@NotNull final String fullValue, @Nullable final Font font) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
myTextArea.setText(fullValue);
if (font != null) {
myTextArea.setFont(font);
}
AppUIUtil.invokeOnEdt(() -> {
myTextArea.setText(fullValue);
if (font != null) {
myTextArea.setFont(font);
}
});
}
@Override
public void errorOccurred(@NotNull final String errorMessage) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
myTextArea.setForeground(XDebuggerUIConstants.ERROR_MESSAGE_ATTRIBUTES.getFgColor());
myTextArea.setText(errorMessage);
}
AppUIUtil.invokeOnEdt(() -> {
myTextArea.setForeground(XDebuggerUIConstants.ERROR_MESSAGE_ATTRIBUTES.getFgColor());
myTextArea.setText(errorMessage);
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -19,7 +19,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.editor.colors.EditorColorsListener;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
@@ -67,52 +66,41 @@ public class ExecutionPointHighlighter {
// Update highlighter colors if global color schema was changed
final EditorColorsManager colorsManager = EditorColorsManager.getInstance();
if (colorsManager != null) { // in some debugger tests EditorColorsManager component isn't loaded
colorsManager.addEditorColorsListener(new EditorColorsListener() {
@Override
public void globalSchemeChange(EditorColorsScheme scheme) {
update(false);
}
}, project);
colorsManager.addEditorColorsListener(scheme -> update(false), project);
}
}
public void show(final @NotNull XSourcePosition position, final boolean notTopFrame,
@Nullable final GutterIconRenderer gutterIconRenderer) {
updateRequested.set(false);
AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
@Override
public void run() {
updateRequested.set(false);
AppUIUtil.invokeLaterIfProjectAlive(myProject, () -> {
updateRequested.set(false);
mySourcePosition = position;
mySourcePosition = position;
clearDescriptor();
myOpenFileDescriptor = XSourcePositionImpl.createOpenFileDescriptor(myProject, position);
if (!XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isScrollToCenter()) {
myOpenFileDescriptor.setScrollType(notTopFrame ? ScrollType.CENTER : ScrollType.MAKE_VISIBLE);
}
//see IDEA-125645 and IDEA-63459
//myOpenFileDescriptor.setUseCurrentWindow(true);
myGutterIconRenderer = gutterIconRenderer;
myNotTopFrame = notTopFrame;
doShow(true);
clearDescriptor();
myOpenFileDescriptor = XSourcePositionImpl.createOpenFileDescriptor(myProject, position);
if (!XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isScrollToCenter()) {
myOpenFileDescriptor.setScrollType(notTopFrame ? ScrollType.CENTER : ScrollType.MAKE_VISIBLE);
}
//see IDEA-125645 and IDEA-63459
//myOpenFileDescriptor.setUseCurrentWindow(true);
myGutterIconRenderer = gutterIconRenderer;
myNotTopFrame = notTopFrame;
doShow(true);
});
}
public void hide() {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
updateRequested.set(false);
AppUIUtil.invokeOnEdt(() -> {
updateRequested.set(false);
removeHighlighter();
clearDescriptor();
myEditor = null;
myGutterIconRenderer = null;
}
removeHighlighter();
clearDescriptor();
myEditor = null;
myGutterIconRenderer = null;
});
}
@@ -136,24 +124,18 @@ public class ExecutionPointHighlighter {
public void update(final boolean navigate) {
if (updateRequested.compareAndSet(false, true)) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (updateRequested.compareAndSet(true, false)) {
doShow(navigate);
}
ApplicationManager.getApplication().invokeLater(() -> {
if (updateRequested.compareAndSet(true, false)) {
doShow(navigate);
}
}, myProject.getDisposed());
}
}
public void updateGutterIcon(@Nullable final GutterIconRenderer renderer) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
if (myRangeHighlighter != null && myGutterIconRenderer != null) {
myRangeHighlighter.setGutterIconRenderer(renderer);
}
AppUIUtil.invokeOnEdt(() -> {
if (myRangeHighlighter != null && myGutterIconRenderer != null) {
myRangeHighlighter.setGutterIconRenderer(renderer);
}
});
}
@@ -247,14 +229,11 @@ public class ExecutionPointHighlighter {
if (ApplicationManager.getApplication().isUnitTestMode()) return;
// need to always invoke later to maintain order of increment/decrement
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JComponent component = editor.getComponent();
Object o = component.getClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING);
Integer value = ((o instanceof Integer) ? (Integer)o : 0) + increment;
component.putClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
}
SwingUtilities.invokeLater(() -> {
JComponent component = editor.getComponent();
Object o = component.getClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING);
Integer value = ((o instanceof Integer) ? (Integer)o : 0) + increment;
component.putClientProperty(EditorImpl.IGNORE_MOUSE_TRACKING, value > 0 ? value : null);
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -212,12 +212,9 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
}
public void rebuildViews() {
AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
@Override
public void run() {
for (XDebugView view : myViews) {
view.processSessionEvent(XDebugView.SessionEvent.SETTINGS_CHANGED);
}
AppUIUtil.invokeLaterIfProjectAlive(myProject, () -> {
for (XDebugView view : myViews) {
view.processSessionEvent(XDebugView.SessionEvent.SETTINGS_CHANGED);
}
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -65,19 +65,11 @@ public class SetValueInplaceEditor extends XDebuggerTreeInplaceEditor {
final SetValueInplaceEditor editor = new SetValueInplaceEditor(node, nodeName);
if (editor.myModifier != null) {
editor.myModifier.calculateInitialValueEditorText(new XValueModifier.XInitialValueCallback() {
@Override
public void setValue(final String initialValue) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
if (editor.getTree().isShowing()) {
editor.show(initialValue);
}
}
});
editor.myModifier.calculateInitialValueEditorText(initialValue -> AppUIUtil.invokeOnEdt(() -> {
if (editor.getTree().isShowing()) {
editor.show(initialValue);
}
});
}));
}
else {
editor.show(null);
@@ -107,30 +99,22 @@ public class SetValueInplaceEditor extends XDebuggerTreeInplaceEditor {
@Override
public void valueModified() {
if (isDetachedTree(myTree)) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
myTree.rebuildAndRestore(treeState);
}
});
AppUIUtil.invokeOnEdt(() -> myTree.rebuildAndRestore(treeState));
}
XDebuggerUtilImpl.rebuildAllSessionsViews(getProject());
}
@Override
public void errorOccurred(@NotNull final String errorMessage) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
myTree.rebuildAndRestore(treeState);
AppUIUtil.invokeOnEdt(() -> {
myTree.rebuildAndRestore(treeState);
Editor editor = myExpressionEditor.getEditor();
if (editor != null) {
HintManager.getInstance().showErrorHint(editor, errorMessage);
}
else {
Messages.showErrorDialog(myTree, errorMessage);
}
Editor editor = myExpressionEditor.getEditor();
if (editor != null) {
HintManager.getInstance().showErrorHint(editor, errorMessage);
}
else {
Messages.showErrorDialog(myTree, errorMessage);
}
});
XDebuggerUtilImpl.rebuildAllSessionsViews(getProject());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -120,12 +120,7 @@ public abstract class TreeInplaceEditor implements AWTEventListener {
layeredPane.add(inplaceEditorComponent, new Integer(250));
myRemoveActions.add(new Runnable() {
@Override
public void run() {
layeredPane.remove(inplaceEditorComponent);
}
});
myRemoveActions.add(() -> layeredPane.remove(inplaceEditorComponent));
inplaceEditorComponent.validate();
inplaceEditorComponent.paintImmediately(0,0,inplaceEditorComponent.getWidth(),inplaceEditorComponent.getHeight());
@@ -135,22 +130,19 @@ public abstract class TreeInplaceEditor implements AWTEventListener {
@Override
public void componentResized(ComponentEvent e) {
final Project project = getProject();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!isShown() || project == null || project.isDisposed()) {
return;
}
JTree tree = getTree();
JLayeredPane layeredPane = tree.getRootPane().getLayeredPane();
Rectangle bounds = getEditorBounds();
if (bounds == null) {
return;
}
Point layeredPanePoint = SwingUtilities.convertPoint(tree, bounds.x, bounds.y, layeredPane);
setInplaceEditorBounds(inplaceEditorComponent, layeredPanePoint.x, layeredPanePoint.y, bounds.width, bounds.height);
inplaceEditorComponent.revalidate();
ApplicationManager.getApplication().invokeLater(() -> {
if (!isShown() || project == null || project.isDisposed()) {
return;
}
JTree tree1 = getTree();
JLayeredPane layeredPane1 = tree1.getRootPane().getLayeredPane();
Rectangle bounds1 = getEditorBounds();
if (bounds1 == null) {
return;
}
Point layeredPanePoint1 = SwingUtilities.convertPoint(tree1, bounds1.x, bounds1.y, layeredPane1);
setInplaceEditorBounds(inplaceEditorComponent, layeredPanePoint1.x, layeredPanePoint1.y, bounds1.width, bounds1.height);
inplaceEditorComponent.revalidate();
});
}
@@ -160,12 +152,9 @@ public abstract class TreeInplaceEditor implements AWTEventListener {
}
};
final HierarchyListener hierarchyListener = new HierarchyListener() {
@Override
public void hierarchyChanged(HierarchyEvent e) {
if (!tree.isShowing()) {
cancelEditing();
}
final HierarchyListener hierarchyListener = e -> {
if (!tree.isShowing()) {
cancelEditing();
}
};
@@ -173,13 +162,10 @@ public abstract class TreeInplaceEditor implements AWTEventListener {
tree.addComponentListener(componentListener);
rootPane.addComponentListener(componentListener);
myRemoveActions.add(new Runnable() {
@Override
public void run() {
tree.removeHierarchyListener(hierarchyListener);
tree.removeComponentListener(componentListener);
rootPane.removeComponentListener(componentListener);
}
myRemoveActions.add(() -> {
tree.removeHierarchyListener(hierarchyListener);
tree.removeComponentListener(componentListener);
rootPane.removeComponentListener(componentListener);
});
final Disposable disposable = Disposer.newDisposable();
@@ -194,12 +180,7 @@ public abstract class TreeInplaceEditor implements AWTEventListener {
cancelEditing();
}
});
myRemoveActions.add(new Runnable() {
@Override
public void run() {
Disposer.dispose(disposable);
}
});
myRemoveActions.add(() -> Disposer.dispose(disposable));
final JComponent editorComponent = getEditorComponent();
editorComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enterStroke");
@@ -217,20 +198,12 @@ public abstract class TreeInplaceEditor implements AWTEventListener {
}
});
final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!isShown()) return;
defaultToolkit.addAWTEventListener(TreeInplaceEditor.this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
}
SwingUtilities.invokeLater(() -> {
if (!isShown()) return;
defaultToolkit.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
});
myRemoveActions.add(new Runnable() {
@Override
public void run() {
defaultToolkit.removeAWTEventListener(TreeInplaceEditor.this);
}
});
myRemoveActions.add(() -> defaultToolkit.removeAWTEventListener(this));
onShown();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -84,18 +84,15 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider, Disposa
}
}, 100, this);
private static final Convertor<TreePath, String> SPEED_SEARCH_CONVERTER = new Convertor<TreePath, String>() {
@Override
public String convert(TreePath o) {
String text = null;
if (o != null) {
final Object node = o.getLastPathComponent();
if (node instanceof XDebuggerTreeNode) {
text = ((XDebuggerTreeNode)node).getText().toString();
}
private static final Convertor<TreePath, String> SPEED_SEARCH_CONVERTER = o -> {
String text = null;
if (o != null) {
final Object node = o.getLastPathComponent();
if (node instanceof XDebuggerTreeNode) {
text = ((XDebuggerTreeNode)node).getText().toString();
}
return StringUtil.notNullize(text);
}
return StringUtil.notNullize(text);
};
private static final TransferHandler DEFAULT_TRANSFER_HANDLER = new TransferHandler() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -60,6 +60,7 @@ public abstract class XDebuggerTreeInplaceEditor extends TreeInplaceEditor {
doOKAction();
}
@Override
protected JComponent getPreferredFocusedComponent() {
return myExpressionEditor.getPreferredFocusedComponent();
}
@@ -68,22 +69,27 @@ public abstract class XDebuggerTreeInplaceEditor extends TreeInplaceEditor {
return myNode;
}
@Override
public Editor getEditor() {
return myExpressionEditor.getEditor();
}
@Override
public JComponent getEditorComponent() {
return myExpressionEditor.getEditorComponent();
}
@Override
protected TreePath getNodePath() {
return myNode.getPath();
}
@Override
protected JTree getTree() {
return myNode.getTree();
}
@Override
protected Project getProject() {
return myNode.getTree().getProject();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -24,7 +24,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
@@ -74,12 +73,7 @@ public class XDebuggerTreePanel implements DnDSource {
}
private XValueNodeImpl[] getNodesToDrag() {
return myTree.getSelectedNodes(XValueNodeImpl.class, new Tree.NodeFilter<XValueNodeImpl>() {
@Override
public boolean accept(final XValueNodeImpl node) {
return DebuggerUIUtil.hasEvaluationExpression(node.getValueContainer());
}
});
return myTree.getSelectedNodes(XValueNodeImpl.class, node -> DebuggerUIUtil.hasEvaluationExpression(node.getValueContainer()));
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -117,6 +117,7 @@ public class XDebuggerTreeRestorer implements XDebuggerTreeListener, TreeSelecti
return false;
}
@Override
public void nodeLoaded(@NotNull final RestorableStateNode node, final String name) {
XDebuggerTreeState.NodeInfo parentInfo = myNode2ParentState.remove(node);
if (parentInfo != null) {
@@ -134,6 +135,7 @@ public class XDebuggerTreeRestorer implements XDebuggerTreeListener, TreeSelecti
}
}
@Override
public void childrenLoaded(@NotNull final XDebuggerTreeNode node, @NotNull final List<XValueContainerNode<?>> children, final boolean last) {
XDebuggerTreeState.NodeInfo nodeInfo = myNode2State.get(node);
if (nodeInfo != null) {
@@ -154,6 +156,7 @@ public class XDebuggerTreeRestorer implements XDebuggerTreeListener, TreeSelecti
myTree.removeTreeSelectionListener(this);
}
@Override
public void valueChanged(TreeSelectionEvent e) {
if (!myInsideRestoring) {
myStopRestoringSelection = true;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -29,7 +29,6 @@ import com.intellij.xdebugger.impl.evaluate.quick.XDebuggerInstanceTreeCreator;
import com.intellij.xdebugger.impl.evaluate.quick.XDebuggerTreeCreator;
import com.intellij.xdebugger.impl.evaluate.quick.common.DebuggerTreeWithHistoryPanel;
import com.intellij.xdebugger.impl.frame.XValueMarkers;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -17,13 +17,9 @@ package com.intellij.xdebugger.impl.ui.tree.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Consumer;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.impl.XDebugSessionImpl;
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
import com.intellij.xdebugger.impl.frame.XWatchesView;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
@@ -43,12 +39,10 @@ class XAddToWatchesAction extends XDebuggerTreeActionBase {
protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) {
final XWatchesView watchesView = getWatchesView(e);
if (watchesView != null) {
node.getValueContainer().calculateEvaluationExpression().done(new Consumer<XExpression>() {
@Override
public void consume(XExpression expression) {
if (expression != null) {
watchesView.addWatchExpression(expression, -1, true);
}
node.getValueContainer().calculateEvaluationExpression()
.done(expression -> {
if (expression != null) {
watchesView.addWatchExpression(expression, -1, true);
}
});
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -163,12 +163,9 @@ public abstract class XFetchValueActionBase extends AnAction {
}
public void evaluationComplete(final int index, @NotNull final String value) {
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
values.set(index, value);
finish();
}
AppUIUtil.invokeOnEdt(() -> {
values.set(index, value);
finish();
});
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -20,13 +20,11 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.ui.AppUIUtil;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.frame.XNavigatable;
import com.intellij.xdebugger.frame.XValue;
import com.intellij.xdebugger.impl.evaluate.XDebuggerEvaluationDialog;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author nik
@@ -36,21 +34,15 @@ public abstract class XJumpToSourceActionBase extends XDebuggerTreeActionBase {
protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) {
XValue value = node.getValueContainer();
final XDebuggerEvaluationDialog dialog = e.getData(XDebuggerEvaluationDialog.KEY);
XNavigatable navigatable = new XNavigatable() {
@Override
public void setSourcePosition(@Nullable final XSourcePosition sourcePosition) {
if (sourcePosition != null) {
final Project project = node.getTree().getProject();
AppUIUtil.invokeOnEdt(new Runnable() {
@Override
public void run() {
sourcePosition.createNavigatable(project).navigate(true);
if (dialog != null && Registry.is("debugger.close.dialog.on.navigate")) {
dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
}
}
}, project.getDisposed());
}
XNavigatable navigatable = sourcePosition -> {
if (sourcePosition != null) {
final Project project = node.getTree().getProject();
AppUIUtil.invokeOnEdt(() -> {
sourcePosition.createNavigatable(project).navigate(true);
if (dialog != null && Registry.is("debugger.close.dialog.on.navigate")) {
dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
}
}, project.getDisposed());
}
};
startComputingSourcePosition(value, navigatable);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -18,7 +18,6 @@ package com.intellij.xdebugger.impl.ui.tree.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.xdebugger.impl.ui.tree.SetValueInplaceEditor;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTreeInplaceEditor;
import com.intellij.xdebugger.impl.ui.tree.nodes.WatchNode;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import org.jetbrains.annotations.NotNull;
@@ -46,6 +45,7 @@ public class XSetValueAction extends XDebuggerTreeActionBase {
return super.isEnabled(node, e) && node.getValueContainer().getModifier() != null;
}
@Override
protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) {
SetValueInplaceEditor.show(node, nodeName);
}