Added diff inspector tab for String-like objects
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 27 Feb 2014 17:55:19 +0100
changeset 14071 1920eb29e7b5
parent 14070 f95472e8cb38
child 14072 f261e252f590
Added diff inspector tab for String-like objects
extensions.st
--- a/extensions.st	Thu Feb 27 17:01:23 2014 +0100
+++ b/extensions.st	Thu Feb 27 17:55:19 2014 +0100
@@ -357,15 +357,44 @@
 
 !CharacterArray methodsFor:'inspecting'!
 
-inspector2TabHTML
+inspector2TabDiff
+    | diffApp |
+
+    diffApp := Tools::TextDiff2Tool new.
+    diffApp labelA: 'self'; textA: self.
+    diffApp labelB: 'pasted'; textB: 'Paste some text here'.
+    diffApp diffView leftTextView readOnly: true.
+    diffApp diffView rightTextView acceptAction:[:contents |
+        diffApp textBHolder value: contents asString.
+        diffApp updateViews.   
+    ].
 
     ^self newInspector2Tab
-        label: 'HTML';
-        priority: 35;
-        view: ((ScrollableView for:HTMLDocumentView) setText: self; yourself)
+        label: 'Diff';
+        priority: 33;
+        application: diffApp;
+        yourself
+
+    "Created: / 27-02-2014 / 16:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CharacterArray methodsFor:'inspecting'!
+
+inspector2TabHTML
+
+    ((self startsWith:'<!!DOCTYPE html') and:[ HTMLDocumentView ]) ifTrue:[
+        ^self newInspector2Tab
+            label: 'HTML';
+            priority: 35;
+            view: ((ScrollableView for:HTMLDocumentView) setText: self; yourself);
+            yourself
+    ].
+    "/ If nil is returned, tab is not shown...
+    ^ nil
 
     "Created: / 17-02-2008 / 10:10:50 / janfrog"
     "Created: / 07-11-2011 / 12:35:15 / cg"
+    "Modified: / 27-02-2014 / 16:08:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CharacterArray methodsFor:'inspecting'!
@@ -384,14 +413,10 @@
 !CharacterArray methodsFor:'inspecting'!
 
 inspector2Tabs
-    HTMLDocumentView notNil ifTrue:[
-        (self startsWith:'<!!DOCTYPE html') ifTrue:[
-            ^ #( inspector2TabCommon inspector2TabText inspector2TabBytes inspector2TabHTML )
-        ].
-    ].
-    ^ #( inspector2TabCommon inspector2TabText inspector2TabBytes )
+    ^ #( inspector2TabCommon inspector2TabText inspector2TabBytes inspector2TabDiff inspector2TabHTML )
 
     "Created: / 05-07-2011 / 13:40:27 / cg"
+    "Modified: / 27-02-2014 / 16:10:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CharacterArray methodsFor:'inspecting'!
@@ -2316,7 +2341,7 @@
 !stx_libtool class methodsFor:'documentation'!
 
 extensionsVersion_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/extensions.st,v 1.121 2014-02-25 10:39:31 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/extensions.st,v 1.122 2014-02-27 16:55:19 vrany Exp $'
 ! !
 
 !stx_libtool class methodsFor:'documentation'!