Skip to content

Commit

Permalink
Add abstract GUI to select an item from a dropList, and choose elemen…
Browse files Browse the repository at this point in the history
…ts from a list. Change preview of push down method, using the new GUI. Remove old GUIs of push up and push down
  • Loading branch information
Lin777 committed Feb 10, 2021
1 parent 146b00a commit 17065f4
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 252 deletions.
Expand Up @@ -67,7 +67,7 @@ SycPushDownMethodCommand >> selectMethods [
selectedMethods := methods copy asOrderedCollection.
class := methods first origin.
dialog := RBMethodsSelectionPresenter
label: class name,' - Select all methods to push down'
label: 'Push down methods from ', class name
withItems: (class methods sort: [ :a :b | a asString < b asString ]) asOrderedCollection
selecting: selectedMethods.
dialog cancelled ifTrue: [ CmdCommandAborted signal ].
Expand Down
34 changes: 29 additions & 5 deletions src/SystemCommands-MethodCommands/SycPushUpMethodCommand.class.st
Expand Up @@ -4,6 +4,9 @@ I am a command to push up given methods
Class {
#name : #SycPushUpMethodCommand,
#superclass : #SycMethodCommand,
#instVars : [
'superclass'
],
#category : #'SystemCommands-MethodCommands'
}

Expand All @@ -26,13 +29,11 @@ SycPushUpMethodCommand class >> methodShortcutActivation [

{ #category : #execution }
SycPushUpMethodCommand >> asRefactorings [
|dialog refactoring|
| refactoring |
refactoring := RBPullUpMethodRefactoring
pullUp: methods
pullUp: (methods collect: #selector)
from: methods first origin.
refactoring setOption: #superClass toUse: [ :ref |
dialog := RBPushUpPreviewPresenter on: ref.
dialog cancelled ifTrue: [ CmdCommandAborted signal ]].
refactoring superClass: superclass.
^ OrderedCollection with: refactoring
]

Expand All @@ -56,3 +57,26 @@ SycPushUpMethodCommand >> execute [
SycPushUpMethodCommand >> isComplexRefactoring [
^true
]

{ #category : #execution }
SycPushUpMethodCommand >> prepareFullExecutionInContext: aToolContext [
super prepareFullExecutionInContext: aToolContext.
self selectMethodsAndSuperclass.
]

{ #category : #execution }
SycPushUpMethodCommand >> selectMethodsAndSuperclass [
| selectedMethods dialog class classes |
selectedMethods := methods copy asOrderedCollection.
class := methods first origin.
classes := class allSuperclasses removeAllSuchThat: [ :each | each == Object or: [ each == ProtoObject ] ].
dialog := RBSelectClassAndMethodsPresenter
label: 'Methods to be pull up'
dropLabel: 'Pull up methods of ', class name, ' to:'
withItems: (class methods sort: [ :a :b | a asString < b asString ]) asOrderedCollection
selecting: selectedMethods
dropItems: classes
acceptBlock: [ :item :items | superclass := item.
methods := items ].
dialog cancelled ifTrue: [ CmdCommandAborted signal ].
]
@@ -0,0 +1,72 @@
Class {
#name : #RBAbstractSelectionPresenter,
#superclass : #RBItemsSelectionPresenter,
#instVars : [
'dropList',
'dropLabel',
'acceptBlock'
],
#category : #'SystemCommands-RefactoringSupport'
}

{ #category : #specs }
RBAbstractSelectionPresenter class >> defaultSpec [
^ SpBoxLayout newVertical
add: #dropLabel withConstraints: [ :c | c height: self labelHeight ];
add:
(SpBoxLayout newHorizontal
add: #dropList ;
yourself) withConstraints: [ :c | c height: self toolbarHeight ];
add: #label withConstraints: [ :c | c height: self buttonHeight ];
add:
(SpBoxLayout newHorizontal
add: #table;
yourself);
yourself
]

{ #category : #specs }
RBAbstractSelectionPresenter class >> label: aString dropLabel: aString2 withItems: coll1 selecting: coll2 dropItems: coll3 acceptBlock: aBlock [
^ self new
label: aString
dropLabel: aString2
withItems: coll1
selecting: coll2
dropItems: coll3
acceptBlock: aBlock;
openModalWithSpec
]

{ #category : #actions }
RBAbstractSelectionPresenter >> accept [
acceptBlock value: self selectedItem value: selectedItems
]

{ #category : #initialization }
RBAbstractSelectionPresenter >> initializeDropList [
dropList := self newDropList.
dropList
display: [ :scope | scope name ];
iconBlock: [ :e | e systemIcon ]
]

{ #category : #initialization }
RBAbstractSelectionPresenter >> initializeWidgets [
super initializeWidgets .
dropLabel := self newLabel.
self initializeDropList.
]

{ #category : #initialization }
RBAbstractSelectionPresenter >> label: aString dropLabel: aString2 withItems: coll1 selecting: coll2 dropItems: coll3 acceptBlock: aBlock [
self label: aString withItems: coll1 selecting: coll2.
dropLabel label: aString2.
dropList items: coll3.
acceptBlock := aBlock.

]

{ #category : #accessing }
RBAbstractSelectionPresenter >> selectedItem [
^ dropList selectedItem
]
Expand Up @@ -28,7 +28,7 @@ Class {
#category : #'SystemCommands-RefactoringSupport'
}

{ #category : #visiting }
{ #category : #specs }
RBItemsSelectionPresenter class >> defaultSpec [
^ SpBoxLayout newVertical
add: #label withConstraints: [ :c | c height: self buttonHeight ];
Expand All @@ -39,7 +39,7 @@ RBItemsSelectionPresenter class >> defaultSpec [
yourself
]

{ #category : #visiting }
{ #category : #specs }
RBItemsSelectionPresenter class >> label: aString withItems: coll1 selecting: coll2 [
^ self new
label: aString withItems: coll1 selecting: coll2;
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 17065f4

Please sign in to comment.