Skip to content

Instantly share code, notes, and snippets.

@iriyak
Created May 24, 2025 13:28
Show Gist options
  • Save iriyak/cb2b6f8373c43d11ca19ae770f210089 to your computer and use it in GitHub Desktop.
Save iriyak/cb2b6f8373c43d11ca19ae770f210089 to your computer and use it in GitHub Desktop.
'From Pharo11.0.0 of 7 March 2024 [Build information: Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)] on 24 May 2025 at 10:24:50.586 pm'!
!Behavior methodsFor: '*KIExtensionsForGt' stamp: 'GlamorousAuthor 5/24/2025 20:22'!
gtMyOverviewFor: aView
<gtClassView>
^ aView explicit
title: 'Overview';
tooltip: 'Overview';
priority: 1;
disableAsync;
stencil: [ | left right contentBuilder labelBuilder className |
contentBuilder := [ BlElement new
layout: BlLinearLayout vertical;
constraintsDo: [ :c |
c vertical matchParent.
c horizontal matchParent ] ].
labelBuilder := [ :s |
BrLabel new
aptitude: (BrGlamorousLabelAptitude new
foreground: Color veryVeryDarkGray;
fontSize: 16;
bold);
hMatchParent;
text: s asRopedText ].
className := self gtDisplayString , ' class'.
left := contentBuilder value
addChildren: {labelBuilder value: 'Comments for ' , className.
GtInspector forObject: self viewSelector: #gtCoderLepiterCommentsFor:.
labelBuilder value: 'References for ' , className.
GtInspector forObject: self viewSelector: #gtAllReferencesFor:.
labelBuilder value: 'Examples for ' , className.
GtInspector forObject: self viewSelector: #gtExamplesFor:context:}.
right := contentBuilder value
addChildren: {labelBuilder value: 'Methods for ' , className.
GtInspector
forObject: self
viewSelector: #gtCoderStreamingMethodsFor:context:}.
BrHorizontalPane new
matchParent;
addChildren: {left.
right} ]! !
'From Pharo11.0.0 of 7 March 2024 [Build information: Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)] on 24 May 2025 at 10:24:50.588 pm'!
!GtP3ConnectionManager methodsFor: '*KIExtensionsForGt' stamp: 'GlamorousAuthor 5/24/2025 22:19'!
gtDefaultConnectionFor: aView
<gtView>
^ aView columnedList
title: 'Connection';
priority: 0;
items: [ {self defaultConnection} ];
column: ''
stencil: [ :e |
BrButton new
aptitude: BrGlamorousButtonWithIconAptitude;
icon: BrGlamorousVectorIcons shutdown;
label: 'Start/stop PostgreSQL client connection';
action: [ e isConnected ifTrue: [ e close ] ifFalse: [ e ensureConnected ] ] ]
weight: 0.75;
column: 'connected'
text: [ :e |
e isConnected
in: [ :boolean |
boolean asRopedText
foreground: (boolean
ifTrue: BrGlamorousColors successBorderColor
ifFalse: BrGlamorousColors errorBorderColor) ] ];
column: 'session' text: [ :e | e session ifNil: '' ];
column: 'host' text: [ :e | e host ifNil: '' ];
column: 'port' text: [ :e | e port ifNil: '' ];
column: 'client' text: [ :e | e class ifNil: '' ];
column: 'url'
text: [ :e | e url ifNil: '' ]
weight: 3;
column: 'user' text: [ :e | e user ifNil: '' ];
column: 'password' text: [ :e | e password ifNil: '' ];
column: 'database' text: [ :e | e database ifNil: '' ];
column: 'ssl' text: [ :e | e isSSL ifNil: '' ];
column: 'options' text: [ :e | e startupOptions ifNil: '' ];
actionUpdateButton! !
'From Pharo11.0.0 of 7 March 2024 [Build information: Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)] on 24 May 2025 at 10:24:50.59 pm'!
!P3Client class methodsFor: '*KIExtensionsForGt' stamp: 'GlamorousAuthor 5/24/2025 20:17'!
gtViewAllP3ClientsIn: composite
"
Remarks
1. 'composite columnedList' creates a GtPhlowColumnedListView.
2. The view collects P3Clients by 'self allInstances'. So not performant.
3. Start/stop button doesn't trigger refreshing this custom view.
4. Start/stop fails while user/password/database is left as blank.
"
<gtClassView>
^ composite columnedList
title: 'Clients';
priority: 8;
items: [ self allInstances ];
column: ''
stencil: [ :e |
BrButton new
aptitude: BrGlamorousButtonWithIconAptitude;
icon: BrGlamorousVectorIcons shutdown;
label: 'Start/stop PostgreSQL client connection';
action: [ e isConnected ifTrue: [ e close ] ifFalse: [ e ensureConnected ] ] ]
weight: 0.75;
column: 'connected'
text: [ :e |
e isConnected
in: [ :boolean |
boolean asRopedText
foreground: (boolean
ifTrue: BrGlamorousColors successBorderColor
ifFalse: BrGlamorousColors errorBorderColor) ] ];
column: 'session' text: [ :e | e session ifNil: '' ];
column: 'host' text: [ :e | e host ifNil: '' ];
column: 'port' text: [ :e | e port ifNil: '' ];
column: 'client' text: [ :e | e class ifNil: '' ];
column: 'url'
text: [ :e | e url ifNil: '' ]
weight: 3;
column: 'user' text: [ :e | e user ifNil: '' ];
column: 'password' text: [ :e | e password ifNil: '' ];
column: 'database' text: [ :e | e database ifNil: '' ];
column: 'ssl' text: [ :e | e isSSL ifNil: '' ];
column: 'options' text: [ :e | e startupOptions ifNil: '' ];
updateWhen: P3ConnectionClosedEvent in: [ P3LogEvent announcer ];
updateWhen: P3ConnectionEstablishedEvent in: [ P3LogEvent announcer ];
actionUpdateButton! !
'From Pharo11.0.0 of 7 March 2024 [Build information: Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)] on 24 May 2025 at 10:24:50.592 pm'!
!GtP3ConnectionManager class methodsFor: '*KIExtensionsForGt' stamp: 'GlamorousAuthor 5/24/2025 22:18'!
initialize
"self initialize"
self environment
at: #SessionManager
ifPresent: [ :manager | manager default registerNetworkClassNamed: self name ]
ifAbsent: [ Smalltalk addToStartUpList: self ]! !
'From Pharo11.0.0 of 7 March 2024 [Build information: Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)] on 24 May 2025 at 10:24:50.593 pm'!
!GtP3ConnectionManager class methodsFor: '*KIExtensionsForGt' stamp: 'GlamorousAuthor 5/24/2025 22:18'!
startUp
uniqueInstance
ifNotNil: [ uniqueInstance defaultConnection
ifNotNil: [ :connection |
connection close.
P3SCRAM reset ] ]! !
'From Pharo11.0.0 of 7 March 2024 [Build information: Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)] on 24 May 2025 at 10:24:50.594 pm'!
!GtP3ConnectionManager class methodsFor: '*KIExtensionsForGt' stamp: 'GlamorousAuthor 5/24/2025 22:18'!
gtDefaultConnectionFor: aView
<gtClassView>
^ aView forward
title: 'Connection';
priority: 0;
object: [ self uniqueInstance ];
view: #gtDefaultConnectionFor:! !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment