Skip to content
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

Add new button to not save the tokens #141

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/Toplo-IDE/ToThemeEditorThemeInfos.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Class {
'tokensPresenter',
'tokenAll',
'tokenNo',
'tokenNew'
'tokenNew',
'tokenInherit'
],
#category : #'Toplo-IDE-theme-editor-presenter-themeInfos'
}
Expand Down Expand Up @@ -39,8 +40,9 @@ ToThemeEditorThemeInfos >> defaultLayout [
expand: false;
add: self themeClassInput expand: false;
add: self tokenAll expand: false;
add: self tokenNew expand: false;
add: self tokenNo expand: false;
add: self tokenNew expand: false;
add: self tokenInherit expand: false;
add: self tokenNo expand: false;
add: self saveButton expand: false;
add: self inspectButton expand: false;
add: self notebook expand: true;
Expand Down Expand Up @@ -75,12 +77,18 @@ ToThemeEditorThemeInfos >> initializePresenters [
label: 'Save all tokens in theme.';
yourself.
tokenNew := SpRadioButtonPresenter new
label: 'Save only the tokens not in parents theme.';
label: 'Save only the new and modified tokens.';
yourself.
tokenInherit := SpRadioButtonPresenter new
label: 'Inherit tokens from parent.';
yourself.
tokenNo := SpRadioButtonPresenter new
label: 'Do not save the tokens.';
label: 'Do not modify the tokens method.';
yourself.
tokenAll associatedRadioButtons: { tokenNew . tokenNo }
tokenAll associatedRadioButtons: {
tokenNew.
tokenNo.
tokenInherit }
]

{ #category : #layout }
Expand All @@ -107,11 +115,12 @@ ToThemeEditorThemeInfos >> saveCurrentTheme [
| model |
model := ToThemeModel new
theme: self theme;
tokens: self tokensPresenter controller tokens;
tokens: self tokensPresenter controller tokens;
yourself.
self tokenAll state ifTrue: [ model doNotHeritToken ].
self tokenNew state ifTrue: [ model onlyDifferentTokens ].
self tokenNo state ifTrue: [ model doHeritToken ].
self tokenInherit state ifTrue: [ model doHeritToken ].
self tokenNo state ifTrue: [ model doNotModifyToken ].
model compileOnCurrentTheme
]

Expand Down Expand Up @@ -140,6 +149,11 @@ ToThemeEditorThemeInfos >> tokenAll [
^ tokenAll
]

{ #category : #initialization }
ToThemeEditorThemeInfos >> tokenInherit [
^ tokenInherit
]

{ #category : #initialization }
ToThemeEditorThemeInfos >> tokenNew [
^ tokenNew
Expand Down
7 changes: 7 additions & 0 deletions src/Toplo-IDE/ToThemeModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ ToThemeModel >> compileStyleRulesOn: aTheme [
ToThemeModel >> compileTokensOn: aTheme [

| formatedSourceCode expr tokenStream |
self tokensModel shouldCompile ifFalse: [ ^ self ].
tokenStream := String new writeStream.
self tokensModel asSourceCodeOn: tokenStream.
expr := RBParser parseMethod: tokenStream contents expandMacros.
Expand All @@ -89,6 +90,12 @@ ToThemeModel >> doNotHeritToken [
self tokensModel strategy: ToTokensDoNotHeritFromParentStrategy new
]

{ #category : #'as yet unclassified' }
ToThemeModel >> doNotModifyToken [

self tokensModel strategy: ToTokensDoNotCompileStrategy new
]

{ #category : #initialization }
ToThemeModel >> initialize [

Expand Down
11 changes: 11 additions & 0 deletions src/Toplo-IDE/ToTokensDoNotCompileStrategy.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Class {
#name : #ToTokensDoNotCompileStrategy,
#superclass : #ToTokensStrategy,
#category : #'Toplo-IDE-theme-serialization'
}

{ #category : #asserting }
ToTokensDoNotCompileStrategy >> shouldCompile [

^ false
]
6 changes: 6 additions & 0 deletions src/Toplo-IDE/ToTokensModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ ToTokensModel >> selector [
^ 'defaultTokenProperties'
]

{ #category : #asserting }
ToTokensModel >> shouldCompile [

^ self strategy shouldCompile
]

{ #category : #accessing }
ToTokensModel >> strategy [

Expand Down
6 changes: 6 additions & 0 deletions src/Toplo-IDE/ToTokensStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ ToTokensStrategy >> asSourceCodeWith: aCollection [
self shouldBeImplemented

]

{ #category : #asserting }
ToTokensStrategy >> shouldCompile [

^ true
]
Loading