Skip to content

Changes for Cavrois before release #1110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 14, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Class {
'kind',
'position',
'strategy',
'count',
'visualPlaceHolder'
'count'
],
#category : 'NewTools-Window-Profiles-Model',
#package : 'NewTools-Window-Profiles',
Expand Down Expand Up @@ -53,6 +52,7 @@ CavAbstractWindowPlaceHolder >> count: aNumber [
{ #category : 'api' }
CavAbstractWindowPlaceHolder >> display [

| visualPlaceHolder |
visualPlaceHolder := CavVisualPlaceHolderMorph new
extent: extent;
position: position;
Expand All @@ -65,7 +65,7 @@ CavAbstractWindowPlaceHolder >> display [
(TextMorph new contents:
kind printString) width / 2)
@ position y + 3).
visualPlaceHolder placeHolder: self.
visualPlaceHolder placeHolder: self.
visualPlaceHolder openInWorld
]

Expand Down
22 changes: 0 additions & 22 deletions src/NewTools-Window-Profiles/CavNullStrategy.class.st

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ CavVisualPlaceHolderMorph >> initialize [
self borderColor: UITheme current selectionColor.
self color: (UITheme current lightSelectionColor alpha: 0.2).
self eventHandler: MorphicEventHandler new.
self eventHandler on: #mouseDown send: #handleClick: to: self.

self eventHandler on: #mouseDown send: #handleClick: to: self
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -87,7 +86,6 @@ CavVisualPlaceHolderMorph >> remove [
key ifEmpty: [
CavroisWindowManager current currentProfile
placeHolderDictionnary removeKey: class ].
self delete.
CavroisWindowManager current removeVisualPlaceholders ].
self delete ].
presenter openDialog
]
19 changes: 0 additions & 19 deletions src/NewTools-Window-Profiles/CavWindowStrategyTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,6 @@ CavWindowStrategyTest >> testExactReplaceStrategyDoesNotChangeExtentAndPosition



]

{ #category : 'tests' }
CavWindowStrategyTest >> testNullStrategyDoesNotChangeExtentAndPosition [

| strategy |
self skip.
self flag: #revisitAlexis.
[ strategy := CavNullStrategy new.
strategy placeHolder: placeHolder.
strategy placePresenter: presenter.
presenter open.
self assert: presenter extent equals: 666@42.
self assert: presenter position equals: 10@10.] ensure: [ presenter delete ]





]

{ #category : 'tests' }
Expand Down
104 changes: 63 additions & 41 deletions src/NewTools-Window-Profiles/CavroisWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ To fully understand my fonctionnalities, you can:

- Lastly, with 'Export Profile', current profile will be saved in a STON file in the Preferences folder as ""Profile:YourProfileName.ston"".
Any profile can be load with 'Import Profile', make sure your file has 'Profile' in it to work.

A profile can be loaded in the StartUp Preferences files, just add this piece of code in it: StartupAction
name: 'Load Profile'
code: [
CavroisWindowManager current makeProfileCurrent: profileName
].
"
Class {
#name : 'CavroisWindowManager',
Expand Down Expand Up @@ -125,10 +129,10 @@ CavroisWindowManager class >> createProfile [
acceptLabel: 'Confirm';
cancelLabel: 'Cancel';
onAccept: [ :dialog |
self updateCurrentProfileBeforeCreation.
self current addProfileFromWindows:
dialog presenter text , ' (Current)'.
MenubarMorph reset ];
self current updatePreviousCurrentProfile.
self current addProfileFromWindows:
dialog presenter text , ' (Current)'.
MenubarMorph reset ];
openDialog
]

Expand Down Expand Up @@ -182,7 +186,9 @@ CavroisWindowManager class >> loadProfile [
at: baseName put: oldProfile;
removeKey: oldKey ].
self current profiles
at: profile name , ' (Current)'
at:
(profile name copyReplaceAll: '(Current)' with: '')
, ' (Current)'
put: profile.
self current currentProfile: profile.
MenubarMorph reset ]
Expand Down Expand Up @@ -269,19 +275,19 @@ CavroisWindowManager class >> renameProfile [
profile := dialog presenter selectedItem.
dialog presenter delete ].
presenter openModal.

presenter := SpRequestDialog new
title: 'Rename ' , profile key;
label: 'What is the new name of your profile ?';
text: '';
acceptLabel: 'Confirm';
cancelLabel: 'Cancel';
onAccept: [ :dialog |
self
updateProfile: profile
withName: dialog presenter text.
MenubarMorph reset ];
openDialog
profile ifNotNil: [
presenter := SpRequestDialog new
title: 'Rename ' , profile key;
label: 'What is the new name of your profile ?';
text: '';
acceptLabel: 'Confirm';
cancelLabel: 'Cancel';
onAccept: [ :dialog |
self
updateProfile: profile
withName: dialog presenter text.
MenubarMorph reset ];
openDialog ]
]

{ #category : 'actions' }
Expand All @@ -295,7 +301,7 @@ CavroisWindowManager class >> renameProfileItem: aBuilder [
iconName: #edit
]

{ #category : 'accessing' }
{ #category : 'class initialization' }
CavroisWindowManager class >> reset [

<script>
Expand All @@ -321,12 +327,16 @@ CavroisWindowManager class >> resetWindowsToCurrentProfile: aBuilder [
CavroisWindowManager class >> saveProfile: aLocation [

| fileString fileName file saveName |
self current currentProfile ifNil: [
self inform: 'No profile registered'.
^ self ].
saveName := self current currentProfile name
copyReplaceAll: '(Current)'
with: ''.
fileString := STON toString: self current currentProfile.
fileName := 'Profile:' , saveName trimBoth , '.ston'.
file := aLocation / fileName.

file writeStreamDo: [ :stream | stream nextPutAll: fileString ].
self inform: 'Profile saved !'
]
Expand Down Expand Up @@ -377,13 +387,13 @@ CavroisWindowManager class >> toggleProfilePlaceholders [
morph isKindOf: CavVisualPlaceHolderMorph ])
ifTrue: [ self current removeVisualPlaceholders ]
ifFalse: [
self current currentProfile ifNotNil: [
| allWindows |
allWindows := self currentWorld windowsSatisfying: [ :w |
w isCollapsed not ].
self current currentProfile placeHolders do: [ :each |
each display ].
allWindows do: [ :w | w hide ] ] ]
self current currentProfile ifNotNil: [
| allWindows |
allWindows := self currentWorld windowsSatisfying: [ :w |
w isCollapsed not ].
self current currentProfile placeHolders do: [ :each |
each display ].
allWindows do: [ :w | w hide ] ] ]
]

{ #category : 'updating' }
Expand All @@ -400,20 +410,6 @@ CavroisWindowManager class >> updateCurrentProfileAfterDeletion: deletedProfileK
self current currentProfile: (self current profiles at: newKey)
]

{ #category : 'updating' }
CavroisWindowManager class >> updateCurrentProfileBeforeCreation [

| oldProfile oldKey newKey |
self current currentProfile ifNotNil: [
oldProfile := self current currentProfile.
oldKey := self current profiles keyAtValue: oldProfile.
newKey := oldKey copyReplaceAll: '(Current)' with: ''.

self current profiles
at: newKey put: oldProfile;
removeKey: oldKey ]
]

{ #category : 'updating' }
CavroisWindowManager class >> updateProfile [

Expand Down Expand Up @@ -514,6 +510,19 @@ CavroisWindowManager >> kindFor: aString [
^ classToolMapping at: aString ifAbsent: [ #Unknown ]
]

{ #category : 'action' }
CavroisWindowManager >> makeProfileCurrent: aProfileName [

| profile |
profile := STON fromString:
FileLocator preferences asFileReference / 'pharo'
/ ('Profile:{1}.ston' format: { aProfileName }).
self updatePreviousCurrentProfile.
self profiles at: aProfileName , ' (Current)' put: profile.
self currentProfile: profile.
MenubarMorph reset
]

{ #category : 'actions' }
CavroisWindowManager >> nextPlaceHolderIndexFor: aWindowType ifAbsent: aBlock [

Expand Down Expand Up @@ -614,6 +623,19 @@ CavroisWindowManager >> transitionToProfile [
w extent: placeHolder extent ] ] ]
]

{ #category : 'update' }
CavroisWindowManager >> updatePreviousCurrentProfile [

| oldProfile oldKey newKey |
currentProfile ifNotNil: [
oldProfile := currentProfile.
oldKey := profiles keyAtValue: oldProfile.
newKey := oldKey copyReplaceAll: '(Current)' with: ''.
profiles
at: newKey put: oldProfile;
removeKey: oldKey ]
]

{ #category : 'updating' }
CavroisWindowManager >> updateProfile [

Expand Down
Loading