<commit_before>Class {
	#name : #RTAbstractSmartBrowser,
	#superclass : #RTObject,
	#instVars : [
		'statusBar',
		'currentSelection',
		'view'
	],
	#classInstVars : [
		'icon'
	],
	#category : #'Roassal2-DataStudio'
}

{ #category : #adding }
RTAbstractSmartBrowser >> addClasses: classes [
	"Add a list of Pharo classes"

	| es |
	es := self shapeForClass elementsOn: classes.
	es @ RTPopup @ RTDraggable.
	view addAll: es.
	RTEdge
		buildEdgesFromObjects: classes
		from: #superclass
		to: #yourself
		using: (RTLine new attachPoint: RTVerticalAttachPoint instance)
		inView: view.	"We look for the hierarchy root"	"	es do: [ :el | 
		(classes includes: el model superclass)
			ifFalse: [ el @ RTLabelled ] ].
"
	es
		when: TRMouseClick
		do: [ :e | 
			(e element attributes includesKey: #isExpanded)
				ifTrue: [ self shrinkClassElement: e element ]
				ifFalse: [ self expandClassElement: e element ].
			self applyLayout: RTTreeLayout new ].
	self setStatusBar: classes size printString , ' added classes'.
	currentSelection := view elementsFromModels: classes.
	self applyLayout: RTTreeLayout new
]

{ #category : #adding }
RTAbstractSmartBrowser >> addClassesFromRegExp: regExp [
	| classes |
	classes := self getClassesMatching: regExp.
	self addClasses: classes
]

{ #category : #'UI effects' }
RTAbstractSmartBrowser >> addInteractionToMethods: methodElements [
	methodElements @ (RTPopup new text: [ :cm | cm selector asString ]).
	methodElements
		when: TRMouseClick
		do: [ :event | 
			self clickOnMethod: event	"model := Pitekun new view: view; addCompiledMethod: event element model.
			element := view elementFromModel: model. " ]
]

{ #category : #adding }
RTAbstractSmartBrowser >> addPackagesFromRegExp: regExp [
	| paks |
	paks := RPackageOrganizer default packages select: [ :p | regExp match: p name ].
	self addClasses: ((paks flatCollect: #definedClasses) reject: #isTrait )
]

{ #category : #'UI effects' }
RTAbstractSmartBrowser >> applyLayout: layout [
	layout
		translator: self translator;
		on: self currentSelection
]

{ #category : #hooks }
RTAbstractSmartBrowser >> clickOnClass: event [
	"To be overridden"


]

{ #category : #hooks }
RTAbstractSmartBrowser >> clickOnMethod: event [
	"To be overridden"<commit_msg>0.255 : minor fix<commit_after>Class {
	#name : #RTAbstractSmartBrowser,
	#superclass : #RTObject,
	#instVars : [
		'statusBar',
		'currentSelection',
		'view'
	],
	#classInstVars : [
		'icon'
	],
	#category : #'Roassal2-DataStudio'
}

{ #category : #adding }
RTAbstractSmartBrowser >> addClasses: classes [
	"Add a list of Pharo classes"

	| es |
	es := self shapeForClass elementsOn: classes.
	es @ RTPopup @ RTDraggable.
	view addAll: es.
	RTEdge
		buildEdgesFromObjects: classes
		from: #superclass
		to: #yourself
		using: (RTLine new attachPoint: RTVerticalAttachPoint instance)
		inView: view.	"We look for the hierarchy root"	"	es do: [ :el | 
		(classes includes: el model superclass)
			ifFalse: [ el @ RTLabelled ] ].
"
	es
		when: TRMouseClick
		do: [ :e | 
			(e element attributes includesKey: #isExpanded)
				ifTrue: [ self shrinkClassElement: e element ]
				ifFalse: [ self expandClassElement: e element ].
			self applyLayout: RTTreeLayout new ].
	self setStatusBar: classes size printString , ' added classes'.
	currentSelection := view elementsFromModels: classes.
	self applyLayout: RTTreeLayout new
]

{ #category : #adding }
RTAbstractSmartBrowser >> addClassesFromRegExp: regExp [
	| classes |
	classes := self getClassesMatching: regExp.
	self addClasses: classes
]

{ #category : #'UI effects' }
RTAbstractSmartBrowser >> addInteractionToMethods: methodElements [
	methodElements @ (RTPopup new text: [ :cm | cm selector asString ]).
	methodElements
		when: TRMouseClick
		do: [ :event | 
			self clickOnMethod: event ]
]

{ #category : #adding }
RTAbstractSmartBrowser >> addPackagesFromRegExp: regExp [
	| paks |
	paks := RPackageOrganizer default packages select: [ :p | regExp match: p name ].
	self addClasses: ((paks flatCollect: #definedClasses) reject: #isTrait )
]

{ #category : #'UI effects' }
RTAbstractSmartBrowser >> applyLayout: layout [
	layout
		translator: self translator;
		on: self currentSelection
]

{ #category : #hooks }
RTAbstractSmartBrowser >> clickOnClass: event [
	"To be overridden"


]

{ #category : #hooks }
RTAbstractSmartBrowser >> clickOnMethod: event [
	"To be overridden"
{'fraction_non_alphanumeric': 0.10979498861047836, 'fraction_numerical': 0.001366742596810934, 'mean_word_length': 4.4344059405940595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '7140632', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1431, 'n_words': 402}