Last active
May 28, 2025 14:30
-
-
Save iriyak/ecd5231cd8d67172270082bc7d53f2a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| P3ClientLoginPane subclass: #P3ClientLoginPane2 | |
| instanceVariableNames: 'name' | |
| classVariableNames: '' | |
| package: 'KIExtensionsForGToolkit4P3'! | |
| !P3ClientLoginPane2 methodsFor: 'as yet unclassified' stamp: 'GlamorousAuthor 5/27/2025 22:04'! | |
| nameDescription | |
| <magritteDescription> | |
| ^ MAStringDescription new | |
| priority: 100; | |
| label: 'Name'; | |
| accessor: #name; | |
| default: 'database'! ! | |
| !P3ClientLoginPane2 methodsFor: 'as yet unclassified' stamp: 'GlamorousAuthor 5/27/2025 22:04'! | |
| loadFromConfig: aConfig | |
| self name: aConfig key. | |
| #(host port user password database options ssl) | |
| do: [ :each | self perform: each asMutator with: (aConfig value at: each) ]! ! | |
| !P3ClientLoginPane2 methodsFor: 'as yet unclassified' stamp: 'GlamorousAuthor 5/28/2025 22:40'! | |
| loadFrom: p3Client | |
| self name: self defaultConfigHolder lastConfig key. | |
| super loadFrom: p3Client! ! | |
| !P3ClientLoginPane2 methodsFor: 'as yet unclassified' stamp: 'GlamorousAuthor 5/27/2025 22:04'! | |
| name: aString | |
| name := aString! ! | |
| !P3ClientLoginPane2 methodsFor: 'as yet unclassified' stamp: 'GlamorousAuthor 5/28/2025 22:48'! | |
| saveToDefaultConnection | |
| | configHolder connection config | | |
| configHolder := self defaultConfigHolder. | |
| connection := self defaultConnection. | |
| config := self name | |
| -> (Dictionary | |
| newFrom: {'host' -> self host. | |
| 'port' -> self port. | |
| 'client' -> self class. | |
| 'url' -> self url. | |
| 'user' -> self user. | |
| 'password' -> self password. | |
| 'database' -> self database. | |
| 'options' -> self options. | |
| 'ssl' -> self ssl}). | |
| configHolder lastConfig: config. | |
| configHolder configs at: config key put: config value. | |
| super saveToDefaultConnection! ! | |
| !P3ClientLoginPane2 methodsFor: 'as yet unclassified' stamp: 'GlamorousAuthor 5/27/2025 22:04'! | |
| name | |
| ^ name! ! | |
| !P3ClientLoginPane2 methodsFor: 'as yet unclassified' stamp: 'GlamorousAuthor 5/28/2025 22:35'! | |
| defaultConfigHolder | |
| ^ P3ConfigHolder uniqueInstance! ! | |
| Object subclass: #P3ConfigHolder | |
| instanceVariableNames: 'configs lastConfig' | |
| classVariableNames: 'uniqueInstance' | |
| package: 'KIExtensionsForGToolkit4P3'! | |
| !P3ConfigHolder methodsFor: 'KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/28/2025 22:50'! | |
| lastConfig | |
| ^ lastConfig! ! | |
| !P3ConfigHolder methodsFor: 'KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/26/2025 21:48'! | |
| configs | |
| ^ configs! ! | |
| !P3ConfigHolder methodsFor: 'KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/28/2025 23:17'! | |
| initialize | |
| configs := Dictionary new asValueHolder. | |
| lastConfig := 'database' -> Dictionary new! ! | |
| !P3ConfigHolder methodsFor: 'KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/26/2025 21:55'! | |
| gtConfigViewFor: aView | |
| "Copied from Dictionary>>#gtItemsFor:" | |
| <gtView> | |
| ^ aView columnedTree | |
| title: 'Configs'; | |
| priority: 8; | |
| items: [ self configs associations sort: (#key collatedBy: #asString) ]; | |
| children: [ :each | | |
| each value isDictionary | |
| ifTrue: [ each value associations sort: (#key collatedBy: #asString) ] | |
| ifFalse: [ (each value isArray and: [ each value allSatisfy: #isDictionary ]) | |
| ifTrue: [ each value collectWithIndex: [ :x :i | i -> x ] ] | |
| ifFalse: [ #() ] ] ]; | |
| column: 'Key' | |
| text: [ :assoc | assoc key ] | |
| weight: 2.0; | |
| column: '' | |
| stencil: [ :assoc | | |
| BrButton new | |
| aptitude: BrGlamorousButtonWithLabelAptitude; | |
| label: 'Save'; | |
| action: [ P3ClientLoginPane2 new | |
| loadFromConfig: assoc; | |
| saveToDefaultConnection ] ] | |
| weight: 0.8; | |
| column: 'Value' | |
| text: [ :assoc | assoc value ] | |
| weight: 9; | |
| contextItemLabel: 'Inspect key' | |
| action: [ :anElement :aTreeNode | anElement phlow spawnObject: aTreeNode value key ]; | |
| contextItemLabel: 'Inspect value' | |
| action: [ :anElement :aTreeNode | anElement phlow spawnObject: aTreeNode value value ]; | |
| contextItemLabel: 'Inspect association' | |
| action: [ :anElement :aTreeNode | anElement phlow spawnObject: aTreeNode value ]; | |
| contextItemLabel: 'Remove key and value' | |
| action: [ :anElement :aTreeNode | | |
| self configs removeKey: aTreeNode value key ifAbsent: [ "ignore" ]. | |
| anElement phlow contextMenuUpdateViewContent ]; | |
| send: [ :assoc "Implementation note: association sorting uses #collatedBy: to avoid a 'Symbol DNU value: value: error'" | assoc value ]; | |
| updateWhen: ValueChanged in: [ self configs announcer ]; | |
| actionUpdateButton! ! | |
| !P3ConfigHolder methodsFor: 'KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/28/2025 22:33'! | |
| lastConfig: aConfig | |
| lastConfig := aConfig! ! | |
| "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! | |
| P3ConfigHolder class | |
| instanceVariableNames: ''! | |
| !P3ConfigHolder class methodsFor: 'KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/26/2025 21:48'! | |
| uniqueInstance | |
| ^ uniqueInstance ifNil: [ uniqueInstance := self new ]! ! | |
| !P3ConfigHolder class methodsFor: 'KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/26/2025 21:49'! | |
| gtConfigViewFor: aView | |
| <gtClassView> | |
| ^ aView forward | |
| title: 'Configs'; | |
| priority: 8; | |
| object: [ self uniqueInstance ]; | |
| view: #gtConfigViewFor:! ! | |
| 'From Pharo11.0.0 of 7 March 2024 [Build information: Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)] on 28 May 2025 at 11:25:11.582 pm'! | |
| !GtP3ConnectionManager methodsFor: '*KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/24/2025 23:48'! | |
| 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: '' ]; | |
| 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 28 May 2025 at 11:25:11.582 pm'! | |
| !P3Client class methodsFor: '*KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/26/2025 21:56'! | |
| gtViewAllInstancesIn: composite | |
| " | |
| Remarks | |
| 1. 'composite columnedList' creates a GtPhlowColumnedListView. | |
| 2. The view collects P3Clients by 'self allInstances'. So not performant. | |
| 3. Start/stop fails while user/password/database is left as blank. | |
| " | |
| <gtClassView> | |
| ^ composite columnedList | |
| title: 'Instances'; | |
| 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 28 May 2025 at 11:25:11.582 pm'! | |
| !GtP3ConnectionManager class methodsFor: '*KIExtensionsForGToolkit4P3' 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 28 May 2025 at 11:25:11.582 pm'! | |
| !GtP3ConnectionManager class methodsFor: '*KIExtensionsForGToolkit4P3' 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 28 May 2025 at 11:25:11.582 pm'! | |
| !GtP3ConnectionManager class methodsFor: '*KIExtensionsForGToolkit4P3' stamp: 'GlamorousAuthor 5/26/2025 20:38'! | |
| gtDefaultConnectionFor: aView | |
| <gtClassView> | |
| ^ aView forward | |
| title: 'Connection'; | |
| priority: 8; | |
| object: [ self uniqueInstance ]; | |
| view: #gtDefaultConnectionFor:! ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment