From c09045ee61f30444e393f49f30eed447098d992b Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Tue, 8 Apr 2014 14:25:31 +0400 Subject: [PATCH 1/5] console insert user text test --- .../execution/impl/ConsoleViewImplTest.java | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java diff --git a/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java b/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java new file mode 100644 index 000000000000..ffeab5b769c6 --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java @@ -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; + } + } +} From 732de39314959e7d793e6c0f6e1698b4d98ff3d9 Mon Sep 17 00:00:00 2001 From: Vassiliy Date: Tue, 8 Apr 2014 14:08:31 +0400 Subject: [PATCH 2/5] Real font families by generic names (cherry picked from commit 286ecf7) --- .../util/src/com/intellij/util/ui/UIUtil.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 86b3d93a9213..ee56a623e483 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -2909,4 +2909,30 @@ public class UIUtil { return null; } + private static Map 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 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(); + } + ourRealFontFamilies.put(genericFontFamily, family); + return family; + } + } + return genericFontFamily; + } } From 8bb23c3f16cf8cc1d74e1979737d1bd477c830e2 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 8 Apr 2014 12:33:57 +0200 Subject: [PATCH 3/5] =?UTF-8?q?IDEA-123444=20Item=20=E2=80=9Cmore=E2=80=A6?= =?UTF-8?q?=E2=80=9D=20on=20Search=20Everywhere=20does=20not=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ide/actions/SearchEverywhereAction.java | 93 +++++++++++-------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index 9dd6d343f14e..f54c4a472280 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -167,6 +167,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA private ArrayList myAlreadyAddedActions = new ArrayList(); 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; From aad1a93924398d3e8bdcaf25b6f85f3db0cbed79 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 8 Apr 2014 12:34:38 +0200 Subject: [PATCH 4/5] make the dialog non-modal to compare traces --- .../src/com/intellij/internal/focus/FocusTracesDialog.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.java b/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.java index a9ab36046cc0..dbeff3213c4a 100644 --- a/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.java +++ b/platform/platform-impl/src/com/intellij/internal/focus/FocusTracesDialog.java @@ -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) { From 61243fb5d116a849166c33f0e7dc7dcf3bcc45cd Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 8 Apr 2014 14:47:48 +0400 Subject: [PATCH 5/5] IDEA-123619 Simplify adding stepping filters --- .../actions/AddSteppingFilterAction.java | 90 +++++++++++++++++++ .../debugger/settings/DebuggerSettings.java | 2 +- resources/src/idea/JavaActions.xml | 3 + 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java b/java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java new file mode 100644 index 000000000000..269a8b60c7ea --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/actions/AddSteppingFilterAction.java @@ -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; + } +} diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java index 8a1762d17167..f4c9b3d87480 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/DebuggerSettings.java @@ -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; } diff --git a/resources/src/idea/JavaActions.xml b/resources/src/idea/JavaActions.xml index c0a7d4ade398..d22afe07318a 100644 --- a/resources/src/idea/JavaActions.xml +++ b/resources/src/idea/JavaActions.xml @@ -104,6 +104,8 @@ + + @@ -285,6 +287,7 @@ +