Tools_NavigationState.st
author Claus Gittinger <cg@exept.de>
Mon, 20 Jan 2020 21:02:47 +0100
changeset 19422 c6ca1c3e0fd7
parent 13876 82a149c4e4cb
permissions -rw-r--r--
#REFACTORING by exept class: MultiViewToolApplication added: #askForFile:default:forSave:thenDo: changed: #askForFile:default:thenDo: #askForFile:thenDo: #menuSaveAllAs #menuSaveAs

"
 COPYRIGHT (c) 2000 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libtool' }"

"{ NameSpace: Tools }"

Object subclass:#NavigationState
	instanceVariableNames:'browserLabel codeModifiedHolder categoryList classList
		packageFilter nameSpaceFilter hidePrivateClasses canvasType
		notMetaToggle metaToggle metaToggleLabel organizerMode codeAspect
		codeHolder classDocumentationHolder canvas selectorListGenerator
		protocolListGenerator classListPerNameSpaceGenerator
		classListGenerator categoryListGenerator nameSpaceListGenerator
		projectListGenerator classHierarchyTopClass meta selectedMethods
		selectedProtocols selectedClasses selectedCategories
		selectedProjects selectedNamespaces selectedLintRules
		variableFilter filterClassVars sortBy noAllItem autoSearchPattern
		autoSearchIgnoreCase autoSearchAction realModifiedStateHolder
		methodInfo versionDiffApplication selectorListGeneratorArray
		selectedMethodsArray infoLabelHolder packageLabelHolder
		cursorLineLabelHolder cursorColLabelHolder modeLabelHolder
		sortVariablesBy editModeHolder scrollableCodeView specialEditors
		selectedEditorNoteBookTabIndexHolder editorNoteBookListHolder
		editorNoteBookCanvasHolder codeView stringSearchToolView
		noteBookView inheritanceView documentationView languageHolder
		messageSpecHolder messageHolder progressHolder tabContentView
		messagePaneView codePaneAndPluginView
		codePaneAndPluginViewRelativeCorners pluginVisibleHolder
		bookmarkHolder worker packageInfoBackgroundColorHolder
		packageInfoButton showMethodTemplate lastMethodShownInCodeView
		showingParseError'
	classVariableNames:'CodeAspectTranslations'
	poolDictionaries:''
	category:'Interface-Browsers-New'
!

!NavigationState class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2000 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
! !

!NavigationState class methodsFor:'initialization'!

initialize
    "Invoked at system start or when the class is dynamically loaded."

    "/ please change as required (and remove this comment)

    CodeAspectTranslations := Dictionary new.
    CodeAspectTranslations at: #newApplication put: SyntaxHighlighter codeAspectClassDefinition.
    CodeAspectTranslations at: #newError put: SyntaxHighlighter codeAspectClassDefinition.


    "/ Add more...

    "Modified: / 23-10-2012 / 11:27:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!NavigationState methodsFor:'accessing'!

autoSearchAction
    ^ autoSearchAction
!

autoSearchAction:something
    autoSearchAction := something.
!

autoSearchIgnoreCase
    "return true if the autSearch is to be case-insensitive"

    ^ autoSearchIgnoreCase
!

autoSearchIgnoreCase:aBoolean
    "change the autSearches case-insensitivenes"

    autoSearchIgnoreCase := aBoolean
!

autoSearchPattern
    "return the automatic search pattern"

    ^ autoSearchPattern
!

autoSearchPattern:aPattern
    "change the automatic search pattern"

    autoSearchPattern := aPattern.
!

browserLabel
    "return the assigned state-label (to be shown in the tab)."

    ^ browserLabel
!

browserLabel:aString
    "set the assigned state-label (to be shown in the tab)."

    browserLabel := aString
!

canvas
    ^ canvas
!

canvas:something
    canvas := something.
    canvasType isNil ifTrue:[
        canvasType := something spec
    ].
!

canvasType
    "return the type of canvas"

    ^ canvasType
!

canvasType:aSpecSymbol
    "set the type of canvas"

    canvasType notNil ifTrue:[
        canvasType ~~ aSpecSymbol ifTrue:[
            self halt:'cannot be changed, once set'.
        ]
    ].
    canvasType := aSpecSymbol
!

codeAspect
    "return the codeAspect; a symbol describing what is shown in the codeView"

    ^ codeAspect

    "Created: / 11.2.2000 / 12:43:29 / cg"
!

codeAspect:aSymbolOrNil
    "set the codeAspect; a symbol describing what is shown in the codeView"

    codeAspect := aSymbolOrNil.
    (codeView notNil and:[codeView isCodeView2]) ifTrue:[
        | xlatedCodeAspect |

        xlatedCodeAspect := CodeAspectTranslations at: aSymbolOrNil ifAbsent: aSymbolOrNil.
        codeView codeAspect: xlatedCodeAspect
    ].

    "Created: / 11-02-2000 / 12:43:45 / cg"
    "Modified: / 22-10-2012 / 17:05:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

codePaneAndPluginView
    ^ codePaneAndPluginView
!

codePaneAndPluginView:something
    codePaneAndPluginView := something.
!

codePaneAndPluginViewRelativeCorners
    codePaneAndPluginViewRelativeCorners ifNil:[
        codePaneAndPluginViewRelativeCorners := #(0.76 1.0)
    ].
    ^ codePaneAndPluginViewRelativeCorners

    "Modified: / 04-10-2010 / 08:20:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

codePaneAndPluginViewRelativeCorners: anArray

    codePaneAndPluginViewRelativeCorners := anArray.

    "Modified: / 04-10-2010 / 08:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

editorNoteBookCanvasHolder
    editorNoteBookCanvasHolder isNil ifTrue:[
        editorNoteBookCanvasHolder := nil asValue.
    ].
    ^ editorNoteBookCanvasHolder
!

editorNoteBookListHolder
    editorNoteBookListHolder isNil ifTrue:[
        editorNoteBookListHolder := #() asValue.
    ].
    ^ editorNoteBookListHolder
!

environment
    ^ Smalltalk
!

lastMethodShownInCodeView
    ^ lastMethodShownInCodeView
!

lastMethodShownInCodeView:something
    lastMethodShownInCodeView := something.
!

messagePaneView
    ^ messagePaneView
!

messagePaneView:something
    messagePaneView := something.
!

modified
    "check for modified code by asking the editTextView;
     this one returns true if ever modified - even if
     the modifications where undone in the editor
     (i.e. not really modified).
     Use #reallyModified if the contents should be compared
     against the original contents"

    |v|

    self realModifiedState == true ifTrue:[^ true].
    self anySpecialEditorModified ifTrue:[^ true].

    ^ (v := self codeView) notNil and:[v modified]
!

modified:aBoolean
    |codeView|

    (codeView := self codeView) notNil ifTrue:[
        codeView modified:aBoolean
    ].
    specialEditors notNil ifTrue:[
        specialEditors do:[:anEditor | 
            anEditor application modified:aBoolean
        ].    
    ].
!

noteBookView
    ^ noteBookView
!

noteBookView:something
    noteBookView := something.
!

realModifiedState
    ^ self realModifiedStateHolder value
!

realModifiedState:aBoolean
    self realModifiedStateHolder value:aBoolean
!

realModifiedStateHolder
    realModifiedStateHolder isNil ifTrue:[
        realModifiedStateHolder := ValueHolder new.
    ].
    ^ realModifiedStateHolder
!

selectedEditorNoteBookTabIndexHolder
    selectedEditorNoteBookTabIndexHolder isNil ifTrue:[
        selectedEditorNoteBookTabIndexHolder := 1 asValue.
    ].
    ^ selectedEditorNoteBookTabIndexHolder
!

showMethodTemplate
    ^ showMethodTemplate ? true

    "Created: / 12-02-2012 / 08:49:32 / cg"
!

showMethodTemplate: aBoolean
    showMethodTemplate := aBoolean

    "Created: / 12-02-2012 / 08:49:45 / cg"
!

showingParseError
    ^ showingParseError
!

showingParseError:something
    showingParseError := something.
!

stringSearchToolView
    ^ stringSearchToolView
!

stringSearchToolView: aStringSearchTool

    stringSearchToolView := aStringSearchTool
!

tabContentView
    ^ tabContentView
!

tabContentView:something
    tabContentView := something.
!

worker
    ^ worker
!

worker:aProcess
    worker := aProcess.
! !

!NavigationState methodsFor:'accessing-selection'!

theSingleSelectedClass
    "if only one class is selected, return it.
     Otherwise, return nil"

    |classes|

    classes := self selectedClasses value.
    classes size == 1 ifTrue:[
        ^ classes first
    ].
    ^ nil
!

theSingleSelectedMethod
    "if only one method is selected, return it.
     Otherwise, return nil"

    |methods|

    methods := self selectedMethods value.
    methods size == 1 ifTrue:[
        ^ methods first
    ].
    ^ nil
! !

!NavigationState methodsFor:'accessing-subApps'!

applicationOfComponent:aComponentName
    ^ self applicationOfComponent:aComponentName or:nil

!

applicationOfComponent:aComponentName or:anotherComponentName
    |builder view|

    canvas isNil ifTrue:[^ nil].

    builder := canvas builder.

    view := builder findVisibleComponentAt:aComponentName.
    (view isNil and:[anotherComponentName notNil]) ifTrue:[
        view := builder findVisibleComponentAt:anotherComponentName.
    ].

    view notNil ifTrue:[
        ^ view application
    ].
    ^ nil
!

classCategoryListApplication
    ^ self applicationOfComponent:#ClassCategoryList

!

classHierarchyListApplication
    ^ self applicationOfComponent:#ClassHierarchyList
!

classListApplication
    ^ self applicationOfComponent:#ClassList

!

metaToggleComponent
    ^ canvas builder findComponentAt:#ClassToggle.
!

methodCategoryListApplication
    ^ self applicationOfComponent:#MethodCategoryList
!

methodListApplication
    ^ self applicationOfComponent:#MethodList
!

nameSpaceListApplication
    ^ self applicationOfComponent:#NamespaceList or:#PseudoNamespaceList
!

projectListApplication
    ^ self applicationOfComponent:#ProjectList or:#PseudoProjectList
!

variableListApplication
    ^ self applicationOfComponent:#VariableList 
!

versionDiffApplication
    ^ versionDiffApplication

!

versionDiffApplication:anApplication
    versionDiffApplication := anApplication

! !

!NavigationState methodsFor:'accessing-subViews'!

anySpecialEditorModified
    specialEditors notNil ifTrue:[
        ^ specialEditors contains:[:anEditor | anEditor application isModified].    
    ].
    ^ false
!

codeView
    codeView isNil ifTrue:[
        codeView := self scrollableCodeView scrolledView
    ].
    ^ codeView
!

doSaveInSpecialEditors
    specialEditors notNil ifTrue:[
        specialEditors do:[:anEditor | 
            anEditor application isModified ifTrue:[
                anEditor application save.
                ^ self.
            ]
        ].    
    ].
!

documentationView
    |textView|

    documentationView isNil ifTrue:[
        textView := CodeView new.
        documentationView := HVScrollableView forView:textView.
    ].
    ^ documentationView
!

getCodeView
    ^ codeView
!

inheritanceView
    inheritanceView isNil ifTrue:[
        |classTreeView scrolledView|

        classTreeView := ClassTreeGraphView new.
        scrolledView := HVScrollableView forView:classTreeView.
        classTreeView middleButtonMenu:nil.
        inheritanceView := scrolledView
    ].
    ^ inheritanceView
!

methodCategoryList: aView

    | builder |

    builder := canvas builder.
    builder namedComponents at: #MethodCategoryList put: aView.

    "Created: / 08-08-2011 / 09:18:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

methodList: aView

    | builder |

    builder := canvas builder.
    builder namedComponents at: #MethodList put: aView.

    "Created: / 08-08-2011 / 15:32:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

packageInfoButton
    ^ packageInfoButton
!

packageInfoButton:something
    packageInfoButton := something.
!

scrollableCodeView
    scrollableCodeView isNil ifTrue:[
        scrollableCodeView := self setUpScrollableCodeView.
    ].
    ^ scrollableCodeView
!

setUpScrollableCodeView
    |v newScrollableCodeView newCodeView |

    (UserPreferences current useCodeView2In: #Browser) ifTrue:[
        newCodeView := newScrollableCodeView := CodeView2 new.
        newCodeView mode: #method.
        newCodeView methodHolder: self theSingleSelectedMethodHolder.
        newCodeView classHolder: self theSingleSelectedClassHolder.
    ] ifFalse:[
        newScrollableCodeView := HVScrollableView for:CodeView.
        newCodeView := newScrollableCodeView scrolledView.
        newScrollableCodeView horizontalMini:true.
    ].

    newScrollableCodeView name:'CodeView'.
    newCodeView modifiedChannel:self codeModifiedHolder.
    newCodeView model:self codeHolder.
    newCodeView canTab:true.
    UserPreferences current useCodeView2InTools ifTrue:[
        newCodeView
            classHolder:self theSingleSelectedClassFromMethodHolder;
            languageHolder:self languageHolder
    ].

    (UserPreferences current showAcceptCancelBarInBrowser 
        and:[newCodeView isCodeView2 not or:[UserPreferences current codeView2ShowAcceptCancel not]]) ifTrue:[
        ViewWithAcceptAndCancelBar notNil ifTrue:[
            v := ViewWithAcceptAndCancelBar new.
            v slaveView:newScrollableCodeView.
            v reallyModifiedHolder:self realModifiedStateHolder.
            v cancelAction:
                [
                    "/ codeView setClipboardText:(codeView contents).   "/ for undo
                    newCodeView device rememberInCopyBufferHistory:(newCodeView contents).  "/ for undo
                    newCodeView application
                        delayedUpdateCodeWithAutoSearch:false checkModified:false.
                    newCodeView requestFocus.
                ].
            v compareAction:
                [
                    newCodeView application doCompareIn:self.
                    newCodeView requestFocus
                ].
            newScrollableCodeView := v.
        ]
    ].

   ^newScrollableCodeView

    "Modified: / 05-07-2011 / 10:34:33 / cg"
    "Modified: / 05-08-2011 / 09:44:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

specialEditorCanvasClassForResourceType:resourceTypeSymbol
    resourceTypeSymbol == #fileImage ifTrue:[
        ^ nil
    ].
    ^ SystemBrowser resourceEditorClassFor:resourceTypeSymbol
!

specialEditorCanvasForResourceType:resourceTypeSymbol
    |appClass app editorView|

    specialEditors isNil ifTrue:[
        specialEditors := Dictionary new.    
    ].
    editorView := specialEditors at:resourceTypeSymbol ifAbsent:nil.
    editorView isNil ifTrue:[
        appClass := self specialEditorCanvasClassForResourceType:resourceTypeSymbol.
        appClass notNil ifTrue:[
            app := appClass new.
            app masterApplication:self canvas application.
            app isEmbeddedInBrowser:true.
            app infoLabelHolder:(self canvas application infoLabelHolder).

            editorView := ApplicationSubView new.
            editorView buildMenu:true.
            editorView client:app.
            app builder window:editorView.

            specialEditors at:resourceTypeSymbol put:editorView.
        ].
    ].
    ^ editorView
! !

!NavigationState methodsFor:'aspects'!

bookmarkHolder
    "return/create the 'bookmarkHolder' value holder (automatically generated)"

    bookmarkHolder isNil ifTrue:[
        bookmarkHolder := ValueHolder with: self theSingleSelectedBookmarkFromMethodOrClass.
        self selectedMethods onChangeSend: #updateBookmarkHolder to: self.
        self selectedClasses onChangeSend: #updateBookmarkHolder to: self.
    ].
    ^ bookmarkHolder

    "Modified: / 03-06-2011 / 12:00:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

categoryList
    categoryList isNil ifTrue:[
        categoryList := nil asValue.
    ].
    ^ categoryList

    "Modified: / 25.2.2000 / 01:35:42 / cg"
    "Created: / 25.2.2000 / 01:57:45 / cg"
!

categoryListGenerator
    categoryListGenerator isNil ifTrue:[
        categoryListGenerator := nil asValue.
    ].
    ^ categoryListGenerator

    "Created: / 25.2.2000 / 01:34:30 / cg"
    "Modified: / 25.2.2000 / 01:35:42 / cg"
!

classDocumentationHolder
    classDocumentationHolder isNil ifTrue:[
        classDocumentationHolder := nil asValue.
    ].
    ^ classDocumentationHolder
!

classHierarchyTopClass
    classHierarchyTopClass isNil ifTrue:[
        classHierarchyTopClass := nil asValue.
    ].
    ^ classHierarchyTopClass

!

classList
    classList isNil ifTrue:[
        classList := nil asValue.
    ].
    ^ classList

    "Created: / 25.2.2000 / 01:57:28 / cg"
!

classListGenerator
    classListGenerator isNil ifTrue:[
        classListGenerator := nil asValue.
    ].
    ^ classListGenerator


!

classListPerNameSpaceGenerator
    classListPerNameSpaceGenerator isNil ifTrue:[
        classListPerNameSpaceGenerator := nil asValue.
    ].
    ^ classListPerNameSpaceGenerator

    "Created: / 18.8.2000 / 14:15:34 / cg"
!

codeHolder
    codeHolder isNil ifTrue:[
        codeHolder := nil asValue.
    ].
    ^ codeHolder

!

codeModifiedHolder
    codeModifiedHolder isNil ifTrue:[
        codeModifiedHolder := false asValue.
    ].
    ^ codeModifiedHolder
!

cursorColLabelHolder
    cursorColLabelHolder isNil ifTrue:[
"/        self codeView isNil ifTrue:[^ nil].

        cursorColLabelHolder := BlockValue 
                                    with:[:v | v printString]
                                    argument:self codeView cursorColHolder.
    ].
    ^ cursorColLabelHolder
!

cursorLineLabelHolder
    cursorLineLabelHolder isNil ifTrue:[
"/        self codeView isNil ifTrue:[^ nil].

        cursorLineLabelHolder := BlockValue 
                                    with:[:v | v printString]
                                    argument:self codeView cursorLineHolder.
    ].
    ^ cursorLineLabelHolder
!

editModeHolder
    editModeHolder isNil ifTrue:[
        editModeHolder := self codeView editModeHolder.
    ].
    ^ editModeHolder
!

filterClassVars
    filterClassVars isNil ifTrue:[
        filterClassVars := false asValue.
    ].
    ^ filterClassVars

    "Created: / 24.2.2000 / 23:45:28 / cg"
!

hidePrivateClasses
    hidePrivateClasses isNil ifTrue:[
        hidePrivateClasses := false asValue.
    ].
    ^ hidePrivateClasses

    "Created: / 24.2.2000 / 16:17:02 / cg"
!

infoLabelHolder 
    infoLabelHolder isNil ifTrue:[
        infoLabelHolder := '' asValue.
    ].
    ^ infoLabelHolder
!

languageHolder

    languageHolder ifNil:[
        languageHolder := ValueHolder with: self theSingleSelectedLanguageFromMethodOrClass.
        self selectedMethods onChangeSend: #updateLanguageHolder to: self.
        self selectedClasses onChangeSend: #updateLanguageHolder to: self.
    ].
    ^languageHolder

    "Created: / 20-07-2010 / 16:03:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

lintRuleListGenerator

    | result |
    result := self objectAttributeAt: #lintRuleListGenerator.
    result ifNil:
        [result := ValueHolder new.
        self objectAttributeAt: #lintRuleListGenerator put: result].
    ^result

    "Created: / 22-07-2009 / 15:27:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

messageHolder
    "return/create the 'messageHolder' value holder (automatically generated)"

    messageHolder isNil ifTrue:[
        messageHolder := ValueHolder new.
    ].
    ^ messageHolder
!

messageHolder:aValueHolder
    "set the 'messageHolder' value holder (automatically generated)"

    messageHolder := aValueHolder.
!

messageSpecHolder
    "return/create the 'messageSpecHolder' value holder (automatically generated)"

    messageSpecHolder isNil ifTrue:[
        messageSpecHolder := ValueHolder with:#messageInfoSpec.
    ].
    ^ messageSpecHolder

    "Modified: / 28-08-2010 / 11:40:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

messageSpecHolder:something
    "set the 'messageSpecHolder' value holder (automatically generated)"

    messageSpecHolder := something.
!

meta
    meta isNil ifTrue:[
        meta := false asValue.
    ].
    ^ meta


!

metaToggleLabelHolder
    metaToggleLabel isNil ifTrue:[
        metaToggleLabel := 'Class' asValue.
    ].
    ^ metaToggleLabel
!

methodInfo
    methodInfo isNil ifTrue:[
        methodInfo := nil asValue.
    ].
    ^ methodInfo

!

methodList
    |methodListApplication|

    methodListApplication := self methodListApplication.
    methodListApplication isNil ifTrue:[^ nil].

    ^ methodListApplication methodList
!

modeLabelHolder
    modeLabelHolder isNil ifTrue:[
        modeLabelHolder := self codeView modeLabelHolder.
    ].
    ^ modeLabelHolder
!

nameSpaceFilter
    nameSpaceFilter isNil ifTrue:[
        nameSpaceFilter := nil asValue.
    ].
    ^ nameSpaceFilter

    "Created: / 18.8.2000 / 14:25:24 / cg"
!

nameSpaceListGenerator
    nameSpaceListGenerator isNil ifTrue:[
        nameSpaceListGenerator := nil asValue.
    ].
    ^ nameSpaceListGenerator

    "Created: / 18.8.2000 / 14:26:19 / cg"
    "Modified: / 18.8.2000 / 14:27:59 / cg"
!

navigationHistory

    | history |
    history := self objectAttributeAt: #navigationHistory.
    history ifNil:
        [history := NavigationHistory new.
        self objectAttributeAt: #navigationHistory put: history].
    ^history

    "Created: / 21-02-2008 / 20:08:43 / janfrog"
    "Modified: / 21-07-2009 / 22:39:57 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

noAllItem
    noAllItem isNil ifTrue:[
        noAllItem := nil asValue.
    ].
    ^ noAllItem
!

organizerMode
    "return the organizerMode holder; 
     holding a symbol describing how things are organized
     (#category, #hierarchy, #project or #namespace)"

    organizerMode isNil ifTrue:[
        organizerMode := OrganizerCanvas organizerModeCategory asValue.
    ].
    ^ organizerMode

    "Created: / 18.2.2000 / 13:33:55 / cg"
    "Modified: / 18.8.2000 / 18:37:22 / cg"
!

packageFilter
    packageFilter isNil ifTrue:[
        packageFilter := nil asValue.
    ].
    ^ packageFilter

    "Created: / 24.2.2000 / 23:45:28 / cg"
!

packageInfoBackgroundColorHolder

    packageInfoBackgroundColorHolder isNil ifTrue:[
        packageInfoBackgroundColorHolder := nil asValue.
    ].
    ^ packageInfoBackgroundColorHolder

    "Created: / 03-10-2011 / 14:04:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

packageLabelHolder
    packageLabelHolder isNil ifTrue:[
        packageLabelHolder := '' asValue.
    ].
    ^ packageLabelHolder
!

pluginVisibleHolder
    pluginVisibleHolder isNil ifTrue:[
        pluginVisibleHolder := false asValue.
    ].
    ^ pluginVisibleHolder

    "Created: / 03-10-2010 / 17:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

profilerStatistics

    | statistics |
    statistics := self objectAttributeAt: #profilerStatistics.
    statistics ifNil:
        [statistics := ValueHolder new.
        self objectAttributeAt: #profilerStatistics put: statistics].
    ^statistics

    "Created: / 21-02-2008 / 20:08:43 / janfrog"
    "Modified: / 21-07-2009 / 22:40:34 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

profilerStatistics: anObject

    self objectAttributeAt: #profilerStatistics put: anObject

    "Created: / 21-02-2008 / 20:08:43 / janfrog"
    "Modified: / 21-07-2009 / 22:41:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

progressHolder
    "return/create the 'progressHolder' value holder (automatically generated)"

    progressHolder isNil ifTrue:[
        progressHolder := ValueHolder new.
    ].
    ^ progressHolder
!

progressHolder:aValueHolder
    "set the 'progressHolder' value holder (automatically generated)"

    progressHolder := aValueHolder.
!

projectListGenerator
    projectListGenerator isNil ifTrue:[
        projectListGenerator := nil asValue.
    ].
    ^ projectListGenerator

    "Modified: / 25.2.2000 / 01:35:42 / cg"
    "Created: / 25.2.2000 / 02:43:26 / cg"
!

protocolListGenerator
    protocolListGenerator isNil ifTrue:[
        protocolListGenerator := nil asValue.
    ].
    ^ protocolListGenerator

!

selectedCategories
    selectedCategories isNil ifTrue:[
        selectedCategories := nil asValue.
    ].
    ^ selectedCategories

!

selectedClasses
    selectedClasses isNil ifTrue:[
        selectedClasses := "SpecialValueHolder with:nil." nil asValue.
    ].
    ^ selectedClasses

    "Modified: / 26-02-2013 / 12:29:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectedLintRules
    selectedLintRules isNil ifTrue:[
        selectedLintRules := nil asValue.
    ].
    ^ selectedLintRules

    "Modified: / 02-02-2010 / 20:42:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectedMethods
    selectedMethods isNil ifTrue:[
        selectedMethods := nil asValue.
    ].
    ^ selectedMethods

!

selectedMethodsArrayAt:index
    |holder|

    selectedMethodsArray isNil ifTrue:[
        selectedMethodsArray := OrderedCollection new 
    ].
    index > selectedMethodsArray size ifTrue:[
        selectedMethodsArray grow:index
    ].
    holder := selectedMethodsArray at:index.
    holder isNil ifTrue:[
        selectedMethodsArray at:index put:(holder := ValueHolder new)
    ].
    ^ holder.
!

selectedNamespaces
    selectedNamespaces isNil ifTrue:[
        selectedNamespaces := nil asValue.
    ].
    ^ selectedNamespaces

!

selectedProjects
    selectedProjects isNil ifTrue:[
        selectedProjects := nil asValue.
    ].
    ^ selectedProjects

!

selectedProtocols
    selectedProtocols isNil ifTrue:[
        selectedProtocols := nil asValue.
    ].
    ^ selectedProtocols

!

selectorListGenerator
    selectorListGenerator isNil ifTrue:[
        selectorListGenerator := nil asValue.
    ].
    ^ selectorListGenerator

!

selectorListGeneratorArray
    self halt:'should not be invoked'.
!

selectorListGeneratorArrayAt:index
    |holder|

    selectorListGeneratorArray isNil ifTrue:[
        selectorListGeneratorArray := OrderedCollection new 
    ].
    index > selectorListGeneratorArray size ifTrue:[
        selectorListGeneratorArray grow:index
    ].
    holder := selectorListGeneratorArray at:index.
    holder isNil ifTrue:[
        selectorListGeneratorArray at:index put:(holder := ValueHolder new)
    ].
    ^ holder.
!

sortBy
    sortBy isNil ifTrue:[
        sortBy := nil asValue.
    ].
    ^ sortBy
!

theSingleSelectedBookmarkFromMethodOrClass

    | mth cls |

    mth := self theSingleSelectedMethod. 
    (mth notNil and:[mth mclass notNil])
        ifTrue:[^Tools::NewSystemBrowser bookmarkForClass:mth mclass selector:mth selector].
    cls := self theSingleSelectedClass.
    cls 
        ifNotNil:[^Tools::NewSystemBrowser bookmarkForClass:cls selector:nil].
    ^nil

    "Created: / 02-06-2011 / 22:16:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-06-2011 / 23:19:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

theSingleSelectedClassFromMethodHolder

    ^BlockValue 
        with:
            [:i1 :i2| | mth cls |
            mth := self theSingleSelectedMethod. 
            cls := mth ifNil:[nil] ifNotNil:[mth mclass].
            cls ifNil:[
            cls := self theSingleSelectedClass].
            cls]
        argument: self selectedMethods
        argument: self selectedClasses.

    "Created: / 14-02-2010 / 10:05:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

theSingleSelectedClassHolder

    ^BlockValue 
        with:
            [:i1 | self theSingleSelectedClass]
        argument: 
            self selectedClasses

    "Created: / 05-08-2011 / 09:44:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

theSingleSelectedLanguageFromMethodOrClass

    | mth cls |

    mth := self theSingleSelectedMethod. 
    mth ifNotNil:[^mth programmingLanguage].
    cls := self theSingleSelectedClass.
    cls ifNotNil:[^cls programmingLanguage].
    ^SmalltalkLanguage instance

    "Created: / 20-07-2010 / 15:59:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

theSingleSelectedMethodHolder

    ^BlockValue 
        with:
            [:i1 | self theSingleSelectedMethod]
        argument: 
            self selectedMethods

    "Created: / 17-06-2011 / 12:39:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

updateBookmarkHolder

   ^self bookmarkHolder value: self theSingleSelectedBookmarkFromMethodOrClass

    "Created: / 02-06-2011 / 22:13:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

updateLanguageHolder

   ^self languageHolder value: self theSingleSelectedLanguageFromMethodOrClass

    "Created: / 20-07-2010 / 16:05:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

variableFilter
    variableFilter isNil ifTrue:[
        variableFilter := nil asValue.
    ].
    ^ variableFilter

    "Created: / 24.2.2000 / 23:45:28 / cg"
! !

!NavigationState methodsFor:'aspects-kludges'!

metaToggle
    metaToggle isNil ifTrue:[
        metaToggle := PluggableAdaptor on:(self meta).
        metaToggle
            getBlock:[:m | m value == true]
            putBlock:[:m :newValue | m value:(newValue ? false)]
            updateBlock:[:m :aspect :param | true].
    ].
    ^ metaToggle
!

notMetaToggle
    notMetaToggle isNil ifTrue:[
        notMetaToggle := PluggableAdaptor on:(self meta).
        notMetaToggle
            getBlock:[:m | m value == false]
            putBlock:[:m :newValue | m value:(newValue ? false) not]
            updateBlock:[:m :aspect :param | true].
    ].
    ^ notMetaToggle
! !

!NavigationState methodsFor:'history'!

addToHistory: class selector: selector

    | entry |
    "/selector ifNil:[^self].
    entry := SystemBrowser historyEntryForClass: class selector: selector.
    self navigationHistory goTo: entry.
    ^entry

    "Created: / 22-02-2008 / 08:44:05 / janfrog"
    "Modified: / 22-02-2008 / 17:20:00 / janfrog"
    "Modified: / 06-04-2012 / 10:55:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!NavigationState methodsFor:'printing & storing'!

colorizeForModifiedBuffer:someString
    ^ someString asText emphasisAllAdd:(UserPreferences current emphasisForModifiedBuffer)
!

nameString
    "a descriptive string of what this state shows"

    |s|

    s := self rawNameStringOrNil ? 'nothing selected'.

    (self realModifiedState == true) ifTrue:[
        ^ self colorizeForModifiedBuffer:s string
    ].
    ^ s
!

nameStringOrNil
    "a descriptive string of what this state shows"

    |s "codeView"|

    s := self rawNameStringOrNil.
    s notNil ifTrue:[
        self realModifiedState == true 
"/    ((codeView := self codeView) notNil
"/    and:[codeView modified]) 
        ifTrue:[
            ^ self colorizeForModifiedBuffer:s string
        ].
    ].
    ^ s
!

rawNameStringForCategory
    |categories theCategory|

    categories := self selectedCategories value.
    categories size == 1 ifTrue:[
        theCategory := categories first.
        theCategory notNil ifTrue:[
            ^ theCategory string, ' [Category]'
        ].
    ].
    ^ nil

    "Created: / 18.8.2000 / 19:42:42 / cg"
!

rawNameStringForNameSpace
    |namespaces theNamespace nsName s|

    namespaces := self selectedNamespaces value.
    namespaces size == 1 ifTrue:[
        theNamespace := namespaces first
    ].
    theNamespace notNil ifTrue:[
        theNamespace isNameSpace ifTrue:[
            nsName := theNamespace name
        ] ifFalse:[
            nsName := theNamespace
        ].
        s := nsName , ' [NameSpace]'.
        (self isNameSpaceBrowser or:[self isNameSpaceFullBrowser]) ifTrue:[
            ^ LabelAndIcon icon:(NewSystemBrowser nameSpaceIcon) string:s.
        ].
        ^ s
    ].
    ^ nil

    "Created: / 18.8.2000 / 20:15:02 / cg"
!

rawNameStringForProject
    |projects theProject s|

    projects := self selectedProjects value.
    projects size == 1 ifTrue:[
        theProject := projects first
    ].
    theProject notNil ifTrue:[
        s := theProject , ' [Project]'.
        (self isProjectBrowser or:[self isProjectFullBrowser]) ifTrue:[
            ^ LabelAndIcon icon:(NewSystemBrowser packageIcon) string:s.
        ].
        ^ s
    ].
    ^ nil

    "Created: / 18.8.2000 / 20:18:34 / cg"
!

rawNameStringOrNil
    "a descriptive string of what this state shows; nil, if nothing is selected"

    ^ self rawNameStringOrNilWantShort:false
!

rawNameStringOrNilWantShort:shortName
    "a descriptive string of what this state shows; nil, if nothing is selected"

    |lbl nr numClasses numMethods numCategories cats classes theClass   
     "protocols theProtocol" 
     methods theSingleMethod projects theProject longName nm methodName suffix cls|

    browserLabel notNil ifTrue:[
        "/ add the number of selected methods
        ((canvasType == #singleFullProtocolBrowserSpec)
        or:[canvasType == #methodListBrowserSpec]) ifTrue:[
            nr := self selectedMethods value size.
            nr > 5 ifTrue:[
                ^ browserLabel string , ' - ' , nr printString , ' methods'
            ].
        ].
        ^ browserLabel
    ].

    suffix := ''.

    self isProtocolOrFullProtocolBrowser ifTrue:[
        lbl := self rawNameStringForProject.
        lbl notNil ifTrue:[^ lbl].
        suffix := ' [Protocol]'.
    ].

    self isCategoryBrowser ifTrue:[
        lbl := self rawNameStringForCategory.
        lbl notNil ifTrue:[^ lbl].
        suffix := ' [Category]'.
    ].

    self isNameSpaceBrowser ifTrue:[
        lbl := self rawNameStringForNameSpace.
        lbl notNil ifTrue:[^ lbl].
        suffix := ' [NameSpace]'.
    ].

    self isProjectBrowser ifTrue:[
        projects := self selectedProjects value.
        projects size == 1 ifTrue:[
            theProject := projects first
        ].
        suffix := ' [Project]'.
        theProject notNil ifTrue:[
            ^ theProject , suffix
        ]
    ].

    classes := self selectedClasses value.
    classes size == 1 ifTrue:[
        theClass := classes first.
        theClass notNil ifTrue:[
            theClass := theClass theNonMetaclass
        ]
    ].

    self isClassBrowser ifTrue:[
        suffix := ' [Class]'.
        theClass notNil ifTrue:[
            ^ theClass name , suffix
        ]
    ].

"/    protocols := self selectedProtocols value.
"/    protocols size == 1 ifTrue:[
"/        theProtocol := protocols first
"/    ].

    methods := self selectedMethods value.
    methods size == 1 ifTrue:[
        theSingleMethod := methods first
    ].

    theSingleMethod notNil ifTrue:[
        methodName := theSingleMethod selector.
        methodName isSymbol ifTrue:[methodName := methodName selector].
        theSingleMethod isJavaMethod ifTrue:[
            methodName := theSingleMethod printStringForBrowserWithSelector:methodName.
        ].
    ].

    self isMethodBrowser ifTrue:[
        suffix := ' [Selector]'.

        theSingleMethod notNil ifTrue:[
            theSingleMethod mclass isNil ifTrue:[
                ^ '???'
            ].
            ^ theSingleMethod mclass name , ' ' , methodName , suffix
        ]
    ].

    self isCategoryBrowser ifTrue:[
        suffix :=  ' [Category]'.
    ] ifFalse:[
        self isFullClassSourceBrowser ifTrue:[
            suffix :=  ' [Full]'.
        ] ifFalse:[
            self isClassDocumentationBrowser ifTrue:[
                suffix :=  ' [Doc]'.
            ] ifFalse:[
                self isProjectBrowser ifTrue:[
                    suffix :=  ' [Project]'.
                ]
            ]
        ]
    ].

    nm := nil.
    (numClasses := classes size) > 0 ifTrue:[
        numClasses > 1 ifTrue:[
            methods size > 0 ifTrue:[
                theSingleMethod notNil ifTrue:[
                    cls := theSingleMethod mclass.
                    cls isNil ifTrue:[ 
                        "/ oops - unbound
                        nm := '???'
                    ] ifFalse:[
                        longName := nm := cls nameInBrowser.
                        shortName ifTrue:[
                            nm := cls nameWithoutPrefix.
                            cls isPrivate ifTrue:[
                                nm := ':' , nm
                            ]
                        ].
                    ].
                    nm := nm , ' ', (methodName ? '???')
                ] ifFalse:[
                    nm := methods size printString , ' methods'.
                    numClasses := (methods collect:[:each | each mclass] as:IdentitySet) size.
                    numClasses > 1 ifTrue:[
                        nm := nm , ' in ' , numClasses printString , ' classes'.
                    ].
                ].
                ^ nm , suffix.
            ].

            nm := numClasses printString , ' classes in '.
            "/ cats := self selectedCategories value
            cats := classes collect:[:each | each category] as:Set.
            (numCategories := cats size) == 1 ifTrue:[
                nm := nm , cats first
            ] ifFalse:[
                nm := nm , numCategories printString , ' categories'
            ]
        ] ifFalse:[
            cls := theClass theNonMetaclass.
            longName := nm := cls nameInBrowser.
            shortName ifTrue:[
                nm := cls nameWithoutPrefix.
                cls isPrivate ifTrue:[
                    nm := ':' , nm
                ]
            ].
            methods := self selectedMethods value.
            (numMethods := methods size) > 0 ifTrue:[
                numMethods == 1 ifTrue:[
                    theSingleMethod := methods first.
                    nm := nm , ' ', (methodName ? '???')
                ] ifFalse:[
                    nm := numMethods printString , ' methods in ' , nm
                ]
            ]
        ]
    ] ifFalse:[
        (self isNameSpaceBrowser 
        or:[self isNameSpaceFullBrowser
        or:[organizerMode value == OrganizerCanvas organizerModeNamespace]]) ifTrue:[
            lbl := self rawNameStringForNameSpace.
            lbl notNil ifTrue:[^ lbl].
            suffix := ' [NameSpace]'.
        ] ifFalse:[
            (self isProjectBrowser 
            or:[self isProjectFullBrowser
            or:[organizerMode value == OrganizerCanvas organizerModeProject]]) ifTrue:[
                lbl := self rawNameStringForProject.
                lbl notNil ifTrue:[^ lbl].
                suffix := ' [Project]'.
            ] ifFalse:[
                cats := self selectedCategories value.
                cats size == 1 ifTrue:[
                    nm := (cats first ? '') string
                ]
            ]
        ].
    ].
    nm isNil ifTrue:[ ^ nil ].
    ^ nm , suffix.

    "Created: / 11-02-2000 / 13:32:16 / cg"
    "Modified: / 18-08-2000 / 21:06:35 / cg"
    "Modified: / 20-07-2010 / 10:52:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

shortNameString
    "a descriptive string of what this state shows"

    |s|

    s := (self rawNameStringOrNilWantShort:true) ? 'nothing selected'.

    (self realModifiedState == true) ifTrue:[
        ^ self colorizeForModifiedBuffer:s string
    ].
    ^ s
! !

!NavigationState methodsFor:'queries'!

isCategoryBrowser
    ^ canvasType == #categoryBrowserSpec
      or:[ canvasType == #singleCategoryBrowserSpec
      or:[ canvasType == #multipleCategoryBrowserSpec ]]

    "Modified: / 25.2.2000 / 01:17:02 / cg"
!

isChainBrowser
    ^ canvasType == #chainBrowserSpec    
!

isCheckOutputBrowser
    ^ canvasType == #multipleClassWithInfoAndMethodWithInfoBrowserSpec
      or:[canvasType == #multipleMethodWithInfoBrowserSpec
      or:[canvasType == #multipleClassWithInfoBrowserSpec]]
!

isClassBrowser
    ^ canvasType == #classBrowserSpec
      or:[ canvasType == #singleClassBrowserSpec
      or:[ canvasType == #multipleClassBrowserSpec ]]

    "Modified: / 25.2.2000 / 00:38:07 / cg"
!

isClassDocumentationBrowser
    ^ canvasType == #classDocumentationBrowserSpec

    "Created: / 24.2.2000 / 14:54:40 / cg"
!

isClassExtensionBrowser
    ^ canvasType == #multipleClassExtensionBrowserSpec

    "Created: / 24.2.2000 / 14:54:40 / cg"
!

isFullBrowser
    ^ canvasType == #fullBrowserSpec
!

isFullClassSourceBrowser
    ^ canvasType == #fullClassSourceBrowserSpec

    "Created: / 24.2.2000 / 14:54:40 / cg"
!

isFullProtocolBrowser
    ^ canvasType == #singleFullProtocolBrowserSpec
      or:[ canvasType == #multipleFullProtocolBrowserSpec ]

    "Created: / 24.2.2000 / 21:32:09 / cg"
    "Modified: / 25.2.2000 / 03:11:00 / cg"
!

isLintResultBrowser
    ^ canvasType == #smallLintByRuleResultBrowserSpec
!

isMethodBrowser
    ^ canvasType == #methodListBrowserSpec
      or:[ canvasType == #singleMethodBrowserSpec
      or:[ canvasType == #multipleMethodBrowserSpec
      or:[ canvasType == #multipleMethodWithInfoBrowserSpec ]]]

    "Modified: / 1.3.2000 / 13:35:12 / cg"
!

isMethodListBrowser
    canvasType == #methodListBrowserSpec ifTrue:[^ true].
    canvasType == #multipleMethodBrowserSpec ifTrue:[^ true].
    canvasType == #singleProtocolBrowserSpec ifTrue:[^ true].
    ^ false.
!

isNameSpaceBrowser
    ^ canvasType == #singleNameSpaceBrowserSpec
      or:[ canvasType == #multipleNameSpaceBrowserSpec]

    "Modified: / 18.8.2000 / 16:12:34 / cg"
!

isNameSpaceFullBrowser
    ^ canvasType == #singleNameSpaceFullBrowserSpec
      or:[ canvasType == #multipleNameSpaceFullBrowserSpec ]

    "Created: / 18.8.2000 / 14:58:36 / cg"
!

isProjectBrowser
    ^ canvasType == #singleProjectBrowserSpec
      or:[ canvasType == #multipleProjectBrowserSpec ]

    "Created: / 24.2.2000 / 21:32:09 / cg"
    "Modified: / 25.2.2000 / 03:11:00 / cg"
!

isProjectFullBrowser
    ^ canvasType == #singleProjectFullBrowserSpec
      or:[ canvasType == #multipleProjectFullBrowserSpec ]

    "Created: / 18.8.2000 / 19:02:49 / cg"
!

isProtocolBrowser
    ^ canvasType == #singleProtocolBrowserSpec
      or:[ canvasType == #multipleProtocolBrowserSpec ]

    "Created: / 24.2.2000 / 21:32:09 / cg"
    "Modified: / 25.2.2000 / 03:11:00 / cg"
!

isProtocolOrFullProtocolBrowser
    ^ self isProtocolBrowser
      or:[ self isFullProtocolBrowser ]
!

isSingleCategoryBrowser
    ^ canvasType == #singleCategoryBrowserSpec    
!

isSingleClassBrowser
    ^ canvasType == #singleClassBrowserSpec    
!

isSingleFullProtocolBrowser
    ^ canvasType == #singleFullProtocolBrowserSpec    
!

isSingleMethodBrowser
    ^ canvasType == #singleMethodBrowserSpec

    "Created: / 1.3.2000 / 13:35:52 / cg"
!

isSingleNamespaceBrowser
    ^ canvasType == #singleNameSpaceBrowserSpec
!

isSingleNamespaceFullBrowser
    ^ canvasType == #singleNameSpaceFullBrowserSpec
!

isSingleProjectBrowser
    ^ canvasType == #singleProjectBrowserSpec
      or:[ canvasType == #singleProjectFullBrowserSpec ]

    "Created: / 24.2.2000 / 21:32:09 / cg"
    "Modified: / 25.2.2000 / 03:11:00 / cg"
!

isSingleProjectFullBrowser
    ^ canvasType == #singleProjectFullBrowserSpec

    "Created: / 24.2.2000 / 21:32:09 / cg"
    "Modified: / 25.2.2000 / 03:11:00 / cg"
!

isSingleProtocolBrowser
    ^ canvasType == #singleProtocolBrowserSpec    
!

isVersionDiffBrowser
    ^ canvasType == #multipleClassRepositoryDiffBrowserSpec
! !

!NavigationState class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libtool/Tools_NavigationState.st,v 1.54 2014-02-05 19:08:56 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/Tools_NavigationState.st,v 1.54 2014-02-05 19:08:56 cg Exp $'
!

version_SVN
    ^ '$Id: Tools_NavigationState.st,v 1.54 2014-02-05 19:08:56 cg Exp $'
! !


NavigationState initialize!