mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-139797 Default Theme doesn't allow to apply font size to evaluate expression console's input
This commit is contained in:
@@ -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
|
||||
|
||||
+6
-5
@@ -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);
|
||||
|
||||
+73
-12
@@ -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.
|
||||
@@ -15,46 +15,107 @@
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-9
@@ -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() {
|
||||
|
||||
+14
-6
@@ -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);
|
||||
}
|
||||
|
||||
+15
-8
@@ -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
|
||||
Reference in New Issue
Block a user