mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-155080 - rework in evaluate dialog
This commit is contained in:
@@ -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:
|
||||
|
||||
+9
-57
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="31ade" class="javax.swing.JLabel">
|
||||
<component id="31ade" class="javax.swing.JLabel" binding="myNameLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
@@ -26,7 +26,7 @@
|
||||
</component>
|
||||
<grid id="7eff2" binding="myLanguageChooserPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
|
||||
+5
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
|
||||
+16
-25
@@ -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());
|
||||
|
||||
+26
-2
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user