refactored
authorClaus Gittinger <cg@exept.de>
Thu, 17 Feb 2011 13:59:10 +0100
changeset 9784 afeca3b8a748
parent 9783 4e0f273bcee6
child 9785 eebe4073813f
refactored
AbstractFileBrowser.st
--- a/AbstractFileBrowser.st	Thu Feb 17 12:01:13 2011 +0100
+++ b/AbstractFileBrowser.st	Thu Feb 17 13:59:10 2011 +0100
@@ -1177,6 +1177,12 @@
             translateLabel: true
             shortcutKey: Ctrlt
           )
+"/         (MenuItem
+"/            label: 'Add XML-Tree Page'
+"/            itemValue: newTextEditor
+"/            translateLabel: true
+"/            shortcutKey: Ctrlt
+"/          )
          (MenuItem
             label: 'Add Shell Terminal Page'
             itemValue: doAddTerminal
@@ -1212,6 +1218,8 @@
         nil
         nil
       )
+
+    "Modified: / 17-02-2011 / 13:23:47 / cg"
 !
 
 cvsMenu
@@ -2081,7 +2089,7 @@
                (MenuItem
                   "/ enabled: hasXmlFileSelected
                   label: 'XML Inspector'
-                  itemValue: parseXmlFile
+                  itemValue: inspectXmlFile
                   translateLabel: true
                   isVisible: hasXml
                   showBusyCursorWhilePerforming: true
@@ -2330,7 +2338,7 @@
         nil
       )
 
-    "Modified: / 14-02-2011 / 17:17:44 / cg"
+    "Modified: / 17-02-2011 / 13:55:43 / cg"
 !
 
 viewDetailsMenuSpec
@@ -6155,6 +6163,51 @@
     "Modified: / 04-12-2006 / 13:14:48 / cg"
 !
 
+forEachParsedXmlFileDo:aBlock
+    "parse all selected XML files, for each dom-tree, evaluate aBlock"
+
+    self withActivityIndicationDo:[
+        | selectedFiles xmlDocument |
+
+        selectedFiles:= self currentSelectedFiles.
+        selectedFiles do:[:fileName |
+            XML::XMLSignal handle:[:ex |
+                Dialog information:('Error while reading XML:\    %1' bindWith:ex description) withCRs.
+                ^ self.
+            ] do:[
+                |s d magic encoder document|
+
+                s := fileName asFilename readStream.
+                s binary.
+                magic := (s next:2).
+                magic = #[254 255] ifTrue:[
+                    "/ UTF16BE
+                    document := CharacterEncoder decodeString:(s upToEnd) from:#utf16be.
+                ] ifFalse:[ 
+                    magic = #[255 254] ifTrue:[
+                        "/ UTF16LE
+                        document := CharacterEncoder decodeString:(s upToEnd) from:#utf16le.
+                    ].
+                ]. 
+                s close.
+
+                document notNil ifTrue:[
+                    xmlDocument := XML::XMLParser 
+                                    processDocumentString:document 
+                                    beforeScanDo:[:parse| parse validate:false].
+                ] ifFalse:[
+                    xmlDocument := XML::XMLParser 
+                                    processDocumentInFilename:fileName 
+                                    beforeScanDo:[:parse| parse validate:false].
+                ]
+            ].
+            aBlock value:xmlDocument.
+        ].
+    ]
+
+    "Created: / 17-02-2011 / 13:58:21 / cg"
+!
+
 forEachSelectedFileIgnoringDirectories:ignoreDirs do:aBlock 
     |numItems path files|
 
@@ -6219,6 +6272,22 @@
     ]
 !
 
+inspectXmlFile
+    "Show an XML file - either in an XMLInspector or fall back to
+     a plain inspector on the XML tree"
+
+    self forEachParsedXmlFileDo:[:xmlDocument |
+        XML::XMLInspector notNil ifTrue:[
+            XML::XMLInspector openOn:xmlDocument.
+        ] ifFalse:[
+            "fall back..."
+            xmlDocument inspect.
+        ]
+    ].
+
+    "Modified: / 17-02-2011 / 13:58:16 / cg"
+!
+
 installAllAsAutoloaded
     "install all classes found here as autoloaded classes"
 
@@ -6828,56 +6897,6 @@
     ].
 !
 
-parseXmlFile
-    "Show an XML file - either in an XMLInspector or fall back to
-     a plain inspector on the XML tree"
-
-    self withActivityIndicationDo:[
-        | selectedFiles xmlDocument |
-
-        selectedFiles:= self currentSelectedFiles.
-        selectedFiles do:[:fileName |
-            XML::XMLSignal handle:[:ex |
-                Dialog information:('Error while reading XML:\    %1' bindWith:ex description) withCRs.
-                ^ self.
-            ] do:[
-                |s d magic encoder document|
-
-                s := fileName asFilename readStream.
-                s binary.
-                magic := (s next:2).
-                magic = #[254 255] ifTrue:[
-                    "/ UTF16BE
-                    document := CharacterEncoder decodeString:(s upToEnd) from:#utf16be.
-                ] ifFalse:[ 
-                    magic = #[255 254] ifTrue:[
-                        "/ UTF16LE
-                        document := CharacterEncoder decodeString:(s upToEnd) from:#utf16le.
-                    ].
-                ]. 
-                s close.
-
-                document notNil ifTrue:[
-                    xmlDocument := XML::XMLParser 
-                                    processDocumentString:document 
-                                    beforeScanDo:[:parse| parse validate:false].
-                ] ifFalse:[
-                    xmlDocument := XML::XMLParser 
-                                    processDocumentInFilename:fileName 
-                                    beforeScanDo:[:parse| parse validate:false].
-                ]
-            ].
-            XML::XMLInspector notNil ifTrue:[
-                XML::XMLInspector openOn:xmlDocument.
-"/                XML::XMLInspector openWithoutDetailsOn:xmlDocument.
-            ] ifFalse:[
-                "fall back..."
-                xmlDocument inspect.
-            ]
-        ].
-    ]
-!
-
 readAbbrevFile
     "read the abbrev file and install classes found there as autoloaded classes"
 
@@ -8315,9 +8334,9 @@
 !AbstractFileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.456 2011-02-14 16:23:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.457 2011-02-17 12:59:10 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.456 2011-02-14 16:23:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.457 2011-02-17 12:59:10 cg Exp $'
 ! !