You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2019/03/24 10:26:37 UTC
[groovy] 02/02: 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)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 6b00c6cfb814dd07da086c7a7fc0dceaf6e23534
Author: Adam Davis <ad...@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 | 8 ++++----
.../src/main/groovy/groovy/ui/view/BasicMenuBar.groovy | 1 +
4 files changed, 29 insertions(+), 4 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 02172cf..3d0e976 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
@@ -100,6 +100,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
@@ -654,6 +657,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 627d52b..3aaa929 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 ce5026e..b60dbf6 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
@@ -19,7 +19,6 @@
package groovy.ui.view
import groovy.ui.Console
-import groovy.ui.ConsoleTextEditor
import javax.swing.*
import javax.swing.text.Style
@@ -30,16 +29,17 @@ import java.awt.*
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) {
- inputEditor = widget(new ConsoleTextEditor(), border:emptyBorder(0))
+splitPane = splitPane(resizeWeight: 0.5, orientation:
+ prefs.getBoolean('orientationVertical', true) ? VERTICAL_SPLIT : HORIZONTAL_SPLIT) {
buildOutputArea(prefs)
}
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 9246ea1..81316ed 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
@@ -67,6 +67,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') {