IDEA-139797 Default Theme doesn't allow to apply font size to evaluate expression...
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Fri, 24 Jul 2015 13:29:48 +0000 (16:29 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Fri, 24 Jul 2015 13:51:30 +0000 (16:51 +0300)
platform/platform-resources-en/src/messages/XDebuggerBundle.properties
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputComponent.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java [moved from platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java with 79% similarity]

index 5c4b5649ec2d074977648d9e2852dfc15e83ecef..7c9c2284b7c7b4816f8f9285b398c4ed18d8348b 100644 (file)
@@ -53,6 +53,8 @@ xbreakpoint.label.empty=Select a breakpoint
 
 xbreakpoint.reached.text=Breakpoint reached:
 
+xdebugger.evaluate.language.hint=Click to change the language
+xdebugger.evaluate.history.hint=Show history
 xdebugger.evaluate.label.result=&Result:
 xdebugger.button.evaluate=E&valuate
 xdebugger.evaluate.dialog.close=Close
index 63349076ddb4160d6c8b937fe44f42576a59f091..cf3a9fd48160cf2e7cd0bb64ee18d4981b8580b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 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,7 @@ import com.intellij.xdebugger.XSourcePosition;
 import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
 import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
 import com.intellij.xdebugger.impl.ui.XDebuggerEditorBase;
-import com.intellij.xdebugger.impl.ui.XDebuggerMultilineEditor;
+import com.intellij.xdebugger.impl.ui.XDebuggerExpressionEditor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -36,13 +36,14 @@ import java.awt.*;
  * @author nik
  */
 public class CodeFragmentInputComponent extends EvaluationInputComponent {
-  private final XDebuggerMultilineEditor myMultilineEditor;
+  private final XDebuggerExpressionEditor myMultilineEditor;
   private final JPanel myMainPanel;
 
   public CodeFragmentInputComponent(final @NotNull Project project, @NotNull XDebuggerEditorsProvider editorsProvider,
                                     final @Nullable XSourcePosition sourcePosition, @Nullable XExpression statements, Disposable parentDisposable) {
     super(XDebuggerBundle.message("dialog.title.evaluate.code.fragment"));
-    myMultilineEditor = new XDebuggerMultilineEditor(project, editorsProvider, "evaluateCodeFragment", sourcePosition, statements != null ? statements : XExpressionImpl.EMPTY_CODE_FRAGMENT);
+    myMultilineEditor = new XDebuggerExpressionEditor(project, editorsProvider, "evaluateCodeFragment", sourcePosition,
+                                                      statements != null ? statements : XExpressionImpl.EMPTY_CODE_FRAGMENT, true);
     myMainPanel = new JPanel(new BorderLayout());
     JPanel editorPanel = new JPanel(new BorderLayout());
     editorPanel.add(myMultilineEditor.getComponent(), BorderLayout.CENTER);
@@ -50,7 +51,7 @@ public class CodeFragmentInputComponent extends EvaluationInputComponent {
     group.add(new HistoryNavigationAction(false, IdeActions.ACTION_PREVIOUS_OCCURENCE, parentDisposable));
     group.add(new HistoryNavigationAction(true, IdeActions.ACTION_NEXT_OCCURENCE, parentDisposable));
     editorPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false).getComponent(), BorderLayout.EAST);
-    myMainPanel.add(new JLabel(XDebuggerBundle.message("xdebugger.label.text.code.fragment")), BorderLayout.NORTH);
+    //myMainPanel.add(new JLabel(XDebuggerBundle.message("xdebugger.label.text.code.fragment")), BorderLayout.NORTH);
     myMainPanel.add(editorPanel, BorderLayout.CENTER);
     if (statements != null) {
       myMultilineEditor.setExpression(statements);
index e3295b5cce37e6b32d5caf21aa3ea8161180dc8d..8fbf2f32dac6f86e383b5e5c1f6b2021e03b2304 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 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.
  */
 package com.intellij.xdebugger.impl.evaluate;
 
+import com.intellij.codeInsight.lookup.LookupManager;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.CustomShortcutSet;
+import com.intellij.openapi.editor.ex.util.EditorUtil;
 import com.intellij.openapi.project.Project;
-import com.intellij.ui.IdeBorderFactory;
+import com.intellij.openapi.ui.popup.PopupStep;
+import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
+import com.intellij.ui.ColoredListCellRenderer;
 import com.intellij.ui.components.JBLabel;
+import com.intellij.ui.popup.list.ListPopupImpl;
+import com.intellij.util.ui.JBUI;
 import com.intellij.util.ui.UIUtil;
 import com.intellij.xdebugger.XDebuggerBundle;
 import com.intellij.xdebugger.XExpression;
 import com.intellij.xdebugger.XSourcePosition;
 import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
+import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
 import com.intellij.xdebugger.impl.ui.XDebuggerEditorBase;
-import com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox;
+import com.intellij.xdebugger.impl.ui.XDebuggerExpressionEditor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
 
 /**
  * @author nik
  */
 public class ExpressionInputComponent extends EvaluationInputComponent {
-  private final XDebuggerExpressionComboBox myExpressionComboBox;
+  private final XDebuggerExpressionEditor myExpressionEditor;
   private final JPanel myMainPanel;
 
   public ExpressionInputComponent(final @NotNull Project project, @NotNull XDebuggerEditorsProvider editorsProvider, final @Nullable XSourcePosition sourcePosition,
                                   @Nullable XExpression expression) {
     super(XDebuggerBundle.message("xdebugger.dialog.title.evaluate.expression"));
     myMainPanel = new JPanel(new BorderLayout());
-    myMainPanel.add(new JLabel(XDebuggerBundle.message("xdebugger.evaluate.label.expression")), BorderLayout.WEST);
-    myExpressionComboBox = new XDebuggerExpressionComboBox(project, editorsProvider, "evaluateExpression", sourcePosition);
-    myExpressionComboBox.getComboBox().setMinimumAndPreferredWidth(250);
-    myMainPanel.add(myExpressionComboBox.getComponent(), BorderLayout.CENTER);
+    //myMainPanel.add(new JLabel(XDebuggerBundle.message("xdebugger.evaluate.label.expression")), BorderLayout.WEST);
+    myExpressionEditor = new XDebuggerExpressionEditor(project, editorsProvider, "evaluateExpression", sourcePosition,
+                                                       expression != null ? expression : XExpressionImpl.EMPTY_EXPRESSION, false);
+    myMainPanel.add(myExpressionEditor.getComponent(), BorderLayout.CENTER);
+    JButton historyButton = new JButton(AllIcons.General.MessageHistory);
+    historyButton.setToolTipText(XDebuggerBundle.message("xdebugger.evaluate.history.hint"));
+    historyButton.addActionListener(new ActionListener() {
+      @Override
+      public void actionPerformed(ActionEvent e) {
+        showHistory();
+      }
+    });
+    myMainPanel.add(historyButton, BorderLayout.EAST);
     final JBLabel help = new JBLabel(XDebuggerBundle.message("xdebugger.evaluate.addtowatches.hint"), SwingConstants.RIGHT);
-    help.setBorder(IdeBorderFactory.createEmptyBorder(2,0,6,0));
+    help.setBorder(JBUI.Borders.empty(2, 0, 6, 0));
     help.setComponentStyle(UIUtil.ComponentStyle.SMALL);
     help.setFontColor(UIUtil.FontColor.BRIGHTER);
     myMainPanel.add(help, BorderLayout.SOUTH);
     if (expression != null) {
-      myExpressionComboBox.setExpression(expression);
+      myExpressionEditor.setExpression(expression);
+    }
+    myExpressionEditor.selectAll();
+
+    new AnAction("XEvaluateDialog.ShowHistory") {
+      @Override
+      public void actionPerformed(AnActionEvent e) {
+        showHistory();
+      }
+
+      @Override
+      public void update(AnActionEvent e) {
+        e.getPresentation().setEnabled(LookupManager.getActiveLookup(myExpressionEditor.getEditor()) == null);
+      }
+    }.registerCustomShortcutSet(CustomShortcutSet.fromString("DOWN"), myMainPanel);
+  }
+
+  private void showHistory() {
+    List<XExpression> expressions = myExpressionEditor.getRecentExpressions();
+    if (!expressions.isEmpty()) {
+      ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null, expressions) {
+        @Override
+        public PopupStep onChosen(XExpression selectedValue, boolean finalChoice) {
+          myExpressionEditor.setExpression(selectedValue);
+          myExpressionEditor.requestFocusInEditor();
+          return FINAL_CHOICE;
+        }
+      }) {
+        @Override
+        protected ListCellRenderer getListElementRenderer() {
+          return new ColoredListCellRenderer<XExpression>() {
+            @Override
+            protected void customizeCellRenderer(JList list, XExpression value, int index, boolean selected, boolean hasFocus) {
+              append(value.getExpression());
+            }
+          };
+        }
+      };
+      popup.getList().setFont(EditorUtil.getEditorFont());
+      popup.showUnderneathOf(myExpressionEditor.getComponent());
     }
-    myExpressionComboBox.selectAll();
   }
 
   @Override
@@ -65,6 +126,6 @@ public class ExpressionInputComponent extends EvaluationInputComponent {
 
   @NotNull
   protected XDebuggerEditorBase getInputEditor() {
-    return myExpressionComboBox;
+    return myExpressionEditor;
   }
 }
index eb2e68dd1bafb0d0f982bd464f7a9a1e78d14e50..60cf293d45a4e94d2ab396cb03c03f4c28022d42 100644 (file)
@@ -180,7 +180,7 @@ public class XDebuggerEvaluationDialog extends DialogWrapper {
         XDebugSessionTab tab = ((XDebugSessionImpl)mySession).getSessionTab();
         if (tab != null) {
           tab.getWatchesView().addWatchExpression(expression, -1, true);
-          requestFocusInEditor();
+          getInputEditor().requestFocusInEditor();
         }
       }
     }
@@ -238,14 +238,7 @@ public class XDebuggerEvaluationDialog extends DialogWrapper {
 
     setTitle(myInputComponent.getTitle());
     mySwitchModeAction.putValue(Action.NAME, getSwitchButtonText(mode));
-    requestFocusInEditor();
-  }
-
-  private void requestFocusInEditor() {
-    JComponent preferredFocusedComponent = getInputEditor().getPreferredFocusedComponent();
-    if (preferredFocusedComponent != null) {
-      IdeFocusManager.getInstance(mySession.getProject()).requestFocus(preferredFocusedComponent, true);
-    }
+    getInputEditor().requestFocusInEditor();
   }
 
   private XDebuggerEditorBase getInputEditor() {
index 4d7d65fff3c570e4c2771571ae5265acaa4d33b3..0bed30ba32ce9fbda7ab9fe867b02911bdc17634 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 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,8 @@ import com.intellij.openapi.util.IconLoader;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.reference.SoftReference;
 import com.intellij.ui.ClickListener;
+import com.intellij.util.ui.JBUI;
+import com.intellij.xdebugger.XDebuggerBundle;
 import com.intellij.xdebugger.XExpression;
 import com.intellij.xdebugger.XSourcePosition;
 import com.intellij.xdebugger.evaluation.EvaluationMode;
@@ -43,7 +45,6 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
-import javax.swing.border.EmptyBorder;
 import java.awt.*;
 import java.awt.event.MouseEvent;
 import java.lang.ref.WeakReference;
@@ -76,8 +77,8 @@ public abstract class XDebuggerEditorBase {
     myHistoryId = historyId;
     mySourcePosition = sourcePosition;
 
-    myChooseFactory.setToolTipText("Click to change the language");
-    myChooseFactory.setBorder(new EmptyBorder(0, 3, 0, 3));
+    myChooseFactory.setToolTipText(XDebuggerBundle.message("xdebugger.evaluate.language.hint"));
+    myChooseFactory.setBorder(JBUI.Borders.empty(0, 3, 0, 3));
     new ClickListener() {
       @Override
       public boolean onClick(@NotNull MouseEvent e, int clickCount) {
@@ -104,7 +105,7 @@ public abstract class XDebuggerEditorBase {
         public void actionPerformed(@NotNull AnActionEvent e) {
           XExpression currentExpression = getExpression();
           setExpression(new XExpressionImpl(currentExpression.getExpression(), language, currentExpression.getCustomInfo()));
-          IdeFocusManager.getInstance(getProject()).requestFocus(getComponent(), true);
+          requestFocusInEditor();
         }
       });
     }
@@ -190,12 +191,19 @@ public abstract class XDebuggerEditorBase {
   @Nullable
   public abstract JComponent getPreferredFocusedComponent();
 
+  public void requestFocusInEditor() {
+    JComponent preferredFocusedComponent = getPreferredFocusedComponent();
+    if (preferredFocusedComponent != null) {
+      IdeFocusManager.getInstance(myProject).requestFocus(preferredFocusedComponent, true);
+    }
+  }
+
   public abstract void selectAll();
 
   protected void onHistoryChanged() {
   }
 
-  protected List<XExpression> getRecentExpressions() {
+  public List<XExpression> getRecentExpressions() {
     if (myHistoryId != null) {
       return XDebuggerHistoryManager.getInstance(myProject).getRecentExpressions(myHistoryId);
     }
similarity index 79%
rename from platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerMultilineEditor.java
rename to platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java
index be06fa33b14a9fef36233a9ea481f6777e1788eb..4424d21c538a729fed0a53639c236c2ec2abdb70 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.LangDataKeys;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.ex.EditorEx;
+import com.intellij.openapi.editor.ex.util.EditorUtil;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiDocumentManager;
@@ -38,22 +39,27 @@ import javax.swing.*;
 /**
  * @author nik
  */
-public class XDebuggerMultilineEditor extends XDebuggerEditorBase {
+public class XDebuggerExpressionEditor extends XDebuggerEditorBase {
   private final JComponent myComponent;
   private final EditorTextField myEditorTextField;
   private XExpression myExpression;
 
-  public XDebuggerMultilineEditor(Project project,
+  public XDebuggerExpressionEditor(Project project,
                                    XDebuggerEditorsProvider debuggerEditorsProvider,
                                    @Nullable @NonNls String historyId,
-                                   @Nullable XSourcePosition sourcePosition, @NotNull XExpression text) {
-    super(project, debuggerEditorsProvider, EvaluationMode.CODE_FRAGMENT, historyId, sourcePosition);
+                                   @Nullable XSourcePosition sourcePosition,
+                                   @NotNull XExpression text,
+                                   final boolean multiline) {
+    super(project, debuggerEditorsProvider, multiline ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION, historyId, sourcePosition);
     myExpression = XExpressionImpl.changeMode(text, getMode());
     myEditorTextField = new EditorTextField(createDocument(myExpression), project, debuggerEditorsProvider.getFileType()) {
       @Override
       protected EditorEx createEditor() {
         final EditorEx editor = super.createEditor();
-        editor.setVerticalScrollbarVisible(true);
+        editor.setOneLineMode(!multiline);
+        editor.setVerticalScrollbarVisible(multiline);
+        editor.getColorsScheme().setEditorFontName(getFont().getFontName());
+        editor.getColorsScheme().setEditorFontSize(getFont().getSize());
         return editor;
       }
 
@@ -69,11 +75,12 @@ public class XDebuggerMultilineEditor extends XDebuggerEditorBase {
 
       @Override
       protected boolean isOneLineMode() {
-        return false;
+        return !multiline;
       }
     };
     myEditorTextField.setFontInheritedFromLAF(false);
-    myComponent = addChooseFactoryLabel(myEditorTextField, true);
+    myEditorTextField.setFont(EditorUtil.getEditorFont());
+    myComponent = addChooseFactoryLabel(myEditorTextField, multiline);
   }
 
   @Override
@@ -91,7 +98,7 @@ public class XDebuggerMultilineEditor extends XDebuggerEditorBase {
 
   @Override
   public XExpression getExpression() {
-    return getEditorsProvider().createExpression(getProject(), myEditorTextField.getDocument(), myExpression.getLanguage(), EvaluationMode.CODE_FRAGMENT);
+    return getEditorsProvider().createExpression(getProject(), myEditorTextField.getDocument(), myExpression.getLanguage(), getMode());
   }
 
   @Override