<commit_before>SystemWindow subclass: GCRepositoryBrowser [
    | repositoryIndex selectedClassIndex classList selectedClasses |
    
    <comment: nil>
    <category: 'Gitocello-Morphic'>

    GCRepositoryBrowser class >> open [
	(self new)
	    createWindow;
	    openInWorld
    ]

    classList [
	classList ifNil: 
		[classList := GCRegistry repositories ifEmpty: [#()]
			    ifNotEmpty: [(GCRegistry at: self selectedRepository) classes]].
	^classList
    ]

    classListMap [
	^self classList collect: [:class | self packageClasses includes: class]
    ]

    contents [
	^self selectedRepository
    ]

    createWindow [
	| packageList classList repositoryUrlEntry fileOutCommand |
	fileOutCommand := PluggableButtonMorph 
		    on: self
		    getState: nil
		    action: #fileOut
		    label: #fileOutButtonString.
	repositoryUrlEntry := (PluggableTextMorph 
		    on: self
		    text: #repositoryRoot
		    accept: #repositoryRoot:
		    readSelection: nil
		    menu: #annotationPaneMenu:shifted:)
		    hideScrollBarsIndefinitely;
		    yourself.
	(packageList := PluggableListMorph new) 
	    on: self
	    list: #repositoryList
	    selected: #repositoryIndex
	    changeSelected: #repositoryIndex:
	    menu: #memberMenu:shifted:
	    keystroke: nil.
	(classList := PluggableListMorphOfMany new) 
	    on: self
	    list: #classList
	    primarySelection: #selectedClassIndex
	    changePrimarySelection: #selectedClassIndex:
	    listSelection: #selectedClassesAt:
	    changeListSelection: #selectedClassesAt:put:
	    menu: #classMenu
	    keystroke: nil.
	repositoryUrlEntry color: self defaultBackgroundColor.
	classList color: self defaultBackgroundColor.
	packageList color: self defaultBackgroundColor.
	self addMorph: repositoryUrlEntry frame: (0 @ 0.01 corner: 0.8 @ 0.1).
	self addMorph: fileOutCommand frame: (0.8 @ 0.01 corner: 1.0 @ 0.1).
	self addMorph: packageList frame: (0 @ 0.1 corner: 0.5 @ 1.0).
	self addMorph: classList frame: (0.5 @ 0.1 corner: 1.0 @ 1.0).
	self setLabel: 'Package Git Repository Mirrors'
    ]

    fileOut [
	GCRegistry createFilesFor: self selectedRepository
    ]

    initialize [
	super initialize.
	self
	    repositoryIndex: 1;
	    selectedClassIndex: 1;
	    selectedClasses: self classListMap
    ]

    repositoryList [
	^GCRegistry repositories keys asOrderedCollection
    ]

    selectedClassesAt: anIndex [
	^selectedClasses at: anIndex
    ]

    selectedClassesAt: anIndex put: aValue [
	selectedClasses at: anIndex put: aValue = true.
	self
	    changed: #selectedClassIndex;
	    updatePackageClasses
    ]

    selectedRepository [
	^self repositoryList at: self repositoryIndex
    ]

    classList: anObject [
	"Set the value of classList"

	<category: 'accessing'>
	classList := anObject
    ]

    fileOutButtonString [
	<category: 'accessing'>
	^'Sync repository'
    ]

    packageClasses [
	<category: 'accessing'>
	^GCRegistry repositories ifEmpty: [#()]
	    ifNotEmpty: [(GCRegistry at: self selectedRepository) packageClasses]
    ]

    repositoryIndex [
	"Answer the value of repositoryIndex"

	<category: 'accessing'>
	^repositoryIndex
    ]

    repositoryIndex: anObject [
	"Set the value of repositoryIndex"

	<category: 'accessing'>
	repositoryIndex := anObject.
	classList := nil
    ]

    repositoryRoot [
	<category: 'accessing'>
	^GCRegistry repositoryRoot name
    ]

    repositoryRoot: aString [
	<category: 'accessing'>
	^GCRegistry repositoryRoot: aString
    ]

    selectedClassIndex [
	"Answer the value of selectedClassIndex"

	<category: 'accessing'>
	^selectedClassIndex
    ]

    selectedClassIndex: anObject [
	"Set the value of selectedClassIndex"

	<category: 'accessing'>
	selectedClassIndex := anObject
    ]

    selectedClasses [
	"Answer the value of selectedClasses"

	<category: 'accessing'>
	^selectedClasses
    ]

    selectedClasses: anObject [
	"Set the value of selectedClasses"

	<category: 'accessing'>
	selectedClasses := anObject
    ]

    updatePackageClasses [
	<category: 'accessing'>
	(GCRegistry at: self selectedRepository) packageClasses: (self classList 
		    select: [:class | self selectedClasses at: (self classList indexOf: class)])
    ]
]
<commit_msg>reorganize and fix the repo browser<commit_after>SystemWindow subclass: GCRepositoryBrowser [
    | repositoryIndex selectedClassIndex classList selectedClasses classListMorph packageListMorph |
    
    <comment: nil>
    <category: 'Gitocello-Morphic'>

    GCRepositoryBrowser class >> open [
	<category: 'instance creation'>
	(self new)
	    createWindow;
	    openInWorld
    ]

    classListMorph [
	<category: 'user interface'>
	^classListMorph ifNil: 
		[classListMorph := (PluggableListMorphOfMany 
			    on: self
			    list: #availableClasses
			    primarySelection: #selectedClassIndex
			    changePrimarySelection: #selectedClassIndex:
			    listSelection: #selectedClassesAt:
			    changeListSelection: #selectedClassesAt:put:
			    menu: nil)
			    color: self defaultBackgroundColor;
			    yourself]
    ]

    createWindow [
	<category: 'user interface'>
	self
	    addMorph: self repositoryUrlField frame: (0 @ 0.01 corner: 0.8 @ 0.1);
	    addMorph: self syncButton frame: (0.8 @ 0.01 corner: 1.0 @ 0.1);
	    addMorph: self packageListMorph frame: (0 @ 0.1 corner: 0.5 @ 1.0);
	    addMorph: self classListMorph frame: (0.5 @ 0.1 corner: 1.0 @ 1.0);
	    setLabel: 'Package Git Repository Mirrors'
    ]

    packageListMorph [
	<category: 'user interface'>
	^packageListMorph ifNil: 
		[packageListMorph := (PluggableListMorph 
			    on: self
			    list: #repositoryList
			    selected: #selectedRepositoryIndex
			    changeSelected: #selectedRepositoryIndex:)
			    color: self defaultBackgroundColor;
			    yourself]
    ]

    repositoryUrlField [
	<category: 'user interface'>
	^(PluggableTextMorph 
	    on: self
	    text: #repositoryRootPath
	    accept: #repositoryRootPath:)
	    hideScrollBarsIndefinitely;
	    color: self defaultBackgroundColor;
	    yourself
    ]

    syncButton [
	<category: 'user interface'>
	^PluggableButtonMorph 
	    on: self
	    getState: #syncButtonOn
	    action: #syncButtonAction
	    label: #syncButtonString
    ]

    repositoryList [
	<category: 'accessing'>
	^GCRegistry repositories keys asOrderedCollection
    ]

    selectedRepository [
	<category: 'accessing'>
	^self repositoryList at: self selectedRepositoryIndex
    ]

    selectedRepositoryIndex [
	"Answer the value of repositoryIndex"

	<category: 'accessing'>
	^repositoryIndex
    ]

    selectedRepositoryIndex: anObject [
	"Set the value of repositoryIndex"

	<category: 'accessing'>
	repositoryIndex := anObject.
	classList := nil.
	self
	    selectedClassIndex: 1;
	    selectedClasses: self currentlySelectedClasses;
	    changed: #selectedRepositoryIndex;
	    changed: #selectedClassesAt:;
	    changed: #availableClasses
    ]

    updatePackageClasses [
	<category: 'accessing'>
	(GCRegistry at: self selectedRepository) 
	    packageClasses: (self availableClasses 
		    select: [:class | self selectedClasses at: (self availableClasses indexOf: class)])
    ]

    repositoryRootPath [
	<category: 'accessing-registry-configuration'>
	^GCRegistry repositoryRoot name
    ]

    repositoryRootPath: aString [
	<category: 'accessing-registry-configuration'>
	^GCRegistry repositoryRoot: aString
    ]

    syncButtonAction [
	<category: 'accessing-buttons'>
	GCRegistry createFilesFor: self selectedRepository
    ]

    syncButtonOn [
	<category: 'accessing-buttons'>
	^GCRegistry repositories isEmpty not
    ]

    syncButtonString [
	<category: 'accessing-buttons'>
	^'Sync repository'
    ]

    availableClasses [
	<category: 'accessing-package-configuration'>
	classList ifNil: 
		[classList := GCRegistry repositories ifEmpty: [#()]
			    ifNotEmpty: [(GCRegistry at: self selectedRepository) classes]].
	^classList
    ]

    currentlySelectedClasses [
	<category: 'accessing-package-configuration'>
	^self availableClasses collect: [:cls | self packageClasses includes: cls]
    ]

    packageClasses [
	<category: 'accessing-package-configuration'>
	^GCRegistry repositories ifEmpty: [#()]
	    ifNotEmpty: [(GCRegistry at: self selectedRepository) packageClasses]
    ]

    selectedClassIndex [
	"Answer the value of selectedClassIndex"

	<category: 'accessing-package-configuration'>
	^selectedClassIndex
    ]

    selectedClassIndex: anObject [
	"Set the value of selectedClassIndex"

	<category: 'accessing-package-configuration'>
	selectedClassIndex := anObject.
	self changed: #selectedClassIndex
    ]

    selectedClasses [
	"Answer the value of selectedClasses"

	<category: 'accessing-package-configuration'>
	^selectedClasses
    ]

    selectedClasses: anObject [
	"Set the value of selectedClasses"

	<category: 'accessing-package-configuration'>
	selectedClasses := anObject
    ]

    selectedClassesAt: anIndex [
	<category: 'accessing-package-configuration'>
	^selectedClasses at: anIndex
    ]

    selectedClassesAt: anIndex put: aValue [
	<category: 'accessing-package-configuration'>
	selectedClasses at: anIndex put: aValue = true.
	self
	    changed: #selectedClassIndex;
	    changed: #availableClasses;
	    updatePackageClasses
    ]

    initialize [
	<category: 'initialization'>
	self
	    selectedRepositoryIndex: 1;
	    selectedClassIndex: 1;
	    selectedClasses: self currentlySelectedClasses.
	super initialize
    ]
]

{'fraction_non_alphanumeric': 0.08919291547353908, 'fraction_numerical': 0.007317849188673242, 'mean_word_length': 3.6729435084241824, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '495036', 'n_tokens_mistral': 2951, 'n_tokens_neox': 2742, 'n_words': 698}