Skip to content

Commit 8209505

Browse files
committed
feat: #523 allow resizing the error console in the Preview window
1 parent 34a5c1a commit 8209505

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/main/java/org/antlr/intellij/plugin/preview/InputPanel.form

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
</grid>
5050
</children>
5151
</grid>
52+
<component id="57495" class="com.intellij.openapi.ui.Splitter" binding="editorSplitter">
53+
<constraints border-constraint="Center"/>
54+
<properties>
55+
<dividerWidth value="3"/>
56+
<firstComponent value="4d6c1"/>
57+
<orientation value="true"/>
58+
<proportion value="0.8"/>
59+
<secondComponent value="37477"/>
60+
</properties>
61+
</component>
5262
<component id="4d6c1" class="javax.swing.JTextArea" binding="placeHolder">
5363
<constraints border-constraint="East"/>
5464
<properties>

src/main/java/org/antlr/intellij/plugin/preview/InputPanel.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.intellij.openapi.fileEditor.FileDocumentManager;
1818
import com.intellij.openapi.project.Project;
1919
import com.intellij.openapi.ui.ComponentWithBrowseButton;
20+
import com.intellij.openapi.ui.Splitter;
2021
import com.intellij.openapi.ui.TextComponentAccessor;
2122
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
2223
import com.intellij.openapi.util.Key;
@@ -70,13 +71,7 @@ public class InputPanel {
7071
private JPanel startRuleAndInputPanel;
7172
private TextFieldWithBrowseButton fileChooser;
7273
private JPanel outerMostPanel;
73-
74-
/**
75-
* switchToGrammar() was seeing an empty slot instead of a previous
76-
* editor or placeHolder. Figured it was an order of operations thing
77-
* and synchronized add/remove ops. Works now w/o error.
78-
*/
79-
private final Object swapEditorComponentLock = new Object();
74+
private Splitter editorSplitter;
8075

8176
private final PreviewPanel previewPanel;
8277

@@ -266,17 +261,7 @@ public void switchToGrammar(PreviewState previewState, VirtualFile grammarFile)
266261
}
267262

268263
public void setEditorComponent(JComponent editor) {
269-
BorderLayout layout = (BorderLayout) outerMostPanel.getLayout();
270-
String EDITOR_SPOT_COMPONENT = BorderLayout.CENTER;
271-
// atomically remove old
272-
synchronized (swapEditorComponentLock) {
273-
Component editorSpotComp = layout.getLayoutComponent(EDITOR_SPOT_COMPONENT);
274-
if ( editorSpotComp!=null ) {
275-
editorSpotComp.setVisible(false);
276-
outerMostPanel.remove(editorSpotComp); // remove old editor if it's there
277-
}
278-
outerMostPanel.add(editor, EDITOR_SPOT_COMPONENT);
279-
}
264+
editorSplitter.setFirstComponent(editor);
280265
}
281266

282267
public Editor getInputEditor() {

0 commit comments

Comments
 (0)