Skip to content

Commit

Permalink
feat: #523 allow resizing the error console in the Preview window
Browse files Browse the repository at this point in the history
Signed-off-by: Bastien Jansen <bastien.jansen@gmx.com>
  • Loading branch information
bjansen committed Apr 27, 2022
1 parent 38d5f8b commit 5b70501
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/antlr/intellij/plugin/preview/InputPanel.form
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
</grid>
</children>
</grid>
<component id="57495" class="com.intellij.openapi.ui.Splitter" binding="editorSplitter">
<constraints border-constraint="Center"/>
<properties>
<dividerWidth value="3"/>
<firstComponent value="4d6c1"/>
<orientation value="true"/>
<proportion value="0.8"/>
<secondComponent value="37477"/>
</properties>
</component>
<component id="4d6c1" class="javax.swing.JTextArea" binding="placeHolder">
<constraints border-constraint="East"/>
<properties>
Expand Down
21 changes: 3 additions & 18 deletions src/main/java/org/antlr/intellij/plugin/preview/InputPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentWithBrowseButton;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.ui.TextComponentAccessor;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Key;
Expand Down Expand Up @@ -70,13 +71,7 @@ public class InputPanel {
private JPanel startRuleAndInputPanel;
private TextFieldWithBrowseButton fileChooser;
private JPanel outerMostPanel;

/**
* switchToGrammar() was seeing an empty slot instead of a previous
* editor or placeHolder. Figured it was an order of operations thing
* and synchronized add/remove ops. Works now w/o error.
*/
private final Object swapEditorComponentLock = new Object();
private Splitter editorSplitter;

private final PreviewPanel previewPanel;

Expand Down Expand Up @@ -266,17 +261,7 @@ public void switchToGrammar(PreviewState previewState, VirtualFile grammarFile)
}

public void setEditorComponent(JComponent editor) {
BorderLayout layout = (BorderLayout) outerMostPanel.getLayout();
String EDITOR_SPOT_COMPONENT = BorderLayout.CENTER;
// atomically remove old
synchronized (swapEditorComponentLock) {
Component editorSpotComp = layout.getLayoutComponent(EDITOR_SPOT_COMPONENT);
if ( editorSpotComp!=null ) {
editorSpotComp.setVisible(false);
outerMostPanel.remove(editorSpotComp); // remove old editor if it's there
}
outerMostPanel.add(editor, EDITOR_SPOT_COMPONENT);
}
editorSplitter.setFirstComponent(editor);
}

public Editor getInputEditor() {
Expand Down

0 comments on commit 5b70501

Please sign in to comment.