Skip to content

Commit

Permalink
Added an application. Renamed some classes. Using the application to …
Browse files Browse the repository at this point in the history
…start the presenters instead of sending new openWithSpec. Using styles.
  • Loading branch information
jordanmontt committed Nov 17, 2021
1 parent a76d8ed commit 03af9be
Show file tree
Hide file tree
Showing 20 changed files with 267 additions and 131 deletions.
17 changes: 9 additions & 8 deletions src/RewriteRuleBuilder/RewriteRuleBuilderPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ RewriteRuleBuilderPresenter class >> menuCommandOn: aBuilder [
{ #category : #'instance creation' }
RewriteRuleBuilderPresenter class >> open [

^ self new openWithSpec
<example>
^ RTApplication new startRuleBuilder
]

{ #category : #accessing }
Expand All @@ -90,7 +91,7 @@ RewriteRuleBuilderPresenter >> applyOnAllClasses [
(UIManager default confirm:
'Do you want to apply this rule to all system classes?') ifFalse: [
^ self ].
RTRuleTransformerPresenter
RTCodeTransformerPresenter
runReplaceWithRuleAsAssociation: self lhs text -> self rhs text
isForMethod: false
]
Expand Down Expand Up @@ -216,17 +217,17 @@ RewriteRuleBuilderPresenter >> initializePresenters [
icon: MatchToolPresenter icon.
basicEditorButton := self newButton
label: 'Basic Editor';
icon: RTBasicEditorPresenter icon.
icon: RTRuleEditorPresenter icon.
applyOnAllClassesButton := self newButton
label: 'On all classes';
help:
'Apply the current rewrite rule that is on this tool to all classes in the system.';
icon: RTRuleTransformerPresenter icon.
icon: RTCodeTransformerPresenter icon.
applierButton := self newButton
label: 'On selection...';
help:
'Open a tool to apply a saved rewrite rule to a selected set of classes.';
icon: RTRuleTransformerPresenter icon.
icon: RTCodeTransformerPresenter icon.
buttonsBar := self newButtonBar
add: saveRuleButton;
add: applierButton;
Expand Down Expand Up @@ -319,16 +320,16 @@ RewriteRuleBuilderPresenter >> openApplier [
| applier |
^ loadedRule
ifNotNil: [
applier := RTRuleTransformerPresenter new.
applier := RTCodeTransformerPresenter new.
applier selectedRules: { loadedRule class }.
applier openWithSpec ]
ifNil: [ RTRuleTransformerPresenter open ]
ifNil: [ RTCodeTransformerPresenter open ]
]

{ #category : #actions }
RewriteRuleBuilderPresenter >> openBasicRuleEditor [

^ RTBasicEditorPresenter new
^ RTRuleEditorPresenter new
rhs: self rhs;
lhs: self lhs;
openWithSpec
Expand Down
2 changes: 1 addition & 1 deletion src/RewriteRuleTools/ApplyRuleOnAllClassesCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ApplyRuleOnAllClassesCommand class >> defaultName [
{ #category : #default }
ApplyRuleOnAllClassesCommand class >> iconName [

^ RTRuleTransformerPresenter iconName
^ RTCodeTransformerPresenter iconName
]

{ #category : #executing }
Expand Down
55 changes: 36 additions & 19 deletions src/RewriteRuleTools/MatchToolPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ MatchToolPresenter class >> menuCommandOn: aBuilder [
{ #category : #api }
MatchToolPresenter class >> open [
<example>
^ self new openWithSpec
^ RTApplication new startMatchTool
]

{ #category : #accessing }
{ #category : #specs }
MatchToolPresenter class >> title [

^ 'Match Tool'
Expand Down Expand Up @@ -100,6 +100,32 @@ MatchToolPresenter >> getBindingsItemsForMatch: bindingsAssociation [
^ newItems flattened
]

{ #category : #initialization }
MatchToolPresenter >> initializeButtons [

executeButton := self newButton.
executeButton
icon: (self iconNamed: #smallDoIt);
label: 'Match';
shortcut: Character cr meta.
]

{ #category : #initialization }
MatchToolPresenter >> initializeEditors [

methodCheckbox := self newCheckBox label: 'Is rule for method?'.

codeLabel := self newLabel label: 'Pharo code'.

codeEditor := self newCode.
codeEditor
withoutLineNumbers;
beForScripting;
text: DefaultRule new inputCode.

ruleEditor := self instantiate: RTSearchForPanel.
]

{ #category : #initialization }
MatchToolPresenter >> initializeLayout [

Expand Down Expand Up @@ -134,23 +160,7 @@ MatchToolPresenter >> initializeLayout [
]

{ #category : #initialization }
MatchToolPresenter >> initializePresenters [

methodCheckbox := self newCheckBox label: 'Is rule for method?'.
codeLabel := self newLabel label: 'Pharo code'.

codeEditor := self newCode.
codeEditor
withoutLineNumbers;
beForScripting;
text: DefaultRule new inputCode.
ruleEditor := self instantiate: RTSearchForPanel.

executeButton := self newButton.
executeButton
icon: (self iconNamed: #smallDoIt);
label: 'Match';
shortcut: Character cr meta.
MatchToolPresenter >> initializeMatchesPresenters [

matchesList := self newList.
matchesList display: [ :assoc | assoc key formattedCode ].
Expand All @@ -164,7 +174,14 @@ MatchToolPresenter >> initializePresenters [
title: 'Bindings'
evaluated: [ :assoc | assoc value formattedCode ]);
beResizable.
]

{ #category : #initialization }
MatchToolPresenter >> initializePresenters [

self initializeEditors.
self initializeButtons.
self initializeMatchesPresenters.
self initializeLayout.

self focusOrder
Expand Down
6 changes: 6 additions & 0 deletions src/RewriteRuleTools/OpenMatchToolCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Class {
#category : #'RewriteRuleTools-Commands'
}

{ #category : #default }
OpenMatchToolCommand class >> defaultDescription [

^ 'Open MatchTool'
]

{ #category : #default }
OpenMatchToolCommand class >> defaultName [

Expand Down
4 changes: 2 additions & 2 deletions src/RewriteRuleTools/OpenRTApplierCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ OpenRTApplierCommand class >> defaultName [
{ #category : #default }
OpenRTApplierCommand class >> iconName [

^ RTRuleTransformerPresenter iconName
^ RTCodeTransformerPresenter iconName
]

{ #category : #executing }
OpenRTApplierCommand >> execute [

^ RTRuleTransformerPresenter open
^ RTCodeTransformerPresenter open
]
10 changes: 8 additions & 2 deletions src/RewriteRuleTools/OpenRTBasicEditorCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Class {
#category : #'RewriteRuleTools-Commands'
}

{ #category : #default }
OpenRTBasicEditorCommand class >> defaultDescription [

^ 'Open Rewrite Rule Editor'
]

{ #category : #default }
OpenRTBasicEditorCommand class >> defaultName [

Expand All @@ -18,13 +24,13 @@ OpenRTBasicEditorCommand class >> defaultName [
{ #category : #default }
OpenRTBasicEditorCommand class >> iconName [

^RTBasicEditorPresenter iconName
^RTRuleEditorPresenter iconName
]

{ #category : #executing }
OpenRTBasicEditorCommand >> execute [

^ RTBasicEditorPresenter new
^ RTRuleEditorPresenter new
lhs: self context lhs;
rhs: self context rhs;
openWithSpec
Expand Down
6 changes: 6 additions & 0 deletions src/RewriteRuleTools/OpenRTExpressionFinderCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Class {
#category : #'RewriteRuleTools-Commands'
}

{ #category : #default }
OpenRTExpressionFinderCommand class >> defaultDescription [

^ 'Find ocurrences of an expression in all Pharo''s code'
]

{ #category : #default }
OpenRTExpressionFinderCommand class >> defaultName [

Expand Down
8 changes: 7 additions & 1 deletion src/RewriteRuleTools/OpenRTHelpBrowserCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Class {
#category : #'RewriteRuleTools-Commands'
}

{ #category : #default }
OpenRTHelpBrowserCommand class >> defaultDescription [

^ 'Help browser'
]

{ #category : #default }
OpenRTHelpBrowserCommand class >> defaultName [

Expand All @@ -24,5 +30,5 @@ OpenRTHelpBrowserCommand class >> iconName [
{ #category : #executing }
OpenRTHelpBrowserCommand >> execute [

^ RTRulesHelpPresenter open
^ RTHelpBrowserPresenter open
]
6 changes: 6 additions & 0 deletions src/RewriteRuleTools/OpenRTRuleLoaderCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Class {
#category : #'RewriteRuleTools-Commands'
}

{ #category : #default }
OpenRTRuleLoaderCommand class >> defaultDescription [

^ 'Load a stored Rewrite Rule'
]

{ #category : #default }
OpenRTRuleLoaderCommand class >> defaultName [

Expand Down
82 changes: 82 additions & 0 deletions src/RewriteRuleTools/RTApplication.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"
I am an application to use in all RT tool to define costum styles.
"
Class {
#name : #RTApplication,
#superclass : #SpApplication,
#classVars : [
'Current'
],
#category : #'RewriteRuleTools-Application'
}

{ #category : #accessing }
RTApplication class >> current [

^ Current ifNil: [ Current := self new ]
]

{ #category : #running }
RTApplication >> start [

(self newPresenter: RTRuleEditorPresenter) openWithSpec
]

{ #category : #running }
RTApplication >> startExpressionFinder [

^ (self newPresenter: RTExpressionFinderPresenter) openWithSpec
]

{ #category : #running }
RTApplication >> startHelpBrowser [

^ (self newPresenter: RTHelpBrowserPresenter) openWithSpec
]

{ #category : #running }
RTApplication >> startMatchTool [

^ (self newPresenter: MatchToolPresenter) openWithSpec
]

{ #category : #running }
RTApplication >> startRuleBuilder [

^ (self newPresenter: RewriteRuleBuilderPresenter) openWithSpec
]

{ #category : #running }
RTApplication >> startRuleEditor [

^ (self newPresenter: RTRuleEditorPresenter) openWithSpec
]

{ #category : #running }
RTApplication >> startRuleLoader [

^ (self newPresenter: RTRuleLoaderPresenter) openWithSpec
]

{ #category : #running }
RTApplication >> startTransformer [

^ (self newPresenter: RTCodeTransformerPresenter) openWithSpec
]

{ #category : #styling }
RTApplication >> styleSheet [

^ SpStyle defaultStyleSheet,
(SpStyleVariableSTONReader fromString:
'.application [
.container [ Container { #padding: 4, #borderWidth: 2 } ],
.bgOpaque [ Draw { #backgroundColor: EnvironmentColor(#base) } ],
.bgBlue [ Draw { #backgroundColor: #blue } ],
.boldFont [ Font { #bold: true } ],
.textFont [ Font { #name: EnvironmentFont(#default) } ],
.bigFontSize [ Font { #size: 20 } ],
.buttonStyle [ Geometry { #width: 130 } ]
]')
]
13 changes: 11 additions & 2 deletions src/RewriteRuleTools/RTCheatSheetPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@ RTCheatSheetPresenter >> initializeLayout [
{ #category : #initialization }
RTCheatSheetPresenter >> initializePresenters [

textPresenter := self newText
textPresenter := self newText.
textPresenter
text: self helpText;
beNotEditable.

helpButton := self instantiate: (OpenRTHelpBrowserCommand asSpecButtonForContext: self).

self initializeStyles.
self initializeLayout
"cheatSheet color: self theme baseColor"
]

{ #category : #initialization }
RTCheatSheetPresenter >> initializeStyles [

textPresenter addStyle: 'bgOpaque'.
]
Loading

0 comments on commit 03af9be

Please sign in to comment.