diff --git a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties
index 6cceb2219484..aaff87a5bb46 100644
--- a/platform/platform-resources-en/src/messages/XDebuggerBundle.properties
+++ b/platform/platform-resources-en/src/messages/XDebuggerBundle.properties
@@ -68,6 +68,7 @@ xdebugger.evaluate.history.hint=Show history
xdebugger.evaluate.history.navigate.ad=Press {0} or {1} to navigate through the history
xdebugger.evaluate.label.result=&Result:
xdebugger.button.evaluate=E&valuate
+xdebugger.evaluate.dialog.title=Evaluate
xdebugger.evaluate.dialog.close=Close
xdebugger.dialog.title.evaluate.expression=Evaluate Expression
xdebugger.evaluate.label.expression=Expression:
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java
index 7f8f162b3bde..7fccdc618122 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/CodeFragmentInputComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2016 JetBrains s.r.o.
+ * Copyright 2000-2017 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.evaluate;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.Project;
import com.intellij.ui.JBSplitter;
import com.intellij.xdebugger.XDebuggerBundle;
@@ -37,7 +36,7 @@ import java.awt.*;
*/
public class CodeFragmentInputComponent extends EvaluationInputComponent {
private final XDebuggerExpressionEditor myMultilineEditor;
- private final JPanel myMainPanel;
+ private final ExpressionInputForm myMainForm = new ExpressionInputForm();
private final String mySplitterProportionKey;
public CodeFragmentInputComponent(final @NotNull Project project,
@@ -49,16 +48,11 @@ public class CodeFragmentInputComponent extends EvaluationInputComponent {
super(XDebuggerBundle.message("dialog.title.evaluate.code.fragment"));
myMultilineEditor = new XDebuggerExpressionEditor(project, editorsProvider, "evaluateCodeFragment", sourcePosition,
statements != null ? statements : XExpressionImpl.EMPTY_CODE_FRAGMENT, true, true, false);
- myMainPanel = new JPanel(new BorderLayout());
- JPanel editorPanel = new JPanel(new BorderLayout());
- editorPanel.add(myMultilineEditor.getComponent(), BorderLayout.CENTER);
- DefaultActionGroup group = new DefaultActionGroup();
- group.add(new HistoryNavigationAction(false, IdeActions.ACTION_PREVIOUS_OCCURENCE, parentDisposable));
- group.add(new HistoryNavigationAction(true, IdeActions.ACTION_NEXT_OCCURENCE, parentDisposable));
- group.add(new ToggleSoftWrapAction());
- editorPanel.add(ActionManager.getInstance().createActionToolbar("DebuggerCodeFragment", group, false).getComponent(), BorderLayout.EAST);
- //myMainPanel.add(new JLabel(XDebuggerBundle.message("xdebugger.label.text.code.fragment")), BorderLayout.NORTH);
- myMainPanel.add(editorPanel, BorderLayout.CENTER);
+
+ myMainForm.setName(XDebuggerBundle.message("xdebugger.label.text.code.fragment"));
+ myMainForm.addExpressionComponent(myMultilineEditor.getComponent());
+ myMainForm.addLanguageComponent(myMultilineEditor.getLanguageChooser());
+
if (statements != null) {
myMultilineEditor.setExpression(statements);
}
@@ -72,7 +66,7 @@ public class CodeFragmentInputComponent extends EvaluationInputComponent {
}
public JPanel getMainComponent() {
- return myMainPanel;
+ return myMainForm.getMainPanel();
}
@Override
@@ -80,49 +74,7 @@ public class CodeFragmentInputComponent extends EvaluationInputComponent {
final JBSplitter splitter = new JBSplitter(true, 0.3f, 0.2f, 0.7f);
splitter.setSplitterProportionKey(mySplitterProportionKey);
contentPanel.add(splitter, BorderLayout.CENTER);
- splitter.setFirstComponent(myMainPanel);
+ splitter.setFirstComponent(myMainForm.getMainPanel());
splitter.setSecondComponent(resultPanel);
}
-
- private class ToggleSoftWrapAction extends ToggleAction {
- public ToggleSoftWrapAction() {
- copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_USE_SOFT_WRAPS));
- }
-
- @Override
- public boolean isSelected(AnActionEvent e) {
- return myMultilineEditor.isUseSoftWraps();
- }
-
- @Override
- public void setSelected(AnActionEvent e, boolean state) {
- myMultilineEditor.setUseSoftWraps(state);
- }
- }
-
- private class HistoryNavigationAction extends AnAction {
- private final boolean myForward;
-
- public HistoryNavigationAction(boolean forward, String actionId, Disposable parentDisposable) {
- myForward = forward;
- final AnAction action = ActionManager.getInstance().getAction(actionId);
- copyFrom(action);
- registerCustomShortcutSet(action.getShortcutSet(), myMainPanel, parentDisposable);
- }
-
- @Override
- public void update(AnActionEvent e) {
- e.getPresentation().setEnabled(myForward ? myMultilineEditor.canGoForward() : myMultilineEditor.canGoBackward());
- }
-
- @Override
- public void actionPerformed(AnActionEvent e) {
- if (myForward) {
- myMultilineEditor.goForward();
- }
- else {
- myMultilineEditor.goBackward();
- }
- }
- }
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.form b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.form
index cc0f04292ca9..8ebdd8acc9fc 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.form
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.form
@@ -16,7 +16,7 @@
-
+
@@ -26,7 +26,7 @@
-
+
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.java
index b3f370191ccb..c6c5734facbf 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/ExpressionInputForm.java
@@ -24,6 +24,7 @@ public class ExpressionInputForm {
private JPanel myLanguageChooserPanel;
private JPanel myExpressionPanel;
private JPanel myMainPanel;
+ private JLabel myNameLabel;
public void addLanguageComponent(JComponent component) {
myLanguageChooserPanel.add(component);
@@ -33,6 +34,10 @@ public class ExpressionInputForm {
myExpressionPanel.add(component);
}
+ public void setName(String name) {
+ myNameLabel.setText(name);
+ }
+
public JPanel getMainPanel() {
return myMainPanel;
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java
index 91a37b315909..c01ed38a066b 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java
@@ -171,6 +171,7 @@ public class XDebuggerEvaluationDialog extends DialogWrapper {
if (mode == EvaluationMode.EXPRESSION && text.getMode() == EvaluationMode.CODE_FRAGMENT && myIsCodeFragmentEvaluationSupported) {
mode = EvaluationMode.CODE_FRAGMENT;
}
+ setTitle(XDebuggerBundle.message("xdebugger.evaluate.dialog.title"));
switchToMode(mode, text);
init();
}
@@ -271,7 +272,6 @@ public class XDebuggerEvaluationDialog extends DialogWrapper {
myMainPanel.removeAll();
myInputComponent.addComponent(myMainPanel, myResultPanel);
- setTitle(myInputComponent.getTitle());
mySwitchModeAction.putValue(Action.NAME, getSwitchButtonText(mode));
getInputEditor().requestFocusInEditor();
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java
index f1d844817b66..2f3fc4a310c2 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java
@@ -30,7 +30,6 @@ import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.FoldingModelEx;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.keymap.KeymapUtil;
-import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
@@ -42,6 +41,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.reference.SoftReference;
import com.intellij.ui.*;
import com.intellij.ui.awt.RelativePoint;
+import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBScrollBar;
import com.intellij.util.IconUtil;
import com.intellij.util.ui.JBUI;
@@ -187,6 +187,13 @@ public abstract class XDebuggerEditorBase implements Expandable {
panel.addToCenter(component);
+ if (multiline) {
+ JBLabel adLabel = new JBLabel(getAdText(), SwingConstants.RIGHT);
+ adLabel.setComponentStyle(UIUtil.ComponentStyle.SMALL);
+ adLabel.setFontColor(UIUtil.FontColor.BRIGHTER);
+ panel.addToBottom(adLabel);
+ }
+
return panel;
}
@@ -416,9 +423,7 @@ public abstract class XDebuggerEditorBase implements Expandable {
.setRequestFocus(true)
.setLocateByContent(true)
.setCancelOnWindowDeactivation(false)
- .setAdText(XDebuggerBundle.message("xdebugger.evaluate.history.navigate.ad",
- DebuggerUIUtil.getActionShortcutText(IdeActions.ACTION_NEXT_OCCURENCE),
- DebuggerUIUtil.getActionShortcutText(IdeActions.ACTION_PREVIOUS_OCCURENCE)))
+ .setAdText(getAdText())
.setKeyboardActions(Collections.singletonList(Pair.create(event -> {
collapse();
Window window = UIUtil.getWindow(getComponent());
@@ -442,32 +447,11 @@ public abstract class XDebuggerEditorBase implements Expandable {
return true;
}).createPopup();
- ShortcutSet shortcut = ActionManager.getInstance().getAction(IdeActions.ACTION_NEXT_OCCURENCE).getShortcutSet();
- if (shortcut != null) {
- new DumbAwareAction() {
- @Override
- public void actionPerformed(@NotNull AnActionEvent e) {
- expressionEditor.goForward();
- }
- }.registerCustomShortcutSet(shortcut, component, myExpandedPopup);
- }
-
- shortcut = ActionManager.getInstance().getAction(IdeActions.ACTION_PREVIOUS_OCCURENCE).getShortcutSet();
- if (shortcut != null) {
- new DumbAwareAction() {
- @Override
- public void actionPerformed(@NotNull AnActionEvent e) {
- expressionEditor.goBackward();
- }
- }.registerCustomShortcutSet(shortcut, component, myExpandedPopup);
- }
-
myExpandedPopup.show(new RelativePoint(getComponent(), new Point(0, 0)));
EditorEx editor = (EditorEx)expressionEditor.getEditor();
copyCaretPosition(getEditor(), editor);
editor.getSettings().setUseSoftWraps(isUseSoftWraps());
- editor.setContextMenuGroupId("XDebugger.Evaluate.Code.Fragment.Editor.Popup");
ErrorStripeEditorCustomization.DISABLED.customize(editor);
// TODO: copied from ExpandableTextField
@@ -498,6 +482,13 @@ public abstract class XDebuggerEditorBase implements Expandable {
expressionEditor.requestFocusInEditor();
}
+ @NotNull
+ private static String getAdText() {
+ return XDebuggerBundle.message("xdebugger.evaluate.history.navigate.ad",
+ DebuggerUIUtil.getActionShortcutText(IdeActions.ACTION_NEXT_OCCURENCE),
+ DebuggerUIUtil.getActionShortcutText(IdeActions.ACTION_PREVIOUS_OCCURENCE));
+ }
+
private static void copyCaretPosition(@Nullable Editor source, @Nullable Editor destination) {
if (source != null && destination != null) {
destination.getCaretModel().moveToOffset(source.getCaretModel().getOffset());
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java
index 2816729b4d01..fb60e8458451 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerExpressionEditor.java
@@ -16,11 +16,11 @@
package com.intellij.xdebugger.impl.ui;
import com.intellij.lang.Language;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.*;
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.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.ui.EditorTextField;
@@ -68,6 +68,7 @@ public class XDebuggerExpressionEditor extends XDebuggerEditorBase {
editor.getColorsScheme().setEditorFontSize(getFont().getSize());
if (multiline) {
editor.getContentComponent().setBorder(new CompoundBorder(editor.getContentComponent().getBorder(), JBUI.Borders.emptyLeft(2)));
+ editor.setContextMenuGroupId("XDebugger.Evaluate.Code.Fragment.Editor.Popup");
}
else {
foldNewLines(editor);
@@ -92,6 +93,29 @@ public class XDebuggerExpressionEditor extends XDebuggerEditorBase {
myEditorTextField.setFontInheritedFromLAF(false);
myEditorTextField.setFont(EditorUtil.getEditorFont());
}
+
+ if (multiline) {
+ ShortcutSet shortcut = ActionManager.getInstance().getAction(IdeActions.ACTION_NEXT_OCCURENCE).getShortcutSet();
+ if (shortcut != null) {
+ new DumbAwareAction() {
+ @Override
+ public void actionPerformed(@NotNull AnActionEvent e) {
+ goForward();
+ }
+ }.registerCustomShortcutSet(shortcut, myEditorTextField);
+ }
+
+ shortcut = ActionManager.getInstance().getAction(IdeActions.ACTION_PREVIOUS_OCCURENCE).getShortcutSet();
+ if (shortcut != null) {
+ new DumbAwareAction() {
+ @Override
+ public void actionPerformed(@NotNull AnActionEvent e) {
+ goBackward();
+ }
+ }.registerCustomShortcutSet(shortcut, myEditorTextField);
+ }
+ }
+
myComponent = decorate(myEditorTextField, multiline, showEditor);
setExpression(myExpression);
}