Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anna Kozlova
2014-04-08 12:50:16 +02:00
7 changed files with 267 additions and 39 deletions
@@ -0,0 +1,90 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @author egor
*/
package com.intellij.debugger.actions;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
import com.intellij.debugger.impl.DebuggerContextImpl;
import com.intellij.debugger.jdi.StackFrameProxyImpl;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.ui.classFilter.ClassFilter;
import com.sun.jdi.Location;
import com.sun.jdi.ReferenceType;
import java.util.Arrays;
public class AddSteppingFilterAction extends DebuggerAction {
public void actionPerformed(final AnActionEvent e) {
final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process == null) {
return;
}
process.getManagerThread().schedule(new DebuggerCommandImpl() {
protected void action() throws Exception {
final String name = getClassName(debuggerContext.getFrameProxy());
if (name == null) {
return;
}
final Project project = e.getData(CommonDataKeys.PROJECT);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
String filter = Messages.showInputDialog(project, "", "Add Stepping Filter", null, name, null);
if (filter != null) {
ClassFilter[] filters = DebuggerSettings.getInstance().getSteppingFilters();
ClassFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1);
newFilters[newFilters.length - 1] = new ClassFilter(filter);
DebuggerSettings.getInstance().setSteppingFilters(newFilters);
}
}
});
}
});
}
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(true);
}
private static String getClassName(StackFrameProxyImpl stackFrameProxy) {
if (stackFrameProxy != null) {
try {
Location location = stackFrameProxy.location();
if (location != null) {
ReferenceType type = location.declaringType();
if (type != null) {
return type.name();
}
}
}
catch (EvaluateException ignore) {
}
}
return null;
}
}
@@ -83,7 +83,7 @@ public class DebuggerSettings implements JDOMExternalizable, NamedComponent, Clo
return rv;
}
void setSteppingFilters(ClassFilter[] steppingFilters) {
public void setSteppingFilters(ClassFilter[] steppingFilters) {
mySteppingFilters = steppingFilters != null ? steppingFilters : ClassFilter.EMPTY_ARRAY;
}
@@ -167,6 +167,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
private ArrayList<AnAction> myAlreadyAddedActions = new ArrayList<AnAction>();
private volatile ActionCallback myCurrentWorker = ActionCallback.DONE;
private int myHistoryIndex = 0;
boolean mySkipFocusGain = false;
static {
IdeEventQueue.getInstance().addPostprocessor(new IdeEventQueue.EventDispatcher() {
@@ -356,10 +357,19 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
myList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
e.consume();
final int i = myList.locationToIndex(e.getPoint());
if (i != -1) {
myList.setSelectedIndex(i);
doNavigate(i);
mySkipFocusGain = true;
getField().requestFocus();
//noinspection SSBasedInspection
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
myList.setSelectedIndex(i);
doNavigate(i);
}
});
}
}
});
@@ -431,12 +441,10 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
}
});
editor.addFocusListener(new FocusAdapter() {
boolean skip = false;
@Override
public void focusGained(FocusEvent e) {
if (skip) {
skip = false;
if (mySkipFocusGain) {
mySkipFocusGain = false;
return;
}
search.setText("");
@@ -467,7 +475,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
return;
}
if (myNonProjectCheckBox == e.getOppositeComponent()) {
skip = true;
mySkipFocusGain = true;
editor.requestFocus();
return;
}
@@ -545,9 +553,15 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
if (actionId != null) {
final AnAction action = ActionManager.getInstance().getAction(actionId);
GotoActionAction.openOptionOrPerformAction(action, getField().getText(), project, getField(), myActionEvent);
if (myPopup != null && myPopup.isVisible()) {
myPopup.cancel();
}
//noinspection SSBasedInspection
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myPopup != null && myPopup.isVisible()) {
myPopup.cancel();
}
}
});
return;
}
}
@@ -1755,33 +1769,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
@Override
public void dispose() {
callback.setDone();
if (myBalloon!= null) {
myBalloon.cancel();
myBalloon = null;
}
myFileModel = null;
if (myFileChooseByName != null) {
myFileChooseByName.close(false);
myFileChooseByName = null;
}
myClassModel = null;
myActionModel = null;
myActions = null;
myFiles = null;
myClasses = null;
mySymbolsModel = null;
mySymbols = null;
myConfigurables.clear();
myFocusComponent = null;
myContextComponent = null;
myFocusOwner = null;
myRenderer.myProject = null;
myCalcThread = null;
myPopup = null;
myHistoryIndex = 0;
myPopupActualWidth = 0;
myCurrentWorker = ActionCallback.DONE;
showAll.set(false);
resetFields();
myNonProjectCheckBox.setSelected(false);
ActionToolbarImpl.updateAllToolbarsImmediately();
if (myActionEvent != null && myActionEvent.getInputEvent() instanceof MouseEvent) {
@@ -1883,6 +1871,37 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
}
}
protected void resetFields() {
if (myBalloon!= null) {
myBalloon.cancel();
myBalloon = null;
}
myFileModel = null;
if (myFileChooseByName != null) {
myFileChooseByName.close(false);
myFileChooseByName = null;
}
myClassModel = null;
myActionModel = null;
myActions = null;
myFiles = null;
myClasses = null;
mySymbolsModel = null;
mySymbols = null;
myConfigurables.clear();
myFocusComponent = null;
myContextComponent = null;
myFocusOwner = null;
myRenderer.myProject = null;
myCalcThread = null;
myPopup = null;
myHistoryIndex = 0;
myPopupActualWidth = 0;
myCurrentWorker = ActionCallback.DONE;
showAll.set(false);
mySkipFocusGain = false;
}
private void updatePopupBounds() {
if (myPopup == null || !myPopup.isVisible()) {
return;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -55,6 +55,7 @@ public class FocusTracesDialog extends DialogWrapper {
final FocusRequestInfo r = requests.get(i);
data[i] = new String[]{r.getDate(), String.valueOf(r.isForced()), String.valueOf(r.getComponent())};
}
setModal(false);
myRequestsTable = new JBTable(new DefaultTableModel(data, COLUMNS) {
@Override
public boolean isCellEditable(int row, int column) {
@@ -0,0 +1,89 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.execution.impl;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.ide.DataManager;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.actionSystem.TypedAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.LightPlatformTestCase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.OutputStream;
public class ConsoleViewImplTest extends LightPlatformTestCase {
public void testTypeText() throws Exception {
final ConsoleViewImpl console = createConsole();
console.print("Initial", ConsoleViewContentType.NORMAL_OUTPUT);
console.flushDeferredText();
try {
console.clear();
type(console, '1');
type(console, '2');
}
finally {
Disposer.dispose(console);
}
}
@NotNull
private static ConsoleViewImpl createConsole() {
Project project = getProject();
ConsoleViewImpl console = new ConsoleViewImpl(project,
GlobalSearchScope.allScope(project),
false,
false);
console.getComponent();
ProcessHandler processHandler = new MyProcessHandler();
processHandler.startNotify();
console.attachToProcess(processHandler);
return console;
}
private static void type(ConsoleViewImpl console, char c) {
EditorActionManager actionManager = EditorActionManager.getInstance();
TypedAction action = actionManager.getTypedAction();
action.actionPerformed(console.getEditor(), c, DataManager.getInstance().getDataContext(console.getComponent()));
}
private static class MyProcessHandler extends ProcessHandler {
@Override
protected void destroyProcessImpl() {
notifyProcessTerminated(0);
}
@Override
protected void detachProcessImpl() {
}
@Override
public boolean detachIsDefault() {
return false;
}
@Nullable
@Override
public OutputStream getProcessInput() {
return null;
}
}
}
@@ -2909,4 +2909,30 @@ public class UIUtil {
return null;
}
private static Map<String, String> ourRealFontFamilies = null;
public static String getRealFontFamily(String genericFontFamily) {
if (ourRealFontFamilies != null && ourRealFontFamilies.get(genericFontFamily) != null) {
return ourRealFontFamilies.get(genericFontFamily);
}
String pattern = "Real Font Family";
List<String> GENERIC = Arrays.asList(Font.DIALOG, Font.DIALOG_INPUT, Font.MONOSPACED, Font.SANS_SERIF, Font.SERIF);
int patternSize = 50;
BufferedImage image = createImage(1, 1, BufferedImage.TYPE_INT_ARGB);
Graphics graphics = image.getGraphics();
graphics.setFont(new Font(genericFontFamily, Font.PLAIN, patternSize));
Object patternBounds = graphics.getFontMetrics().getStringBounds(pattern, graphics);
for (String family: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) {
if (GENERIC.contains(family)) continue;
graphics.setFont(new Font(family, Font.PLAIN, patternSize));
if (graphics.getFontMetrics().getStringBounds(pattern, graphics).equals(patternBounds)) {
if (ourRealFontFamilies == null) {
ourRealFontFamilies = new HashMap<String, String>();
}
ourRealFontFamilies.put(genericFontFamily, family);
return family;
}
}
return genericFontFamily;
}
}
+3
View File
@@ -104,6 +104,8 @@
<add-to-group group-id="DebugMainMenu" anchor="after" relative-to-action="ForceRunToCursor"/>
</action>
<action id="Debugger.AddSteppingFilter" class="com.intellij.debugger.actions.AddSteppingFilterAction" text="Add Stepping Filter..."/>
<group id="ToggleBreakpointAction">
<action id="ToggleMethodBreakpoint" class="com.intellij.debugger.actions.ToggleMethodBreakpointAction"/>
<action id="ToggleFieldBreakpoint" class="com.intellij.debugger.actions.ToggleFieldBreakpointAction"/>
@@ -285,6 +287,7 @@
<!--<reference ref="EditSource"/>-->
<separator/>
<reference ref="ExportThreads"/>
<reference ref="Debugger.AddSteppingFilter"/>
<separator/>
<reference ref="Debugger.CustomizeThreadsView"/>
</group>