From 69b540707a340ee7af1a01ebb972158d6ca1cfbd Mon Sep 17 00:00:00 2001 From: Sven Van Caekenberghe Date: Tue, 7 Nov 2023 10:07:41 +0100 Subject: [PATCH 1/2] Add ZTeamCoordinator --- .../ZTimestamp-GT/ZTeamCoordinator.class.st | 118 ++++++++++++++++++ .../ZTeamCoordinatorMember.class.st | 77 ++++++++++++ .../ZTimestamp-GT/ZTimezone.extension.st | 2 +- 3 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 repository/ZTimestamp-GT/ZTeamCoordinator.class.st create mode 100644 repository/ZTimestamp-GT/ZTeamCoordinatorMember.class.st diff --git a/repository/ZTimestamp-GT/ZTeamCoordinator.class.st b/repository/ZTimestamp-GT/ZTeamCoordinator.class.st new file mode 100644 index 0000000..e7360d5 --- /dev/null +++ b/repository/ZTimestamp-GT/ZTeamCoordinator.class.st @@ -0,0 +1,118 @@ +" +I am ZTeamCoordinator, a tool to coordinate team members working in different timezones. + +I hold a list of ZTeamCoordinatorMembers, each with a name and timezone. + +I have a GT view that shows the details and differences of each member with respect to the current timezone of the image. + +Try the example + + ZTeamCoordinator feenk + +To set the current timezone + + ZTimezone current: (ZTimezone id: #'America/New_York'). + +" +Class { + #name : #ZTeamCoordinator, + #superclass : #Object, + #instVars : [ + 'members', + 'name' + ], + #category : #'ZTimestamp-GT' +} + +{ #category : #accessing } +ZTeamCoordinator class >> feenk [ + + | team | + team := self new. + team name: 'feenk'. + self feenkTeamSpecification do: [ :each | + | member | + member := ZTeamCoordinatorMember new + name: each first; + timezone: (ZTimezone id: each second); + yourself. + team addMember: member ]. + ^ team +] + +{ #category : #accessing } +ZTeamCoordinator class >> feenkTeamSpecification [ + ^ #( + (alistair 'Europe/Prague') + (andrei 'Europe/Zurich') + (edward 'America/Toronto') + (iona 'Europe/Zurich') + (john 'America/Chicago') + (juraj 'America/Santiago') + (doru 'Europe/Zurich') + (aliaksei 'Europe/Zurich') + (don 'America/Chicago') + (manuel 'Europe/Zurich') + (oscar 'Europe/Zurich') + (veit 'Europe/Berlin') + (sven 'Europe/Brussels') +) +] + +{ #category : #accessing } +ZTeamCoordinator >> addMember: member [ + self members add: member +] + +{ #category : #accessing } +ZTeamCoordinator >> gtViewMembersFor: aView [ + + | now | + now := ZTimestamp now. + ^ aView columnedList + title: 'Members'; + items: (self members sorted: #name ascending); + column: 'Name' text: [ :each | each name ]; + column: 'Timezone' text: [ :each | each timezone id ]; + column: 'Date' text: [ :each | + (ZTimestampFormat fromString: '2001-02-03') + timezone: each timezone; + format: now ]; + column: 'Clock' text: [ :each | + (ZTimestampFormat fromString: '16:05') + timezone: each timezone; + format: now ]; + column: 'Offset' text: [ :each | + (ZTimestampFormat fromString: '+00:00') + timezone: each timezone; + format: now ]; + column: 'Difference' text: [ :each | + | difference | + difference := (each timezone offsetForTimestamp: now) + - (ZTimezone current offsetForTimestamp: now). + difference isZero + ifTrue: [ 0 ] + ifFalse: [ difference humanReadablePrintString ] ] +] + +{ #category : #accessing } +ZTeamCoordinator >> members [ + ^ members ifNil: [ members := OrderedCollection new ] +] + +{ #category : #accessing } +ZTeamCoordinator >> name [ + ^ name +] + +{ #category : #accessing } +ZTeamCoordinator >> name: anObject [ + name := anObject +] + +{ #category : #accessing } +ZTeamCoordinator >> printOn: stream [ + super printOn: stream. + self name ifNotNil: [ + stream nextPut: $(; print: self name; nextPut: $) ] +] diff --git a/repository/ZTimestamp-GT/ZTeamCoordinatorMember.class.st b/repository/ZTimestamp-GT/ZTeamCoordinatorMember.class.st new file mode 100644 index 0000000..9e2fdb9 --- /dev/null +++ b/repository/ZTimestamp-GT/ZTeamCoordinatorMember.class.st @@ -0,0 +1,77 @@ +" +I am ZTeamCoordinatorMember. + +I am used together with ZTeamCoordinator. + +I hold a name and timezone (ZTimezone). +" +Class { + #name : #ZTeamCoordinatorMember, + #superclass : #Object, + #instVars : [ + 'name', + 'timezone' + ], + #category : #'ZTimestamp-GT' +} + +{ #category : #accessing } +ZTeamCoordinatorMember class >> example [ + + ^ self new + name: 'sven'; + timezone: (ZTimezone id: 'Europe/Brussels'); + yourself +] + +{ #category : #accessing } +ZTeamCoordinatorMember >> gtViewDetailsIn: composite [ + + | now difference | + now := ZTimestamp now. + difference := (self timezone offsetForTimestamp: now) + - (ZTimezone current offsetForTimestamp: now). + ^ composite columnedList + title: 'Details'; + items: [ { + ('name' -> self name). + ('timezone' -> self timezone id). + ('clock' -> ((ZTimestampFormat fromString: '16:05') + timezone: self timezone; + format: now )). + ('offset' -> ((ZTimestampFormat fromString: 'GMT+00:00') + timezone: self timezone; + format: now)). + ('difference' -> (difference isZero + ifTrue: [ 0 ] + ifFalse: [ difference humanReadablePrintString ]))} ]; + column: 'Key' text: #key; + column: 'Value' text: #value; + send: #value +] + +{ #category : #accessing } +ZTeamCoordinatorMember >> name [ + ^ name +] + +{ #category : #accessing } +ZTeamCoordinatorMember >> name: anObject [ + name := anObject +] + +{ #category : #printing } +ZTeamCoordinatorMember >> printOn: stream [ + super printOn: stream. + stream nextPut: $(; print: self name; nextPut: $) +] + +{ #category : #accessing } +ZTeamCoordinatorMember >> timezone [ + ^ timezone +] + +{ #category : #accessing } +ZTeamCoordinatorMember >> timezone: anObject [ + timezone := anObject +] diff --git a/repository/ZTimestamp-GT/ZTimezone.extension.st b/repository/ZTimestamp-GT/ZTimezone.extension.st index dca700e..ed9f9e9 100644 --- a/repository/ZTimestamp-GT/ZTimezone.extension.st +++ b/repository/ZTimestamp-GT/ZTimezone.extension.st @@ -78,7 +78,7 @@ ZTimezone class >> gtViewCurrentTimezoneIn: composite [ ^ composite columnedList - title: 'Default'; + title: 'Current'; priority: 11; items: [ {('image default' -> self current id)} ]; column: 'Key' text: #key; From d5d55626c5c7131d8ea2bd2604dde8ded5d16128 Mon Sep 17 00:00:00 2001 From: Sven Van Caekenberghe Date: Tue, 7 Nov 2023 14:16:10 +0100 Subject: [PATCH 2/2] Add a Set button to ZTimezone>>#gtViewCurrentTimezoneIn: --- .../ZTimestamp-GT/ZTimezone.extension.st | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/repository/ZTimestamp-GT/ZTimezone.extension.st b/repository/ZTimestamp-GT/ZTimezone.extension.st index ed9f9e9..fd748ad 100644 --- a/repository/ZTimestamp-GT/ZTimezone.extension.st +++ b/repository/ZTimestamp-GT/ZTimezone.extension.st @@ -80,10 +80,25 @@ ZTimezone class >> gtViewCurrentTimezoneIn: composite [ ^ composite columnedList title: 'Current'; priority: 11; - items: [ {('image default' -> self current id)} ]; + items: [ { ('image default' -> self current id) } ]; column: 'Key' text: #key; column: 'Value' text: #value; - send: [ self current ] + send: [ self current ]; + actionDropdownButtonLabel: 'Set' + tooltip: 'Set the defult image timezone' + content: [ :aButton :aTab | + BrSimpleList new + items: ZTimezone timezoneIdentifiers sorted; + stencil: [ :aString | + BrLabel new + aptitude: BrGlamorousLabelAptitude new + + BrGlamorousListItemAptitude; + text: aString; + when: BlClickEvent do: [ :anEvent | + ZTimezone current: (ZTimezone id: aString). + self inform: ('image timezone set to {1}' format: { aString }). + aTab viewContentElement phlow update. + anEvent target fireEvent: BrDropdownHideWish new] ] ] ] { #category : #'*ZTimestamp-GT' }