8000 TextEditor: Reinstate setOneTouchExpandable · scijava/script-editor@0cf932c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cf932c

Browse files
committed
TextEditor: Reinstate setOneTouchExpandable
Reported by @acardona, #56 (comment)
1 parent 41c8c3e commit 0cf932c

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/main/java/org/scijava/ui/swing/script/TextEditor.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,22 @@ public TextEditor(final Context context) {
518518
final JCheckBoxMenuItem jcmi2 = new JCheckBoxMenuItem("Console", true);
519519
jcmi2.addItemListener(e -> collapseSplitPane(1, !jcmi2.isSelected()));
520520
tabsMenu.add(jcmi2);
521+
final JMenuItem mi = new JMenuItem("Reset Layout...");
522+
mi.addActionListener(e -> {
523+
final int choice = JOptionPane.showConfirmDialog(TextEditor.this,//
524+
"Reset Location of Console and File Explorer?",
525+
"Reset Layout?", JOptionPane.OK_CANCEL_OPTION);
526+
if (JOptionPane.OK_OPTION == choice) {
527+
body.setDividerLocation(.2d);
528+
getTab().setDividerLocation(.75d);
529+
if (incremental)
530+
getTab().setREPLVisible(incremental);
531+
getTab().getScreenAndPromptSplit().setDividerLocation(.5d);
532+
jcmi1.setSelected(true);
533+
jcmi2.setSelected(true);
534+
}
535+
});
536+
tabsMenu.add(mi);
521537
addSeparator(tabsMenu, "Tabs:");
522538
nextTab = addToMenu(tabsMenu, "Next Tab", KeyEvent.VK_PAGE_DOWN, ctrl);
523539
nextTab.setMnemonic(KeyEvent.VK_N);
@@ -636,10 +652,7 @@ public TextEditor(final Context context) {
636652
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
637653

638654
// Tweaks for JSplitPane
639-
// TF: disable setOneTouchExpandable() due to inconsistent behavior when
640-
// applying preferences at startup. Also, it does not apply to all L&Fs.
641-
// Users can use the controls in the menu bar to toggle the pane
642-
body.setOneTouchExpandable(false);
655+
body.setOneTouchExpandable(true);
643656
body.addPropertyChangeListener(evt -> {
644657
if ("dividerLocation".equals(evt.getPropertyName())) saveWindowSizeToPrefs();
645658
});

src/main/java/org/scijava/ui/swing/script/TextEditorTab.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ public class TextEditorTab extends JSplitPane {
8888
public TextEditorTab(final TextEditor textEditor) {
8989
super(JSplitPane.VERTICAL_SPLIT);
9090
super.setResizeWeight(350.0 / 430.0);
91-
// TF: disable setOneTouchExpandable() due to inconsistent behavior when
92-
// applying preferences at startup. Also, it does not apply to all L&Fs.
93-
// Users can use the controls in the menu bar to toggle the pane
94-
this.setOneTouchExpandable(false);
91+
setOneTouchExpandable(true);
9592

9693
this.textEditor = textEditor;
9794
editorPane = new EditorPane();

0 commit comments

Comments
 (0)
0