Tools__Inspector2.st
changeset 10597 0b3b91f5820f
parent 10596 a18767a996d8
child 10629 3d4fbb369b58
--- a/Tools__Inspector2.st	Fri Aug 19 08:46:40 2011 +0200
+++ b/Tools__Inspector2.st	Fri Aug 19 09:57:00 2011 +0200
@@ -15,13 +15,13 @@
 
 ApplicationModel subclass:#Inspector2
 	instanceVariableNames:'tabViewAspect navigationHistoryHolder navigationStateAspect
-		browser'
+		browser currentObjectHolder'
 	classVariableNames:'LastExtent'
 	poolDictionaries:''
 	category:'Interface-Inspector2'
 !
 
-Object subclass:#NavigationState
+Model subclass:#NavigationState
 	instanceVariableNames:'theObject index tabs selectionIndex displayString'
 	classVariableNames:''
 	poolDictionaries:''
@@ -42,6 +42,52 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
+!
+
+description
+"
+    an application for a multitab inspector
+    extendable by the inspected object itself, by providing additional
+    tabs via the inspector2XXX methods
+
+    [author:]
+        Jan Vrani
+"
+! !
+
+!Inspector2 class methodsFor:'help specs'!
+
+flyByHelpSpec
+    "This resource specification was automatically generated
+     by the UIHelpTool of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the UIHelpTool may not be able to read the specification."
+
+    "
+     UIHelpTool openOnClass:Tools::Inspector2    
+    "
+
+    <resource: #help>
+
+    ^ super flyByHelpSpec addPairsFrom:#(
+
+#backwardInVisitingHistory
+'Move backward in the history of previously visited objects'
+
+#browseClassOfShownObject
+'Open a Systembrowser on the shown object''s class'
+
+#browseFile
+'Open a Filebrowser on the file represented by the shown object'
+
+#forwardInVisitingHistory
+'Move forward in the history of previously visited objects'
+
+
+)
+
+    "Created: / 19-08-2011 / 08:52:33 / cg"
 ! !
 
 !Inspector2 class methodsFor:'interface specs'!
@@ -117,6 +163,7 @@
      #(Menu
         (
          (MenuItem
+            activeHelpKey: backwardInVisitingHistory
             enabled: backButtonEnabledHolder
             label: 'Back'
             itemValue: backButtonAction
@@ -127,6 +174,7 @@
             labelImage: (ResourceRetriever ToolbarIconLibrary historyBackIcon)
           )
          (MenuItem
+            activeHelpKey: forwardInVisitingHistory
             enabled: forwardButtonEnabledHolder
             label: 'Forward'
             itemValue: forwardButtonAction
@@ -140,6 +188,8 @@
             label: '-'
           )
          (MenuItem
+            activeHelpKey: browseClassOfShownObject
+            enabled: browseButtonEnabledHolder
             label: 'Browse'
             itemValue: browseClassAction
             translateLabel: true
@@ -147,10 +197,22 @@
             hideMenuOnActivated: false
             labelImage: (ResourceRetriever ToolbarIconLibrary startNewSystemBrowserIcon)
           )
+         (MenuItem
+            activeHelpKey: browseFile
+            label: 'Browse File'
+            itemValue: browseFileAction
+            translateLabel: true
+            isButton: true
+            isVisible: currentObjectIsFilename
+            hideMenuOnActivated: false
+            labelImage: (ResourceRetriever ToolbarIconLibrary startNewFileBrowserIcon)
+          )
          )
         nil
         nil
       )
+
+    "Modified: / 19-08-2011 / 09:27:19 / cg"
 ! !
 
 !Inspector2 class methodsFor:'startup'!
@@ -184,11 +246,11 @@
 
 !Inspector2 methodsFor:'accessing'!
 
-backButtonEnabled: value
-
-    ^self backButtonEnabledHolder value: value
+backButtonEnabled:value 
+    ^ self backButtonEnabledHolder value:value
 
     "Created: / 12-01-2008 / 19:14:35 / janfrog"
+    "Modified (format): / 19-08-2011 / 08:59:41 / cg"
 !
 
 currentObject
@@ -205,11 +267,11 @@
     "Modified: / 27-02-2008 / 11:56:55 / janfrog"
 !
 
-forwardButtonEnabled: value
-
-    ^self forwardButtonEnabledHolder value: value
+forwardButtonEnabled:value 
+    ^ self forwardButtonEnabledHolder value:value
 
     "Created: / 12-01-2008 / 19:14:48 / janfrog"
+    "Modified (format): / 19-08-2011 / 08:59:45 / cg"
 !
 
 navigationState
@@ -229,6 +291,7 @@
     "Created: / 17-02-2008 / 09:49:11 / janfrog"
     "Modified: / 21-02-2008 / 19:47:26 / janfrog"
     "Modified: / 22-07-2011 / 19:13:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 19-08-2011 / 09:16:38 / cg"
 ! !
 
 !Inspector2 methodsFor:'aspects'!
@@ -243,6 +306,32 @@
     "Modified: / 27-02-2008 / 12:11:30 / janfrog"
 !
 
+browseButtonEnabledHolder
+    ^ BlockValue
+        with:[:m | m notNil]
+        argument:self navigationStateAspect
+
+    "Created: / 19-08-2011 / 09:22:47 / cg"
+!
+
+currentObjectHolder
+    currentObjectHolder isNil ifTrue:[
+        currentObjectHolder := ValueHolder new
+    ].
+    ^ currentObjectHolder
+
+    "Created: / 27-02-2008 / 12:05:22 / janfrog"
+    "Created: / 19-08-2011 / 08:58:48 / cg"
+!
+
+currentObjectIsFilename
+    ^ BlockValue
+        with:[:o | o isFilename ]
+        argument:self currentObjectHolder
+
+    "Created: / 19-08-2011 / 08:56:27 / cg"
+!
+
 forwardButtonEnabledHolder
     "return/create the 'backButtonEnabledHolder' value holder (automatically generated)"
 
@@ -265,23 +354,23 @@
 !
 
 navigationStateAspect
-
-    navigationStateAspect ifNil:
-        [navigationStateAspect := 
-            (AspectAdaptor forAspect: #currentItem)
-                subjectChannel:self navigationHistoryHolder].
-    ^navigationStateAspect
+    navigationStateAspect isNil ifTrue:[
+        navigationStateAspect := (AspectAdaptor forAspect:#currentItem) 
+                    subjectChannel:self navigationHistoryHolder
+    ].
+    ^ navigationStateAspect
 
     "Created: / 27-02-2008 / 12:05:22 / janfrog"
+    "Modified (format): / 19-08-2011 / 08:59:10 / cg"
 !
 
 tabLabelsAspect
-
     ^ (AspectAdaptor forAspect:#tabLabels) 
-        subjectChannel: self navigationStateAspect
+        subjectChannel:self navigationStateAspect
 
     "Created: / 16-01-2008 / 17:29:52 / janfrog"
     "Modified: / 27-02-2008 / 12:05:32 / janfrog"
+    "Modified (format): / 19-08-2011 / 08:59:21 / cg"
 !
 
 tabSelectionIndexAspect
@@ -295,16 +384,15 @@
 !
 
 tabViewAspect
-    tabViewAspect 
-        ifNil:[
-            tabViewAspect := 
-                (AspectAdaptor forAspect:#selectionView) 
-                    subjectChannel: self navigationStateAspect
-        ].
+    tabViewAspect isNil ifTrue:[
+        tabViewAspect := (AspectAdaptor forAspect:#selectionView) 
+                    subjectChannel:self navigationStateAspect
+    ].
     ^ tabViewAspect
 
     "Created: / 16-01-2008 / 17:30:05 / janfrog"
     "Modified: / 27-02-2008 / 12:05:46 / janfrog"
+    "Modified (format): / 19-08-2011 / 08:59:35 / cg"
 !
 
 windowTitleAspect
@@ -342,20 +430,38 @@
 !
 
 browseClassAction
+    "open a class browser, or try to add a tab to the previously openeed class browser"
+
     | class |
 
     class := self currentObject class.
 
-    browser isNil ifTrue:[
-        browser := Tools::NewSystemBrowser openInClass:class selector:nil "/ browseSingleClass: class
-    ] ifFalse:[
-        browser spawnClassBrowserFor:(Array with:class) in:#newBuffer.
-        "/ browser spawnSingleClassBrowserFor:class in:#newBuffer.
-        browser window raise.
-    ]
+    browser notNil ifTrue:[
+        "/ try to add a tab to the already opened browser
+        (browser isKindOf:Tools::NewSystemBrowser) ifTrue:[
+            browser spawnClassBrowserFor:(Array with:class) in:#newBuffer.
+            "/ browser spawnSingleClassBrowserFor:class in:#newBuffer.
+            browser window raise.
+            ^ self.
+        ].
+    ].
+    "/ if that fails, open a new one
+
+    browser := UserPreferences current systemBrowserClass openInClass:class selector:nil "/ browseSingleClass: class
 
     "Modified: / 23-07-2011 / 11:28:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 04-08-2011 / 14:24:41 / cg"
+    "Modified (comment): / 19-08-2011 / 09:32:21 / cg"
+!
+
+browseFileAction
+    "open a filebrowser on the file represented by the current object"
+
+    | fn |
+
+    fn := self currentObject asFilename.
+    UserPreferences current fileBrowserClass openOn:fn
+
+    "Created: / 19-08-2011 / 09:29:44 / cg"
 !
 
 forwardButtonAction
@@ -376,6 +482,7 @@
 !
 
 historyTryPush: anObject
+    <resource: #obsolete>
 
   "/ Pokud uz na anObject byl tak tam skocit, jinak pridat na konec
   self history do: [:item |
@@ -388,15 +495,14 @@
 !
 
 inspect:anObject 
-    self navigationHistoryHolder 
-        currentItem: (NavigationState for: anObject).
-
-    self window notNil ifTrue:[ 
+    self navigationHistoryHolder currentItem:(NavigationState for:anObject).
+    self window notNil ifTrue:[
         self updateWindowLabel
     ].
 
     "Modified: / 27-02-2008 / 12:06:52 / janfrog"
     "Modified: / 15-07-2011 / 16:26:03 / cg"
+    "Modified (format): / 19-08-2011 / 09:01:20 / cg"
 !
 
 openOn: anObject
@@ -419,6 +525,7 @@
     (currentItem := self navigationHistoryHolder currentItem) notNil ifTrue:[
         object := currentItem theObject.
     ].
+    self currentObjectHolder value:object.
     self window label:(InspectorView commonLabelFor:object).
 
     "Created: / 15-07-2011 / 16:25:42 / cg"
@@ -426,17 +533,20 @@
 
 !Inspector2::NavigationState class methodsFor:'creating classes'!
 
-for: anObject
-  | item |
-  item := self new.
-  item theObject: anObject.
-  ^ item.
+for:anObject 
+    |item|
+
+    item := self new.
+    item theObject:anObject.
+    ^ item.
+
+    "Modified (format): / 19-08-2011 / 09:24:40 / cg"
 ! !
 
 !Inspector2::NavigationState class methodsFor:'documentation'!
 
 version
-    ^'$Id: Tools__Inspector2.st,v 1.15 2011-08-19 06:46:40 cg Exp $'
+    ^'$Id: Tools__Inspector2.st,v 1.16 2011-08-19 07:57:00 cg Exp $'
 !
 
 version_SVN
@@ -511,8 +621,10 @@
 
 theObject:anObject
     theObject := anObject.
+    self changed
 
     "Modified: / 17-02-2008 / 08:38:44 / janfrog"
+    "Modified: / 19-08-2011 / 09:16:25 / cg"
 ! !
 
 !Inspector2::NavigationState methodsFor:'comparing'!
@@ -617,11 +729,11 @@
 !Inspector2 class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__Inspector2.st,v 1.15 2011-08-19 06:46:40 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__Inspector2.st,v 1.16 2011-08-19 07:57:00 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/Tools__Inspector2.st,v 1.15 2011-08-19 06:46:40 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/Tools__Inspector2.st,v 1.16 2011-08-19 07:57:00 cg Exp $'
 !
 
 version_CVS_jvrany