groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: GROOVY-8622 Groovy Console should list its classpath(closes #737)
Date Fri, 01 Jun 2018 02:22:26 GMT
Repository: groovy
Updated Branches:
  refs/heads/master b18f236c4 -> 0e6221576


GROOVY-8622 Groovy Console should list its classpath(closes #737)

This feature added at Hackergarten Gr8conf 2018
Authors: Christian Streibl, Andres Almiray


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0e622157
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0e622157
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0e622157

Branch: refs/heads/master
Commit: 0e62215764126ce86cef4e19e46d85db12c5d2b0
Parents: b18f236
Author: aalmiray <aalmiray@gmail.com>
Authored: Thu May 31 21:00:22 2018 +0200
Committer: sunlan <sunlan@apache.org>
Committed: Fri Jun 1 10:21:54 2018 +0800

----------------------------------------------------------------------
 .../src/main/groovy/groovy/ui/Console.groovy    | 29 ++++++++++++++++++++
 .../main/groovy/groovy/ui/ConsoleActions.groovy |  5 ++++
 .../groovy/groovy/ui/view/BasicMenuBar.groovy   |  1 +
 .../groovy/groovy/ui/view/MacOSXMenuBar.groovy  |  1 +
 4 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/0e622157/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
----------------------------------------------------------------------
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 a7ff356..a558de6 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
@@ -1068,6 +1068,35 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
         }
     }
 
+    void listClasspath(EventObject evt = null) {
+        List<URL> urls = []
+
+        ClassLoader cl = shell.classLoader
+        while(cl instanceof URLClassLoader) {
+            cl.getURLs().each { url -> urls << url }
+            cl = cl.parent
+        }
+
+        List data = urls.unique().collect { url -> [name: new File(url.toURI()).name,
path: url.path] }
+        data.sort { it.name }
+
+        JScrollPane scrollPane = swing.scrollPane{
+            table {
+                tableModel(list : data) {
+                    propertyColumn(header: 'Name', propertyName: 'name')
+                    propertyColumn(header:' Path', propertyName: 'path')
+                }
+            }
+        }
+
+        def pane = swing.optionPane()
+        pane.message = scrollPane
+        def dialog = pane.createDialog(frame, 'Classpath')
+        dialog.setSize(800, 600)
+        dialog.resizable = true
+        dialog.visible = true
+    }
+
     void clearContext(EventObject evt = null) {
         def binding = new Binding()
         newScript(null, binding)

http://git-wip-us.apache.org/repos/asf/groovy/blob/0e622157/subprojects/groovy-console/src/main/groovy/groovy/ui/ConsoleActions.groovy
----------------------------------------------------------------------
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 e52363d..627d52b 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/ConsoleActions.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/ConsoleActions.groovy
@@ -224,6 +224,11 @@ addClasspathDir = action(
     mnemonic: 'D',
 )
 
+listClasspath = action(
+    name: 'List Classpath',
+    closure: controller.&listClasspath
+)
+
 clearClassloader = action(
     name: 'Clear Script Context',
     closure: controller.&clearContext,

http://git-wip-us.apache.org/repos/asf/groovy/blob/0e622157/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicMenuBar.groovy
----------------------------------------------------------------------
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 6214c04..9246ea1 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
@@ -85,6 +85,7 @@ menuBar {
         separator()
         menuItem(addClasspathJar)
         menuItem(addClasspathDir)
+        menuItem(listClasspath)
         menuItem(clearClassloader)
         separator()
         menuItem(inspectLastAction)

http://git-wip-us.apache.org/repos/asf/groovy/blob/0e622157/subprojects/groovy-console/src/main/groovy/groovy/ui/view/MacOSXMenuBar.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/view/MacOSXMenuBar.groovy
b/subprojects/groovy-console/src/main/groovy/groovy/ui/view/MacOSXMenuBar.groovy
index 78e9686..1124b47 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/view/MacOSXMenuBar.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/view/MacOSXMenuBar.groovy
@@ -125,6 +125,7 @@ menuBar {
         separator()
         menuItem(addClasspathJar)
         menuItem(addClasspathDir)
+        menuItem(listClasspath)
         menuItem(clearClassloader)
         separator()
         menuItem(inspectLastAction, icon:null)


Mime
View raw message