Skip to content

Commit

Permalink
Using the search for panel in match tool and adding the help button t…
Browse files Browse the repository at this point in the history
…o the cheat sheet.
  • Loading branch information
jordanmontt committed Nov 16, 2021
1 parent 5295f21 commit d9aae61
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 127 deletions.
106 changes: 54 additions & 52 deletions src/RewriteRuleTools/MatchToolPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Class {
'codeLabel',
'methodCheckbox',
'astPattern',
'astCode',
'patternLabel'
'astCode'
],
#category : #'RewriteRuleTools-MatchTool'
}
Expand Down Expand Up @@ -105,63 +104,68 @@ MatchToolPresenter >> getBindingsItemsForMatch: bindingsAssociation [
MatchToolPresenter >> initializeLayout [

| rulePanel codePanel matchesListPanel |
rulePanel := SpBoxLayout newVertical
add: (SpBoxLayout newHorizontal
add: #patternLabel;
addLast: #methodCheckbox;
yourself)
expand: false;
add: #ruleEditor;
yourself.
codePanel := SpBoxLayout newVertical
add: #codeLabel expand: false;
add: #codeEditor;
yourself.
rulePanel := SpBoxLayout newTopToBottom
add: methodCheckbox expand: false;
add: ruleEditor;
yourself.
codePanel := SpBoxLayout newTopToBottom
add: codeLabel expand: false;
add: codeEditor;
yourself.
matchesListPanel := SpBoxLayout newVertical
add: #executeButton expand: false;
add: #matchesList;
yourself.
add: executeButton expand: false;
add: matchesList;
yourself.

self layout: (SpPanedLayout newLeftToRight
add: (SpPanedLayout newTopToBottom
add: rulePanel;
add: codePanel;
yourself);
add: (SpPanedLayout newHorizontal
add: matchesListPanel;
add: #bindingsTable;
yourself);
yourself)
add: (SpPanedLayout newTopToBottom
add: rulePanel;
add: codePanel;
yourself);
add: (SpPanedLayout newHorizontal
add: matchesListPanel;
add: bindingsTable;
yourself);
yourself)
]

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

methodCheckbox := self newCheckBox label: 'Method'.
methodCheckbox := self newCheckBox label: 'Is rule for method?'.
codeLabel := self newLabel label: 'Pharo code'.
patternLabel := self newLabel label: 'Pattern code'.
codeEditor := self newCode
withoutLineNumbers;
text: DefaultRule new inputCode.
ruleEditor := self newCode
withoutLineNumbers;
withoutSyntaxHighlight;
text: DefaultRule new lhs.
executeButton := self newButton
icon: (self iconNamed: #smallDoIt);
label: 'Match';
shortcut: Character cr meta.
matchesList := self newList display: [ :assoc |
assoc key formattedCode ].

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.

matchesList := self newList.
matchesList display: [ :assoc | assoc key formattedCode ].

bindingsTable := self newTable.
bindingsTable
addColumn: (SpStringTableColumn
title: 'Pattern'
evaluated: [ :assoc | assoc key formattedCode ]);
title: 'Pattern'
evaluated: [ :assoc | assoc key formattedCode ]);
addColumn: (SpStringTableColumn
title: 'Bindings'
evaluated: [ :assoc | assoc value formattedCode ]);
title: 'Bindings'
evaluated: [ :assoc | assoc value formattedCode ]);
beResizable.
self initializeLayout

self initializeLayout.

self focusOrder
add: ruleEditor;
add: codeEditor
]

{ #category : #initialization }
Expand Down Expand Up @@ -194,23 +198,21 @@ MatchToolPresenter >> parseCodeAST [
MatchToolPresenter >> parsePatternAST [

astPattern := methodCheckbox state
ifTrue: [
RBPatternParser parseMethod: ruleEditor text ]
ifFalse: [
RBPatternParser parseExpression: ruleEditor text ].
ifTrue: [ RBPatternParser parseMethod: ruleEditor lhs ]
ifFalse: [ RBPatternParser parseExpression: ruleEditor lhs ].

]

{ #category : #accessing }
MatchToolPresenter >> patternCode [

^ ruleEditor text
^ ruleEditor lhs
]

{ #category : #accessing }
MatchToolPresenter >> patternCode: aPatternCode [

ruleEditor text: aPatternCode
ruleEditor lhs: aPatternCode
]

{ #category : #actions }
Expand Down
3 changes: 0 additions & 3 deletions src/RewriteRuleTools/RTBasicEditorPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Class {
'saveButton',
'loadButton',
'expressionFinderButton',
'helpButton',
'matcherButton',
'searchForEditor',
'replaceWithEditor',
Expand Down Expand Up @@ -94,7 +93,6 @@ RTBasicEditorPresenter >> initializeButtons [
openApplierButton := self instantiate: (OpenRTApplierCommand asSpecButtonForContext: self).
matcherButton := self instantiate: (OpenMatchToolCommand asSpecButtonForContext: self).
applyButton := self instantiate: (ApplyRuleOnAllClassesCommand asSpecButtonForContext: self).
helpButton := self instantiate: (OpenRTHelpBrowserCommand asSpecButtonForContext: self).
expressionFinderButton := self instantiate: (OpenRTExpressionFinderCommand asSpecButtonForContext: self).
]

Expand All @@ -109,7 +107,6 @@ RTBasicEditorPresenter >> initializeLayout [
yourself);
add: (SpBoxLayout newTopToBottom
add: isMethodCheckbox expand: false;
add: helpButton expand: false;
add: cheatSheet expand: true;
add: applyButton expand: false;
add: openApplierButton expand: false;
Expand Down
7 changes: 5 additions & 2 deletions src/RewriteRuleTools/RTCheatSheetPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Class {
#name : #RTCheatSheetPresenter,
#superclass : #SpPresenter,
#instVars : [
'textPresenter'
'textPresenter',
'helpButton'
],
#category : #'RewriteRuleTools-Widgets'
#category : #'RewriteRuleTools-Help'
}

{ #category : #accessing }
Expand All @@ -28,6 +29,7 @@ RTCheatSheetPresenter >> helpText [
RTCheatSheetPresenter >> initializeLayout [

self layout: (SpBoxLayout newTopToBottom
add: helpButton expand: false;
add: textPresenter;
yourself)
]
Expand All @@ -38,6 +40,7 @@ RTCheatSheetPresenter >> initializePresenters [
textPresenter := self newText
text: self helpText;
beNotEditable.
helpButton := self instantiate: (OpenRTHelpBrowserCommand asSpecButtonForContext: self).
self initializeLayout
"cheatSheet color: self theme baseColor"
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
'codePresenter',
'listPresenter'
],
#category : #'RewriteRuleTools-ExpressionFinder'
#category : #'RewriteRuleTools-ChangesBrowser'
}

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion src/RewriteRuleTools/RTReplaceWithPanel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RTReplaceWithPanel >> initializePresenters [
codePresenter := self newCode.
codePresenter
text: DefaultRule new rhs;
beForScripting;
withoutSyntaxHighlight;
withoutLineNumbers.

self initializeLayout
Expand Down
16 changes: 10 additions & 6 deletions src/RewriteRuleTools/RTRuleTransformerPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,18 @@ RTRuleTransformerPresenter >> initializeButtons [
{ #category : #initialization }
RTRuleTransformerPresenter >> initializeLayout [

| fixedWidth |
fixedWidth := 130.

self layout: (SpBoxLayout newTopToBottom
add: methodsSelectorPresenter;
addLast: (SpBoxLayout newLeftToRight
add: openRulesTableButton width: 130;
addLast: applyOnSelectedClassesButton;
addLast: applyOnAllClassesButton;
addLast: openLoaderButton;
yourself);
add: (SpBoxLayout newLeftToRight
add: openRulesTableButton width: fixedWidth;
addLast: applyOnSelectedClassesButton withConstraints: [ :c | c width: fixedWidth];
addLast: applyOnAllClassesButton withConstraints: [ :c | c width: fixedWidth];
addLast: openLoaderButton withConstraints: [ :c | c width: fixedWidth];
yourself)
expand: false;
yourself)
]

Expand Down
2 changes: 1 addition & 1 deletion src/RewriteRuleTools/RTSearchForPanel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RTSearchForPanel >> initializePresenters [
codePresenter := self newCode.
codePresenter
text: DefaultRule new lhs;
beForScripting;
withoutSyntaxHighlight;
withoutLineNumbers.

self initializeLayout
Expand Down
57 changes: 0 additions & 57 deletions src/RewriteTool-Tests/CustomRewriteRuleTest.class.st

This file was deleted.

8 changes: 4 additions & 4 deletions src/RewriteTool-Tests/MatchToolPresenterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ MatchToolPresenterTest >> testGetBindingsItemsForMatch [
MatchToolPresenterTest >> testInitializePresenters [

self assert: matchToolPresenter methodCheckbox class equals: SpCheckBoxPresenter.
self assert: matchToolPresenter ruleEditor class equals: SpCodePresenter.
self assert: matchToolPresenter ruleEditor class equals: RTSearchForPanel.
self assert: matchToolPresenter codeEditor class equals: SpCodePresenter.
self assert: matchToolPresenter matchesList class equals: SpListPresenter.
self assert: matchToolPresenter bindingsTable class equals: SpTablePresenter.
self assert: matchToolPresenter codeEditor text isNotEmpty.
self assert: matchToolPresenter ruleEditor text isNotEmpty
self assert: matchToolPresenter ruleEditor lhs isNotEmpty
]

{ #category : #tests }
Expand Down Expand Up @@ -191,12 +191,12 @@ MatchToolPresenterTest >> testParsePatternAST [
| `object |
`object ifNil: [ ^ self ].
`.Statement.'.
matchToolPresenter ruleEditor text: rule.
matchToolPresenter ruleEditor lhs: rule.
matchToolPresenter parsePatternAST.
self
assert: matchToolPresenter astPattern
equals: (RBPatternParser parseExpression: rule).
matchToolPresenter ruleEditor text: methodRule.
matchToolPresenter ruleEditor lhs: methodRule.
matchToolPresenter methodCheckbox click.
matchToolPresenter parsePatternAST.
self
Expand Down

0 comments on commit d9aae61

Please sign in to comment.