#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Fri, 06 Jul 2018 08:43:08 +0200
changeset 6375 0ee929d79a08
parent 6374 bbde223c59ec
child 6376 f3f6befe6205
#UI_ENHANCEMENT by cg class: TextView changed: #editMenu +openWebBrowserOnIt and openFileBrowserOnIt
TextView.st
--- a/TextView.st	Fri Jul 06 07:31:08 2018 +0200
+++ b/TextView.st	Fri Jul 06 08:43:08 2018 +0200
@@ -2259,7 +2259,7 @@
     <resource: #keyboard (#Copy #Find #GotoLine #SaveAs #Print)>
     <resource: #programMenu>
 
-    |item1 items m|
+    |item1 items m toolItems toolSubMenu|
 
     self sensor metaDown ifTrue:[
         item1 := #(
@@ -2276,22 +2276,55 @@
                         ('Search...'     search         Find)
                         ('Goto Line...'  gotoLine       GotoLine)
                         ('-'             nil            )
+                        ('Tools'         tools          )
                         ('Font...'       changeFont     )
                         ('-'             nil            )
                         ('Save As...'    save           SaveAs)
                         ('Print'         doPrint        Print)
                 ).
 
+    toolItems := #(
+                    ('Open FileBrowser on It'      openFileBrowserOnIt        )
+                    ('Open WebBrowser on It'       openWebBrowserOnIt         )
+              ).
+
     m := PopUpMenu itemList:items resources:resources.
+
+    toolSubMenu := PopUpMenu itemList:toolItems resources:resources performer:model.
+    toolSubMenu receiver:self.
+    m subMenuAt:#tools put:toolSubMenu.
     
     self hasSelectionForCopy ifFalse:[
         m disable:#copySelection.
         m disable:#copySelectionBox.
     ].
+    self hasSelection ifFalse:[
+        m disableAll:#(openFileBrowserOnIt openWebBrowserOnIt).
+    ] ifTrue:[
+        (Error handle:[:ex |
+            ex return:false
+        ] do:[
+            |fn|
+            fn := self selectionAsString withoutSeparators.
+            fn asFilename exists or:[ fn withoutQuotes asFilename exists ]
+        ]) ifFalse:[
+            m disableAll:#(openFileBrowserOnIt).
+        ].
+        (Error handle:[:ex |
+            ex return:false
+        ] do:[
+            |url|
+            url := self selectionAsString withoutSeparators.
+            #('http' 'https' 'ftp') includes:url asURL method
+        ]) ifFalse:[
+            m disableAll:#(openWebBrowserOnIt).
+        ]
+    ].    
     m := m asMenu.
     ^ m
 
     "Modified: / 12-04-2017 / 09:06:22 / cg"
+    "Modified: / 06-07-2018 / 08:42:17 / Claus Gittinger"
 !
 
 find