Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify distribution of space between split panes within EditorView. #20

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</component>
</children>
</grid>
<splitpane id="d5f0c">
<splitpane id="d5f0c" binding="upperSplitPane">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
Expand Down Expand Up @@ -136,7 +136,7 @@
<size top="5" left="0" bottom="0" right="0"/>
</border>
<children>
<splitpane id="8027f">
<splitpane id="8027f" binding="lowerSplitPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/blackberry/jwteditor/view/editor/EditorView.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.util.List;

import static java.awt.Color.RED;
import static java.awt.EventQueue.invokeLater;
import static java.awt.event.HierarchyEvent.SHOWING_CHANGED;
import static org.exbin.deltahex.EditationAllowed.ALLOWED;
import static org.exbin.deltahex.EditationAllowed.READ_ONLY;

Expand Down Expand Up @@ -86,6 +90,8 @@ public abstract class EditorView implements ExtensionProvidedEditor {
private JCheckBox checkBoxJWEHeaderCompactJSON;
private JButton buttonJWSPayloadFormatJSON;
private JCheckBox checkBoxJWSPayloadCompactJSON;
private JSplitPane upperSplitPane;
private JSplitPane lowerSplitPane;

private CodeArea codeAreaSignature;
private CodeArea codeAreaEncryptedKey;
Expand All @@ -107,6 +113,8 @@ public abstract class EditorView implements ExtensionProvidedEditor {
this.isProVersion = isProVersion;
this.presenter = new EditorPresenter(this, collaboratorPayloadGenerator, actionListenerFactory, presenters);

panel.addHierarchyListener(new ResizeSplitPanesOnFirstRenderHierarchyListener());

// Event handler for Header / JWS payload change events
DocumentListener documentListener = new DocumentListener() {
@Override
Expand Down Expand Up @@ -537,4 +545,20 @@ private void createUIComponents() {
textAreaJWSHeader = rstaFactory.buildDefaultTextArea();
textAreaPayload = rstaFactory.buildDefaultTextArea();
}

private class ResizeSplitPanesOnFirstRenderHierarchyListener implements HierarchyListener {
@Override
public void hierarchyChanged(HierarchyEvent e) {
if (e.getChangeFlags() != SHOWING_CHANGED || !e.getComponent().isShowing()) {
return;
}

invokeLater(() -> {
upperSplitPane.setDividerLocation(0.25);
lowerSplitPane.setDividerLocation(0.75);
});

panel.removeHierarchyListener(this);
}
}
}