groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch master updated: GROOVY-9022: Added option under View menu of whether or not to have vertical orientation (unchecking changes it to horizontal; value stored in Preferences) (closes #891)
Date Sun, 24 Mar 2019 10:18:34 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 2af4c63  GROOVY-9022: Added option under View menu of whether or not to have vertical
orientation (unchecking changes it to horizontal; value stored in Preferences) (closes #891)
2af4c63 is described below

commit 2af4c635d3ccf19483da9d4d5992f398686f330f
Author: Adam Davis <ada.m.d.a.v@gmail.com>
AuthorDate: Fri Mar 8 07:52:18 2019 -0500

    GROOVY-9022: Added option under View menu of whether or not to have vertical orientation
(unchecking changes it to horizontal; value stored in Preferences) (closes #891)
---
 .../src/main/groovy/groovy/ui/Console.groovy           | 18 ++++++++++++++++++
 .../src/main/groovy/groovy/ui/ConsoleActions.groovy    |  6 ++++++
 .../main/groovy/groovy/ui/view/BasicContentPane.groovy |  6 ++++--
 .../src/main/groovy/groovy/ui/view/BasicMenuBar.groovy |  1 +
 4 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
index 106c902..d5531ba 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
@@ -121,6 +121,9 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
 
     boolean detachedOutput = prefs.getBoolean('detachedOutput', false)
     Action detachedOutputAction
+
+    boolean orientationVertical = prefs.getBoolean('orientationVertical', true)
+    Action orientationVerticalAction
     Action showOutputWindowAction
     Action hideOutputWindowAction1
     Action hideOutputWindowAction2
@@ -675,6 +678,21 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
         toolbar.visible = showToolbar
     }
 
+    void orientationVertical(EventObject evt) {
+        def oldValue = orientationVertical
+        orientationVertical = evt.source.selected
+        prefs.putBoolean('orientationVertical', orientationVertical)
+        if (oldValue != orientationVertical) {
+            if (orientationVertical) {
+                splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT)
+            } else {
+                splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT)
+            }
+            splitPane.resizeWeight = detachedOutput ? 1.0 : 0.5
+            splitPane.resetToPreferredSizes()
+        }
+    }
+
     void detachedOutput(EventObject evt) {
         def oldDetachedOutput = detachedOutput
         detachedOutput = evt.source.selected
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/ConsoleActions.groovy b/subprojects/groovy-console/src/main/groovy/groovy/ui/ConsoleActions.groovy
index e1a5671..50b536e 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/ConsoleActions.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/ConsoleActions.groovy
@@ -305,6 +305,12 @@ detachedOutputAction = action(
     mnemonic: 'D'
 )
 
+orientationVerticalAction = action(
+    name: 'Vertical Orientation',
+    closure: controller.&orientationVertical,
+    mnemonic: 'n'
+)
+
 showOutputWindowAction = action(
     closure: controller.&showOutputWindow,
     keyStroke: shortcut('shift O'),
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicContentPane.groovy
b/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicContentPane.groovy
index dc4245a..57cd37f 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicContentPane.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicContentPane.groovy
@@ -38,15 +38,17 @@ import java.awt.GraphicsEnvironment
 import java.awt.image.BufferedImage
 import java.util.prefs.Preferences
 
+import static javax.swing.JSplitPane.HORIZONTAL_SPLIT
 import static javax.swing.JSplitPane.VERTICAL_SPLIT
 
-def prefs = Preferences.userNodeForPackage(Console)
+Preferences prefs = Preferences.userNodeForPackage(Console)
 def detachedOutputFlag = prefs.getBoolean('detachedOutput', false)
 outputWindow = frame(visible:false, defaultCloseOperation: WindowConstants.HIDE_ON_CLOSE)
{
     blank = glue()
     blank.preferredSize = [0, 0] as Dimension
 }
-splitPane = splitPane(resizeWeight: 0.5, orientation: VERTICAL_SPLIT) {
+splitPane = splitPane(resizeWeight: 0.5, orientation:
+        prefs.getBoolean('orientationVertical', true) ? VERTICAL_SPLIT : HORIZONTAL_SPLIT)
{
     def editor = new ConsoleTextEditor()
     boolean smartHighlighterEnabled = Console.smartHighlighter
     if (smartHighlighterEnabled) {
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicMenuBar.groovy
b/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicMenuBar.groovy
index 8ff0752..737c4a1 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicMenuBar.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicMenuBar.groovy
@@ -68,6 +68,7 @@ menuBar {
         checkBoxMenuItem(showToolbarAction, selected: controller.showToolbar)
         checkBoxMenuItem(detachedOutputAction, selected: controller.detachedOutput)
         checkBoxMenuItem(autoClearOutputAction, selected: controller.autoClearOutput)
+        checkBoxMenuItem(orientationVerticalAction, selected: controller.orientationVertical)
     }
 
     menu(text: 'History', mnemonic: 'I') {


Mime
View raw message