IDEA-155080 - new layout in evaluate dialog

This commit is contained in:
Egor.Ushakov
2017-09-06 15:35:28 +03:00
parent db43ebfcc2
commit 04ed7d645d
3 changed files with 99 additions and 8 deletions
@@ -32,6 +32,7 @@ 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.util.ui.components.BorderLayoutPanel;
import com.intellij.xdebugger.XDebuggerBundle;
import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.XSourcePosition;
@@ -53,7 +54,7 @@ import java.util.List;
*/
public class ExpressionInputComponent extends EvaluationInputComponent {
private final XDebuggerExpressionEditor myExpressionEditor;
private final JPanel myMainPanel = JBUI.Panels.simplePanel();
private final ExpressionInputForm myMainForm = new ExpressionInputForm();
public ExpressionInputComponent(final @NotNull Project project,
@NotNull XDebuggerEditorsProvider editorsProvider,
@@ -63,10 +64,16 @@ public class ExpressionInputComponent extends EvaluationInputComponent {
@NotNull Disposable parentDisposable,
boolean showHelp) {
super(XDebuggerBundle.message("xdebugger.dialog.title.evaluate.expression"));
BorderLayoutPanel expressionPanel = JBUI.Panels.simplePanel();
//myMainPanel.add(new JLabel(XDebuggerBundle.message("xdebugger.evaluate.label.expression")), BorderLayout.WEST);
myExpressionEditor = new XDebuggerExpressionEditor(project, editorsProvider, historyId, sourcePosition,
expression != null ? expression : XExpressionImpl.EMPTY_EXPRESSION, false, true, false);
myMainPanel.add(myExpressionEditor.getComponent(), BorderLayout.CENTER);
expression != null ? expression : XExpressionImpl.EMPTY_EXPRESSION, false, true, false) {
@Override
protected JComponent decorate(JComponent component, boolean multiline, boolean showEditor) {
return component;
}
};
expressionPanel.add(myExpressionEditor.getComponent(), BorderLayout.CENTER);
JButton historyButton = new FixedSizeButton(myExpressionEditor.getComponent());
historyButton.setIcon(AllIcons.General.MessageHistory);
historyButton.setToolTipText(XDebuggerBundle.message("xdebugger.evaluate.history.hint"));
@@ -76,14 +83,14 @@ public class ExpressionInputComponent extends EvaluationInputComponent {
showHistory();
}
});
myMainPanel.add(historyButton, BorderLayout.EAST);
expressionPanel.add(historyButton, BorderLayout.EAST);
final JBLabel help = new JBLabel(XDebuggerBundle.message("xdebugger.evaluate.addtowatches.hint",
KeymapUtil.getKeystrokeText(XDebuggerEvaluationDialog.ADD_WATCH_KEYSTROKE)),
SwingConstants.RIGHT);
help.setBorder(JBUI.Borders.empty(2, 0, 6, 0));
help.setComponentStyle(UIUtil.ComponentStyle.SMALL);
help.setFontColor(UIUtil.FontColor.BRIGHTER);
myMainPanel.add(help, BorderLayout.SOUTH);
expressionPanel.add(help, BorderLayout.SOUTH);
help.setVisible(showHelp);
if (expression != null) {
@@ -91,6 +98,9 @@ public class ExpressionInputComponent extends EvaluationInputComponent {
}
myExpressionEditor.selectAll();
myMainForm.addExpressionComponent(expressionPanel);
myMainForm.addLanguageComponent(myExpressionEditor.getLanguageChooser());
new AnAction("XEvaluateDialog.ShowHistory") {
@Override
public void actionPerformed(AnActionEvent e) {
@@ -101,7 +111,7 @@ public class ExpressionInputComponent extends EvaluationInputComponent {
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(LookupManager.getActiveLookup(myExpressionEditor.getEditor()) == null);
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("DOWN"), myMainPanel, parentDisposable);
}.registerCustomShortcutSet(CustomShortcutSet.fromString("DOWN"), myMainForm.getMainPanel(), parentDisposable);
}
private void showHistory() {
@@ -133,11 +143,11 @@ public class ExpressionInputComponent extends EvaluationInputComponent {
@Override
public void addComponent(JPanel contentPanel, JPanel resultPanel) {
contentPanel.add(resultPanel, BorderLayout.CENTER);
contentPanel.add(myMainPanel, BorderLayout.NORTH);
contentPanel.add(myMainForm.getMainPanel(), BorderLayout.NORTH);
}
public JPanel getMainComponent() {
return myMainPanel;
return myMainForm.getMainPanel();
}
@NotNull
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.xdebugger.impl.evaluate.ExpressionInputForm">
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="6aab2" binding="myExpressionPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<component id="31ade" class="javax.swing.JLabel">
<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>
<properties>
<text resource-bundle="messages/XDebuggerBundle" key="xdebugger.evaluate.label.expression"/>
</properties>
</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"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<hspacer id="f9382">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</form>
@@ -0,0 +1,39 @@
/*
* 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.
* 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.xdebugger.impl.evaluate;
import javax.swing.*;
/**
* @author egor
*/
public class ExpressionInputForm {
private JPanel myLanguageChooserPanel;
private JPanel myExpressionPanel;
private JPanel myMainPanel;
public void addLanguageComponent(JComponent component) {
myLanguageChooserPanel.add(component);
}
public void addExpressionComponent(JComponent component) {
myExpressionPanel.add(component);
}
public JPanel getMainPanel() {
return myMainPanel;
}
}