Skip to content

Commit

Permalink
Add new button to not save the tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Apr 29, 2024
1 parent 0eec312 commit 6e3ed7f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
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
]

0 comments on commit 6e3ed7f

Please sign in to comment.